
Is there a way to run a Haskell module via ghci with a single command on the command-line? Note: I'm on Windows XP. If I have the module test.hs, I can type "test.hs" and that will load it into ghci. However, I need to then type "main" to run it, and then manually exit ghci. I would like to do all this in one step.

On 6 September 2010 17:42, Johann Bach
Is there a way to run a Haskell module via ghci with a single command on the command-line?
Note: I'm on Windows XP.
If I have the module test.hs, I can type "test.hs" and that will load it into ghci. However, I need to then type "main" to run it, and then manually exit ghci. I would like to do all this in one step.
Not sure if this will work in Windows, but you might be able to use runhaskell/runghc to run the script. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

2010/9/6 Ivan Lazar Miljenovic
On 6 September 2010 17:42, Johann Bach
wrote: Is there a way to run a Haskell module via ghci with a single command on the command-line?
Note: I'm on Windows XP.
If I have the module test.hs, I can type "test.hs" and that will load it into ghci. However, I need to then type "main" to run it, and then manually exit ghci. I would like to do all this in one step.
Not sure if this will work in Windows, but you might be able to use runhaskell/runghc to run the script.
Or ghc -e "main" test.hs Cheers, Thu

On Mon, Sep 6, 2010 at 12:51 AM, Vo Minh Thu
2010/9/6 Ivan Lazar Miljenovic
: On 6 September 2010 17:42, Johann Bach
wrote: Is there a way to run a Haskell module via ghci with a single command on the command-line?
Note: I'm on Windows XP.
If I have the module test.hs, I can type "test.hs" and that will load it into ghci. However, I need to then type "main" to run it, and then manually exit ghci. I would like to do all this in one step.
Not sure if this will work in Windows, but you might be able to use runhaskell/runghc to run the script.
Or ghc -e "main" test.hs
Cheers, Thu
This seems to work. Regarding runhaskell: the last time I tried it, it compiled the program, but I want to use the interpreter. I have a script-like application in which the code will be changing frequently and I want to run it and see the results quickly.

2010/9/6 Johann Bach
On Mon, Sep 6, 2010 at 12:51 AM, Vo Minh Thu
wrote: 2010/9/6 Ivan Lazar Miljenovic
: On 6 September 2010 17:42, Johann Bach
wrote: Is there a way to run a Haskell module via ghci with a single command on the command-line?
Note: I'm on Windows XP.
If I have the module test.hs, I can type "test.hs" and that will load it into ghci. However, I need to then type "main" to run it, and then manually exit ghci. I would like to do all this in one step.
Not sure if this will work in Windows, but you might be able to use runhaskell/runghc to run the script.
Or ghc -e "main" test.hs
Cheers, Thu
This seems to work.
Regarding runhaskell: the last time I tried it, it compiled the program, but I want to use the interpreter. I have a script-like application in which the code will be changing frequently and I want to run it and see the results quickly.
In this case, you might want to open it once in ghci and use the :r (for reload) each time you want to try a modification. This way, ghci will be quite quick to tell you any parse or type error. Cheers, Thu

On 6 September 2010 18:00, Johann Bach
Regarding runhaskell: the last time I tried it, it compiled the program, but I want to use the interpreter. I have a script-like application in which the code will be changing frequently and I want to run it and see the results quickly.
Unless on Windows it does something differently, that shouldn't happen: on *nix it just interprets the file and doesn't compile it. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 9/6/10 04:08 , Ivan Lazar Miljenovic wrote:
On 6 September 2010 18:00, Johann Bach
wrote: Regarding runhaskell: the last time I tried it, it compiled the program, but I want to use the interpreter. I have a script-like application in which the code will be changing frequently and I want to run it and see the results quickly.
Unless on Windows it does something differently, that shouldn't happen: on *nix it just interprets the file and doesn't compile it.
Even "interpreted" Haskell is actually compiled to bytecode first. This shouldn't be visible when invoked via runhaskell/runghc/ghc -e, though. - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyFXiAACgkQIn7hlCsL25V5gQCdFP2f5PovNlx25aa/ER1wVrtc +psAn1DpE5VFor2m3mmG6xc5atNlBaSf =doJA -----END PGP SIGNATURE-----
participants (4)
-
Brandon S Allbery KF8NH
-
Ivan Lazar Miljenovic
-
Johann Bach
-
Vo Minh Thu