[Haskell-cafe] executable scripts?

Donald Bruce Stewart dons at cse.unsw.edu.au
Fri Oct 22 20:39:34 EDT 2004


velman:
> One of the nice things about perl (for example) is that you can put
> together a script with #!/usr/local/perl (in bash for example) as the first
> line of a file and run it immediately.  I've used perl a lot this way with
> simple 'throw away' scripts to do special filtering on a file, or some
> other processing that I want to do one or a few times.  occasionally, a
> script like this will have a more permanant value to me, and I keep it
> around.
> 
> Is there some way to do something similar in with Haskell?   I've tried the
> most obvious (to me) test with Hugs and it doesn't work.
> 
> Surely there is a way to do this!

You can use the runghc command provided with ghc (in ghc/utils/runghc --
cvs only, I think):

        paprika$ cat t.hs
        #!/usr/local/bin/runghc
        main = putStrLn "haskell is fun"

        paprika$ chmod 700 t.hs

        paprika$ ./t.hs 
        haskell is fun

-- Don


More information about the Haskell-Cafe mailing list