ihatetoregister ihatetoregister - 1 month ago 18
Bash Question

Can Haskell be used to write shell scripts?

Is it possible to write shell scripts in Haskell and if so, how do you do it? Just changing the interpreter like so?

#!/bin/ghci

Answer

Using ghci will just load the module in GHCi. To run it as a script, use runhaskell or runghc:

#!/usr/bin/env runhaskell
main = putStrLn "Hello World!"
Comments