
The problem here is that, within the `while' you are calling `isEOF' before printing the prompt. IsEOF cannot report False until you actually type the first character! If you type nothing, then it the EOF condition could indeed be true, so no more actions can happen until the condition is falsified.
processline = do putStr "prompt: " line <- getLine putStrLn ("Read: " ++ line)
while :: Monad m => m Bool -> m a -> m () while t s = do b <- t if(b) then do { s; while t s; return () } else do { return () }
main = do hSetBuffering stdout NoBuffering putStrLn "Single call:" processline putStrLn "Call from 'while' construct:" while (notM isEOF) (processline)
Regards, Malcolm