<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:±¼¸²
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>I really appeciate your answer.<BR> <BR>Thanks Again,<BR>Myung<br> <BR><div>> Date: Mon, 20 Apr 2015 02:51:33 +0300<br>> From: rasen.dubi@gmail.com<br>> To: beginners@haskell.org<br>> Subject: Re: [Haskell-beginners] What's the mean of >>=<br>> <br>> Hello!<br>> <br>> >>= and >> are methods of Monad typeclass. Their meaning may be very different depending on the actual type. For IO >>= composes a new IO action which is, when executed, executes left action first and then passes its result to the right function.<br>> <br>> So you can read<br>> putStr' xs >>= \ x -> putChar '\n'<br>> as "Execute action putStr' xs, then pass its result to \x -> putChar '\n'".<br>> <br>> Many times the result of previous action is not used (as in above<br>> example), so there is >> which is like >>= but ignores the result of<br>> first action.<br>> It's something like<br>> x >> y = x >>= (\_ -> y)<br>> <br>> So putStr' xs >> putChar '\n' is the same as putStr' xs >>= \ x -> putChar '\n'<br>> <br>> This code can be rewritten in the do-notation as:<br>> do<br>> putStr' xs<br>> putChar '\n'<br>> <br>> To summarize, for IO, >>= and >> are used to sequence actions.<br>> <br>> Best regards,<br>> Alexey Shmalko<br>> <br>> On Mon, Apr 20, 2015 at 2:33 AM, ±è¸í½Å <himskim@msn.com> wrote:<br>> > It could be stupid question because i'm very beginner of haskell.<br>> ><br>> > I found strange literals when i read haskell code.<br>> > Does anybody explan what the mean of >>= below ocode ? And additionally,<br>> > What is mean of >> itself?<br>> ><br>> > putStrLn' [] = putChar '\n'<br>> > putStrLn' xs - putStr' xs >>= \ x -> putChar '\n'<br>> ><br>> > putStr' [] = return ()<br>> > putStr' (x : xs) = putChar x >> putStr' n<br>> ><br>> > (because of i18n problem, back slash literal could be shown as '\')<br>> ><br>> > Thank you in advance<br>> > Myung Shin Kim<br>> ><br>> ><br>> > _______________________________________________<br>> > Beginners mailing list<br>> > Beginners@haskell.org<br>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners<br>> ><br>> _______________________________________________<br>> Beginners mailing list<br>> Beginners@haskell.org<br>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners<br></div> </div></body>
</html>