
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

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?
You should always be able to do something like this: #!/usr/bin/runfileAsHSFile "$@" module Main where import blah ---- runfileAsHSFile ---- #!/bin/sh # run a file by creating a virtual hs file (fifo file pipe) fileToRun=$1; shift; f=tempfile -s .hs mkfifo $f sed -e '1d' $fileToRun > $f & # remove the first shabeng line using sed.. runhaskell $f rm $f This is written from scratch but should work without much changes.. But there might be much better solutions. Marc Weber

On 7/25/06, mvanier
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?
This is already implemented and will be in GHC-6.6 when it's released. -- Friendly, Lemmih

Lemmih wrote:
On 7/25/06, mvanier
wrote: 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?
This is already implemented and will be in GHC-6.6 when it's released.
Awesome! Thanks. Mike
participants (3)
-
Lemmih
-
Marc Weber
-
mvanier