[Haskell-cafe] ghc -e

Jason Dagit dagit at codersbase.com
Wed Jan 6 21:53:49 EST 2010

On Wed, Jan 6, 2010 at 6:15 PM, Reid Barton <rwbarton at math.harvard.edu>wrote:

> 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.

Did you know you can put commands in $HOME/.ghci that will be loaded every
time you run ghci?

So, if you have modules that you commonly use put something like:
:m + Control.Monad

In your $HOME/.ghci file and then you can use ghci instead of this ghc -e

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100106/fbe7ad82/attachment.html

More information about the Haskell-Cafe mailing list