18 Aug 05:44
invoking a Haskell script without a .hs extension
From: Paul Jarc <prj <at> po.cwru.edu>
Subject: invoking a Haskell script without a .hs extension
Newsgroups: gmane.comp.lang.haskell.glasgow.user
Date: 2008-08-18 03:45:30 GMT
Subject: invoking a Haskell script without a .hs extension
Newsgroups: gmane.comp.lang.haskell.glasgow.user
Date: 2008-08-18 03:45:30 GMT
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? Second attempt: runhaskell -x hs notify This get me "Not in scope: `main'". runhaskell is invoking ghc with these arguments: -ignore-dot-ghci -x -e ':set prog "hs"' -e ':main ["notify"]' hs So it looks like runhaskell it treating "-x" as an argument to be relayed to ghc, "hs" as the name of the script, and "notify" as an argument to the script. I guess I need to use "--" to make it clear where the ghc arguments end and where the script and its arguments begin. Third attempt: runhaskell -- -x hs -- notify This gets me "Not in scope: `main'" again. runhaskell is invoking ghc with these arguments: -ignore-dot-ghci -x -e ':set prog "hs"' -e ':main ["--","notify"]' hs This looks like a bug in the "--" handling, unless I'm misinterpreting the usage message I get from running plain "runhaskell". Fourth attempt: ghc -ignore-dot-ghci -e ':set prog "notify"' \ -e ':main []' -x hs notify This works, but passing arguments becomes rather cumbersome. If there's a way to get runhaskell to pass "-x hs" in the right place, that would be much better.(Continue reading)
RSS Feed