
9 Jun
2009
9 Jun
'09
10:26 p.m.
loading the file that contains the above function into GHCi (version 6.8.3) gives the following error "The last statement in a 'do' construct must be an expression"
being a beginner, I'm at a loss at the cause of the error and how to fix it -- any suggestions?
thanks, george
No problem here too, ghc 6.8.2. Maybe seeing how things are when layout style is not used helps you see a possible layout problem. Maybe it doesn't, and you can just forget the example below :) module Main (main) where { getNums = putStrLn "Enter a number (zero to stop):" >> do { num <- readLn ; if num == 0 then return [] else do {rest <- getNums ; return (num:rest)} } ; main = getNums >>= putStrLn . show } Best, Maurício