invoking a Haskell script without a .hs extension

Bertram Felgenhauer bertram.felgenhauer at
Mon Aug 18 04:47:51 EDT 2008

Paul Jarc wrote:
> I have a Haskell script called "notify", without a .hs extension,
> which causes some problems.  (I'm using ghc 6.8.3.)
> First attempt: runhaskell notify
> Without the .hs extension, ghc doesn't know it's a Haskell script, and
> so I get "Could not find module `notify'".  Maybe runhaskell should
> automatically add "-x hs" to the ghc command?

The 6.9 branch version of runghc does that, actually. (runhaskell is
probably a symlink to runghc.)

> Second attempt: runhaskell -x hs notify

There's an undocumented runghc flag which I found by looking at the
source code, --ghc-arg, that can be used for this.

  runghc -x --ghc-arg=hs notify

should work.

runghc's handling of "--" is a little odd; it does stop parsing ghc args
when "--" is encountered, but it also stops at the first option that
doesn't start with a hyphen, even if a "--" follows later.



More information about the Glasgow-haskell-users mailing list