[Haskell-beginners] <-

Brandon Allbery allbery.b at gmail.com
Sat Sep 1 18:06:14 CEST 2012


On Sat, Sep 1, 2012 at 10:42 AM, Patrick Redmond <plredmond at gmail.com>wrote:

> Interesting. Does that mean the lines following a "x <- getLine" are
> simply balled up into a function? What if there are multiple lines?
>

I'll insert the translation:


> main = do                           main =
>     fn <- getLine                     getLine >>= \fn ->
>     ln <- getLine                     getLine >>= \ln ->
>     putStr $ reverse ln               putStr (reverse ln) >>
>     putStr " "                        putStr " " >>
>     putStr $ reverse fn               putStr (reverse fn)


Which is just a single large expression.  "do" syntax is not magic, nor is
it some fundamentally different language.  It's just a convenient way to
write a certain repetitious pattern.

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120901/457438f9/attachment-0001.htm>


More information about the Beginners mailing list