[Haskell-cafe] The essence of my monad confusion

Felipe Lessa felipe.lessa at gmail.com
Sat May 2 13:09:29 EDT 2009


On Sat, May 02, 2009 at 05:31:03PM +0100, Paul Keir wrote:
> An example immediately follows that quotation on the wiki:
>
> do text <- getLine
>    if null text
>      then putStrLn "You refuse to enter something?"
>      else putStrLn ("You entered " ++ text)

Then, how about

    getMyLine = getLine >>= \text ->
	        if null text then getMyLine else return m

Can you, using functors, decide to run 'getLine' again or not?

HTH,

--
Felipe.


More information about the Haskell-Cafe mailing list