[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] ghc -e

Subject: Re: [Haskell-cafe] ghc -e
From: Jason Dagit
Date: Wed, 6 Jan 2010 18:53:49 -0800


On Wed, Jan 6, 2010 at 6:15 PM, Reid Barton <[email protected]> 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 trick.

HTH,
Jason
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
<Prev in Thread] Current Thread [Next in Thread>