ghc -e

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


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)

    Failed to load interface for `Main':
        Bad interface file: Test.hi
            Test.hi: openBinaryFile: does not exist (No such file or 

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


More information about the Glasgow-haskell-users mailing list