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