
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! Thanks, John Velman

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

On Fri, 22 Oct 2004 16:05:29 -0700
John 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.
#!/usr/local/bin/runhugs will do the trick. See hugs(1). Haskell does really good job for me where perl had been used! -- Koji Nakahara

Thanks to all who answered! #!/usr/local/bin/runhugs does the trick. So much to read. Best, John Velman On Sat, Oct 23, 2004 at 03:38:18PM +0900, Koji Nakahara wrote:
On Fri, 22 Oct 2004 16:05:29 -0700 John Velman
wrote: 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.
#!/usr/local/bin/runhugs will do the trick. See hugs(1).
Haskell does really good job for me where perl had been used!
-- Koji Nakahara _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

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!
I've been using an interpreter script I wrote which just uses ghc to create an executable in /tmp, and then runs it. It compares modification times, so if your script hasn't changed, it doesn't run ghc and there isn't much overhead. Thus it is faster than runghc in the common case. The thing is, it doesn't work very well. If your script depends on a module, and that module changes, then it doesn't know to recompile the script. I tried to get around this using "ghc --make", but unfortunately this isn't as fast as it could be in the common case (I think it could be as fast as "ghc -M", but isn't), and is therefore unsuitable for our application. I tried using "ghc -M", "make -q" and then "ghc --make", but it appears that "ghc -M" outputs dependencies on .hi files whose modification times aren't always updated by "ghc --make" when they are rebuilt, causing a stuck "out-of-date" condition which breaks the dependency analysis. Anyway, my interpreter script is here, but at least in part because I wasn't able to get around the above problems, it isn't very good: http://a5.repetae.net/~frederik/hs-interp e.g. $ cat test #!/usr/bin/env hs-interp main = do putStrLn "hello world" $ ./test hello world -- Frederik
participants (4)
-
dons@cse.unsw.edu.au
-
frederik@a5.repetae.net
-
John Velman
-
Koji Nakahara