haskell-cafe@haskell.org
[Top] [All Lists]

RE: [Haskell-cafe] Explaining monads

Subject: RE: [Haskell-cafe] Explaining monads
From: "peterv"
Date: Mon, 13 Aug 2007 19:31:48 +0200
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
correct? 

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@xxxxxxxxxxx
[mailto:haskell-cafe-bounces@xxxxxxxxxxx] On Behalf Of Kim-Ee Yeoh
Sent: Monday, August 13, 2007 15:30
To: haskell-cafe@xxxxxxxxxxx
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 
disease.

-- 
View this message in context:
http://www.nabble.com/Explaining-monads-tf4244948.html#a12126170
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

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
11:03
 

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
11:03
 

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>