<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div>Hi,<br><br></div>You can consider that:<br></div>type IO a = World -> (World, a)<br></div><div>Where World is the state of the impure world.<br></div><div><br></div>So when you have:<br></div><div>getLine :: IO String<br></div>putStrLn :: String -> IO ()<br><br></div>Is is in fact:<br></div><div>getLine :: World -> (World, String)<br></div>putStrLn :: String -> World -> (World, ())<br><br></div>You can compose IO actions with:<br></div>(>>=) :: IO a -> (a -> IO b) -> IO b<br></div><div>(>>=) :: (World -> (World,a)) -> (a -> World -> (World,b)) -> World -> (World,b)<br></div><div>(>>=) f g w = let (w2,a) = f w in g a w2<br><br></div><div>do-notation is just syntactic sugar for this operator.<br></div><div><br></div>So there is an implicit dependency between both IO functions: the state of the World (which obviously doesn't appear in the compiled code).<br></div></div><br></div>Sylvain<br><div><div><div><div><div><div><div><div><div><div><div><br></div></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-04-15 11:07 GMT+02:00 Jon Schneider <span dir="ltr"><<a href="mailto:haskell@jschneider.net" target="_blank">haskell@jschneider.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Good morning all,<br>
<br>
I think I've got the hang of the way state is carried and fancy operators<br>
work in monads but still have a major sticky issue.<br>
<br>
With lazy evaluation where is it written that if you write things with no<br>
dependencies with a "do" things will be done in order ? Or isn't it ?<br>
<br>
Is it a feature of the language we're supposed to accept ?<br>
<br>
Is it something in the implementation of IO ?<br>
<br>
Is the do keyword more than just a syntactic sugar for a string of binds<br>
and lambdas ?<br>
<br>
Jon<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>