[Haskell-cafe] Monad explanation
Tim Newsham
newsham at lava.net
Fri Feb 6 13:34:17 EST 2009
> So if IO represents a program that when executed interacts with the world's
> state, is it safe to say that when I return (State Int Int), that I'm
> returning a "State program"? That'd make sense as it really does look like
> we force the State to be evaluated with runState, evalState or execState.
Yes, exactly.
> The only difference with IO then is that to get IO programs to run, you have
> to do it inside another IO program.
Almost. Add to your mental model a "runIO" that is invoked when your
program runs as: "runIO main". Your haskell compiler or interpretter
arranges this for you as part of its contract with you.
> I hope I'm not making this worse! :-)
I dont think so.
Tim Newsham
http://www.thenewsh.com/~newsham/
More information about the Haskell-Cafe
mailing list