I have written a script in haskell named testscript with the following code:
#!/usr/bin/env runhaskell
main = putStrLn "hello"
After making the script executable, I can run it using ./testscript. However, when I try to load the script with ghci (ie with :l testscript), I get the error
target `testscript' is not a module name or a source file
If I rename testscript to testscript.hs, and try loading with ghci again, I get the error
testscript.hs:1:0: error: invalid preprocessing directive #!
phase `C pre-processor' failed (exitcode = 1)
If I remove the shebang line it works fine. However it is tedious to have to add a .hs extension to the script, remove the top line, then remove the .hs extension and add the shebang line every time I want to try the script in ghci (which is pretty common everytime I want to make a change to it). Is there an easier way to do this?
I'm using ghc version 7.0.3 under Mac OS X 10.6.8