> is there a way to write haskell code with indentation based expression
> boundaries and evaluate that in ghci ?

You can easily write a function to remove layout.

import Language.Haskell.Exts.Parser {- haskell-src-exts -}
import Language.Haskell.Exts.Pretty

unlayout :: String -> String
unlayout s =
    let m = defaultMode {layout = PPNoLayout}
        ParseOk r = parseExp s
    in prettyPrintWithMode m r

-- > unlayout t0 == "let { a = 5; b = 6} in a + b"
t0 :: String
t0 = unlines ["let a = 5"
             ,"    b = 6"
             ,"in a + b"]

-- > unlayout t1 == unlayout t0
t1 :: String
t1 = "let {a = 5;b = 6} in a + b"

main :: IO ()
main = getContents >>= putStrLn . unlayout

It's not in hsc3 because haskell-src-exts seems a major dependency for a
three line function...

You can run the 'unlayout' process over outgoing expressions in emacs
using 'shell-command-to-string'.

Best,
Rohan

_______________________________________________
haskell-art mailing list
[email protected]
http://lists.lurk.org/mailman/listinfo/haskell-art

Reply via email to