[Haskell-cafe] Explaining monads

peterv bf3 at telenet.be
Mon Aug 13 13:31:48 EDT 2007

When I read "side-effects", I understand it as "unwanted effects", like
"aliasing", and "effects depending on the order of execution". I'm not sure
if my understanding here is correct. I hope Haskell does not allow
"side-effects" but only "effects", meaning the monads do not allow you to
write the typical ill-behaving code you get when doing real imperative
programming, enforcing a single wiring of execution, not allowing the
capture of the RealWorld object. In Concurrent Clean special compiler
support is present to enforce "uniqueness typing", and in Haskell special
compiler support is available to make the RealWorld object not available at
runtime (so e.g. you can't put the RealWorld object in a list). Is this

BTW: What is the correct word in Haskell for "object"? I mean the (lazy)
value you get when evaluating a data constructor? 

-----Original Message-----
From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Kim-Ee Yeoh
Sent: Monday, August 13, 2007 15:30
To: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] Explaining monads

Ronald Guida wrote:
> Given the question "What is a Monad", I would have to say "A Monad is
> a device for sequencing side-effects."

There are side-effects and there are side-effects. If the only
monad you use is Maybe, the only side-effect you get is a slight
warming of the CPU.

Dave Menendez pointed to that fine Wadler link earlier. Please read
it. To wit, in Section 2: "Explaining Monads" the "essence of an
algorithm can become buried under the plumbing required to carry
data from its point of creation to its point of use." Monads can
help keep the clarity of your code untrammelled by providing
implicit plumbing, "side-channels" if you prefer, when data is
moved around.

In fact if you follow Wadler all the way to his monadic expression
evaluator, you see that you could modularize your code in awesomely
cool ways. You get to see how the kernel of the expression
evaluator could be written for a generic monad and compiled
once-and-for-all. Any additional feature (the "variations") is
coded by enriching the monad.

Monads are powerful devices for modularizing code. Available for
free. Only in Haskell (thanks to type classes!). Get them today.

"Side-effects" is a piece of linguistic cruft played fast-and-loose
by too many people in this game. "Sequencing" suffers the same 

View this message in context:
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

Haskell-Cafe mailing list
Haskell-Cafe at haskell.org

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 12/08/2007

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 12/08/2007

More information about the Haskell-Cafe mailing list