[Haskell] Simple question about IO in hugs and ghc

Vivian McPhail vivian.mcphail at paradise.net.nz
Sun Sep 26 07:39:15 EDT 2004


When I run my main function I get an error:

The prompt does not wait for user input and thus my parser fails with an empty head.

Is there a switch to not echo to the console?  Is this the problem?  It happens in both Hugs and GHC

main :: IO ()
main = do 
       putStr "sentence? "
       input <- getLine
       case input of
            "quit" -> putStr "bye.\n"
            _      -> do 
                           let res = get_result $ proof $ do_proof $ getInput input
                                in if res == Nothing
                                   then putStr ("-> Nothing\n")
                                   else putStr ("-> " ++ (show $ unJust res) ++ "\n")


Sample output:
$ mmccg.exe

Fail:  Prelude.head: empty list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell/attachments/20040926/856747f0/attachment.htm

More information about the Haskell mailing list