Skip to content

Instantly share code, notes, and snippets.

@mcandre
Created March 6, 2011 23:14
Show Gist options
  • Save mcandre/857856 to your computer and use it in GitHub Desktop.
Save mcandre/857856 to your computer and use it in GitHub Desktop.
$ cat scriptedmain.hs
#!/usr/bin/env runhaskell
module ScriptedMain where
meaningOfLife :: Int
meaningOfLife = 42
main :: IO ()
main = putStrLn $ "Main: The meaning of life is " ++ show meaningOfLife
$ cat test.hs
#!/usr/bin/env runhaskell
module Test where
import ScriptedMain hiding (main)
main :: IO ()
main = putStrLn $ "Test: The meaning of life is " ++ show meaningOfLife
$ ghc -o scriptedmain -main-is ScriptedMain scriptedmain.hs
$ ./scriptedmain
Main: The meaning of life is 42
$ ghc -o test -main-is Test test.hs scriptedmain.hs
compilation IS NOT required
compilation IS NOT required
ld: duplicate symbol _ZCMain_main_info in scriptedmain.o and test.o
collect2: ld returned 1 exit status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment