Version française
Home     About     Download     Resources     Contact us    
Browse thread
environment idiom
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michael Walter <michael.walter@g...>
Subject: Re: [Caml-list] environment idiom
On Mon, 13 Dec 2004 09:56:55 +0100 (CET), Thomas Fischbacher
<Thomas.Fischbacher@physik.uni-muenchen.de> wrote:
> On Sun, 12 Dec 2004, Michael Walter wrote:
> 
> > Again I believe we are talking about different kinds of "purity".
> > Thomas is obviously right in that the StateTransformer monad (modulo
> > unsafe conversions) is pure, you are obviously right in the
> > (different) point that _running_ an IO fragment has side effects.
> 
> The key issue is: by not doing I/O, but talking about plans how to do I/O,
> you go to a higher level of abstraction that allows you to do magic with
> such plans which you just plainly miss if you only know the imperative
> ways. It's just like everyone knows how to add (i.e. arithmetics), but
> once you learned to talk about properties of addition (i.e. algebra), you
> have a much richer point of view that allows you to do quite miraculous
> things.
Fully agreed.

> Of course, it's possible to just forget about all that and fall back to
> transliterating imperative code to IO monad code, but it is just as well
> possible to find the sum of all the numbers from 1 to 1000 using the
> following piece of Maple code:
> [...]
> One surely can do this, and many people work in such a way to solve
> such problems, as they are used to it, but considering the power that
> Maple offers you, this is nothing but gross abuse of the system.
> 
> It's just the same with Haskell and the IO monad.
Yeah exactly. That's also similar to what I was trying to say in
another post above -- idiomatic monadic I/O lends itself to
composition.

Cheers,
Michael