[Haskell-cafe] Alternative name for return

Jerzy Karczmarczuk jerzy.karczmarczuk at unicaen.fr
Tue Aug 6 16:26:05 CEST 2013


Le 06/08/2013 14:47, Jake McArthur a écrit :
> ... But IO actions *are* pure values. What side effects do they have? 
> None! /You can do whatever you want with them/ with no harmful effects 
> in any Haskell expression. They only special thing about them is that 
> they have a run function

As I said,  --
*Now Is The Time*  --
[[choose your reference of this Original Expression; perhaps the albums 
of Alanis Morissette or that of Jeff Lorber...]]

... to discuss the Purity. Go ahead and good luck.

Unfortunately I belong to a Cretacean generation, for whom the 
Referential Transparency means something, so I don't believe you, Jake.  
I am not saying that you are wrong. I say that calling an action a pure 
/value/ is almost meaningless.

1. First, it is not true  that you can do with, say, (printStr "Ho!" ) 
whatever you want. In fact, you can do almost nothing with it. You can 
transport it "as such", and you can use it as the argument of (>>=).

2. This is the only way you can evaluate your "pure value", and because 
of the monadic chaining, you cannot do it twice, you cannot 
"re-evaluate" it. You know all this as well as I do, perhaps better. 
That's why the "purity" here is dubious (although, unless I am mistaken, 
all functional constructs are considered "pure" by Wadler...).

3. Brandon Albery is (in my eyes) right:
> what's impure about lifting 5 into Maybe or []? `pure` feels IO-targeted.

A list, such as (return 5) in the List/Nondet Monad may be treated as a 
normal data item. But a IO action, or a IoRef mutable reference -- not 
really, they are Magic. If you claim that Magic is Pure, I abandon the 
ring. For me the Magical entities (i.e., the entities which are 
controlled by some layers UNDER the one YOU control) are impure, since 
there is no operational definition of purity for them. "No side 
effects"? Sure, if you don't do anything with it. Even the most horrible 
Devil is pure. Unless you call it...


Jerzy Karczmarczuk


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130806/30d900ac/attachment.htm>


More information about the Haskell-Cafe mailing list