[Haskell-cafe] scripting in haskell

mvanier mvanier at cs.caltech.edu
Tue Jul 25 17:00:20 EDT 2006


Hi,

I was playing around with runhaskell (runghc to be precise), and I discovered 
the limitation wherein you have to use the file suffix ".hs".  Don't get me 
wrong, runhaskell is great, but if you didn't have that restriction it would 
make haskell much more attractive to many programmers who write standalone scripts.

Of course it's always possible to do e.g.

(file: hello)
#! /bin/sh
runhaskell Hello.hs

(file: Hello.hs)
module Main where
main :: IO ()
main = putStrLn "hello, world!"

but that's pretty inconvenient.  What I'd like is:

(file: hello)
#! /usr/bin/env runhaskell
module Main where
main :: IO ()
main = putStrLn "hello, world!"

which is _almost_ doable; you have to name the file "hello.hs".  What would 
really be optimal is something like

(file: hello)
#! /usr/bin/env runhaskell
-fglasgow-exts  -- extra arguments to runhaskell
!#

module Main where
main :: IO ()
main = putStrLn "hello, world!"

Looking through the mailing list I see something from May 2005 on this topic 
about adding the equivalent of gcc's "-x" option to ghc.  What's the status of that?

Cheers,

Mike



More information about the Haskell-Cafe mailing list