Modulinos: Difference between revisions
Content deleted Content added
Fixed Haskell |
|||
Line 227: | Line 227: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
Haskell has scripted main, but |
Haskell has scripted main, but getting scripted main to work with compiled scripts is tricky. |
||
<lang sh>$ rm scriptedmain.hi |
|||
wonko:scriptedmain andrew$ ghc -o scriptedmain -main-is ScriptedMain scriptedmain.hs |
|||
wonko:scriptedmain andrew$ ./scriptedmain |
|||
Main: The meaning of life is 42 |
|||
wonko:scriptedmain andrew$ rm scriptedmain.o |
|||
wonko:scriptedmain andrew$ ghc -o test -main-is Test test.hs scriptedmain.hs |
|||
wonko:scriptedmain andrew$ ./test |
|||
Test: The meaning of life is 42</lang> |
|||
scriptedmain.sh |
scriptedmain.sh |
||
Line 233: | Line 242: | ||
<lang haskell>#!/usr/bin/env runhaskell |
<lang haskell>#!/usr/bin/env runhaskell |
||
-- Compile: |
|||
-- Haskell has scripted main, but not for compiled scripts. |
|||
-- |
|||
-- This is because the primary script must be a module Main, |
|||
-- rm scriptedmain.hi |
|||
-- creating a name conflict. |
|||
-- ghc -o scriptedmain -main-is ScriptedMain scriptedmain.hs |
|||
module ScriptedMain where |
module ScriptedMain where |
||
Line 248: | Line 258: | ||
<lang haskell>#!/usr/bin/env runhaskell |
<lang haskell>#!/usr/bin/env runhaskell |
||
-- Compile: |
|||
-- |
|||
-- rm scriptedmain.hi |
|||
-- ghc -o scriptedmain -main-is ScriptedMain scriptedmain.hs |
|||
-- rm scriptedmain.o |
|||
-- ghc -o test -main-is Test test.hs scriptedmain.hs |
|||
module Test where |
|||
import ScriptedMain hiding (main) |
import ScriptedMain hiding (main) |