ghc -e

Benjamin Franksen benjamin.franksen at bessy.de
Wed Nov 17 07:10:58 EST 2004


Hello,

I want to use ghc as a script interpreter, using the '-e' option. The 
problem is that I can't give the script any command line arguments, 
because 'ghc -e' intepretes everything argument as the name of a module 
to compile.

> cat Test.hs
import System
main = getArgs >>= print
> ghc -e Main.main Test.hs
[]
> ghc -e Main.main Test.hs blabla
    Can't find module `blabla'
    (use -v to see a list of the files searched for)

<interactive>:1:
    Failed to load interface for `Main':
        Bad interface file: Test.hi
            Test.hi: openBinaryFile: does not exist (No such file or 
directory)

<interactive>:1: Variable not in scope: `Main.main'

Is there a way to tell ghc that what follows are arguments to teh 
program ('main') and not to ghc itself?

Ben


More information about the Glasgow-haskell-users mailing list