{- Running Interactive Programs with Haskell CSE 341 You should have a module with an action called "main" with type IO (). Type this on the command line to run the program: runhaskell Magic.hs For some reason, this uses a slightly different I/O library than the interpreter (at least on Linux and Mac). As a result, the program has a nicer input behavior for readLn that understands backspace, ^u, etc. Although you won't need to do this for CSE341, you can also produce an executable file. To produce an executable, the module needs to be called Main -- the file can be called something other than Main.hs however. ghc --make Magic.hs -o magicprogram 'magicprogram' will now be an executable file. This executable will still have the nicer input behavior that understands backspace and so on. But on the output side, Haskell won't flush the output buffer until it has a complete line of text. To get around this, import System.IO, and add this line after the putStr: hFlush stdout -} module Main where get_magic_number = do putStr "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")