GHCi instructions from the command line

command-line, haskell

Solution

You can use `ghc -e` for this:

sorghum:~/programming% cat test.hs
getFoo = getLine
sorghum:~/programming% ghc test.hs -e 'do { a <- getFoo; print a }'
oenuth
"oenuth"

Problem

In the shell you can string commands together, separated by a semicolon: ``` cd ../haskell; rm ./foo; ghc foo.hs; cd ../original_directory ``` It would be great if you could do a similar thing for command-line arguments for ghci, e.g. ``` ghci Foo.hs; a <- getFoo; print a ``` Is this possible?

Original source