[Haskell-cafe] Re: Explaining monads

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Mon Aug 13 17:13:01 EDT 2007


On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote:

> Let's take the simplest example: Maybe. The effect in question is the
> premature abortion of a computation (when Nothing is returned). And of
> course Maybe sequences these effects, that's what you use it for: the
> _first_ action to be encountered that returns Nothing aborts the
> computation. Clearly sequencing goes on here.

Clearly it does, but not as a side effect of the *monad*.  It's  
ordinary Haskell data dependencies at work here, not some mystical  
behavior of a monad.

> What about State? The effect is reading/writing the state. Again,  
> the State
> Monad takes care that these effects get sequenced, and again that's  
> what
> you expect it to do for you.

No, I expect it to carry a value around for me.  If I carry that  
value around myself instead of relying on the monad to do it for me,  
*the calculation still gets sequenced by the data dependencies*.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list