[Haskell-cafe] Re: Can we come out of a monad?

Thomas Davie tom.davie at gmail.com
Wed Aug 11 08:52:13 EDT 2010

On 11 Aug 2010, at 12:39, Ertugrul Soeylemez wrote:

> Martijn van Steenbergen <martijn at van.steenbergen.nl> wrote:
>> On 8/2/10 7:09, Ertugrul Soeylemez wrote:
>>> Given the definition of a Haskell function, Haskell is a pure
>>> language.  The notion of a function in other languages is not:
>>>   int randomNumber();
>>> The result of this function is an integer.  You can't replace the
>>> function call by its result without changing the meaning of the
>>> program.
>> I'm not sure this is fair. It's perfectly okay to replace a call
>> "randomNumber()" by that method's *body* (1), which is what you argue
>> is okay in Haskell.
> This is not the same.  In Haskell you can replace the function call by
> its /result/, not its body.  You can always do that.  But the result of
> an IO-based random number generator is an IO computation, not a value.
> It's not source code either, and it's not a function body.  It's a
> computation, something abstract without a particular representation.

It's still rather papering over the cracks to call this pure though.  The IO based computation itself still has a result that you *can't* replace the IO based computation with.  The fact that it's evaluated by the runtime and not strictly in haskell may give us a warm fuzzy feeling inside, but it still means we have to watch out for a lot of things we don't normally have to in a "very pure"[1] computation.


[1] Bob's arbitrary definition 1 – very pure computations are ones which can be replaced with their result without changing the behavior of the program *even* if said result is computed in the runtime and not by the Haskel program.

More information about the Haskell-Cafe mailing list