Modulinos: Difference between revisions

Content added Content deleted
(Simplified compilation process)
Line 229: Line 229:
Haskell has scripted main, but getting scripted main to work with compiled scripts is tricky.
Haskell has scripted main, but getting scripted main to work with compiled scripts is tricky.


<lang sh>$ rm scriptedmain.hi
<lang sh>$ runhaskell scriptedmain.hs
Main: The meaning of life is 42
$ ghc -o scriptedmain -main-is ScriptedMain scriptedmain.hs
$ runhaskell test.hs
Test: The meaning of life is 42
$ ghc -fforce-recomp -o scriptedmain -main-is ScriptedMain scriptedmain.hs
$ ./scriptedmain
$ ./scriptedmain
Main: The meaning of life is 42
Main: The meaning of life is 42
$ rm scriptedmain.o
$ ghc -fforce-recomp -o test -main-is Test test.hs scriptedmain.hs
$ ghc -o test -main-is Test test.hs scriptedmain.hs
$ ./test
$ ./test
Test: The meaning of life is 42</lang>
Test: The meaning of life is 42</lang>


scriptedmain.sh
scriptedmain.hs


<lang haskell>#!/usr/bin/env runhaskell
<lang haskell>#!/usr/bin/env runhaskell
Line 244: Line 246:
-- Compile:
-- Compile:
--
--
-- rm scriptedmain.hi
-- ghc -fforce-recomp -o scriptedmain -main-is ScriptedMain scriptedmain.hs
-- ghc -o scriptedmain -main-is ScriptedMain scriptedmain.hs


module ScriptedMain where
module ScriptedMain where
Line 261: Line 262:
-- Compile:
-- Compile:
--
--
-- rm scriptedmain.hi
-- ghc -fforce-recomp -o test -main-is Test test.hs scriptedmain.hs
-- ghc -o scriptedmain -main-is ScriptedMain scriptedmain.hs
-- rm scriptedmain.o
-- ghc -o test -main-is Test test.hs scriptedmain.hs


module Test where
module Test where