{- Producing Executable Files with Haskell CSE 341, Winter 2009 To produce an executable file, you need to have a module called "Main" with a function called "main" with type IO (). (The file can be called something other than Main.hs however.) Then at the command line do this: ghc --make Magic.hs -o magicprogram 'magicprogram' will now be an executable file. -} module Main where import IO get_magic_number = do {- for some reason you need to have a newline at the end of the end of the string being printed, or in the compiled version Haskell won't output it -} putStrLn "Please enter a magic number: " n <- readLn if mod n 2 == 0 then do putStrLn "Sorry, even numbers are not magic ..." get_magic_number else return n main = do n <- get_magic_number putStrLn ("The magic number is ... " ++ show n ++ "\n\n")