[Haskell-cafe] ghc -e

Reid Barton rwbarton at math.harvard.edu
Wed Jan 6 21:15:11 EST 2010

On Thu, Jan 07, 2010 at 10:23:35AM +1000, Tony Morris wrote:
> Can I import a module when using ghc -e?
> e.g. ghc -e "import Control.Monad; forM [[1,2,3]] reverse"

One option is to create a file "imports.hs" which contains the text
"import Control.Monad", and then run

ghc -e "forM [[1,2,3]] reverse" imports.hs

I use this method in a short shell script "interact" so that I can
apply Haskell functions to files from the command line and don't have
to type the full qualified names of things in modules I use frequently.

Reid Barton

More information about the Haskell-Cafe mailing list