GHC command that allows running a Haskell program as a script, without having to compile it beforehand
runhaskell
is a command from the ghc haskell compiler that allows running a Haskell program as a script, without having to compile it beforehand.
Usage
To use it, create and mark executable your Haskell code (that defines main :: IO()
), with the shebang line prepended:
#!/usr/bin/env runhaskell
Then, when the script is executed, runhaskell
automatically compiles and runs the script. (The runhaskell
program strips the shebang line before compiling it).
Pitfalls
- May not be included with all Haskell implementations
- The script is compiled, with limited optimization, each time it is run, so performance is slower than a compiled Haskell program