[Haskell-cafe] Execution order in IO

Heinrich Apfelmus apfelmus at quantentunnel.de
Thu Apr 16 10:54:10 UTC 2015


Jon Schneider wrote:
> 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 ?

You have to distinguish between *evaluation order*, which dictates how a 
Haskell expression is evaluated, and something I'd like to call 
*execution order*, which specifies how the IO monad works. The point is 
that the latter is very much independent of the former. Evaluating the 
expression `getLine :: IO String` and "executing" the expression 
`getLine :: IO String` are two entirely different things. I recommend 
the tutorial

   Simon Peyton Jones.
   "Tackling the awkward squad: monadic input/output,
   concurrency, exceptions, and foreign-language calls in Haskell"
http://research.microsoft.com/en-us/um/people/simonpj/papers/marktoberdorf/

for more on this.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



More information about the Haskell-Cafe mailing list