[Haskell-beginners] Re: the role of assignments
edgar klerks
edgar.klerks at gmail.com
Fri Jul 2 07:33:44 EDT 2010
He Prad,
do line <- getLine
putStr "You entered: "
putStrLn line
The example of Ertugrul is desugared to the following:
getLine >>= \x -> putStr "You entered: " >> putStrLn x
or even:
getLine >>= \x -> putStr "You entered: " >>= (\_ -> putStrLn x)
It helps a lot to not use the sugared syntax, until you know how to write
them without the sugar. That way you will grasp the concept of monads much
faster.
it is also a matter of taste, for small monadic functions I prefer the
desugared style. For longer it becomes a bit unwieldy.
Greetings,
Edgar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100702/fb25b04e/attachment.html
More information about the Beginners
mailing list