[Haskell] Lazy IO breaks purity
Jonathan Cast
jonathanccast at fastmail.fm
Wed Mar 4 21:27:43 EST 2009
On Wed, 2009-03-04 at 18:22 -0800, Jonathan Cast wrote:
> On Wed, 2009-03-04 at 18:12 -0800, oleg at okmij.org wrote:
> >
> > We demonstrate how lazy IO breaks referential transparency. A pure
> > function of the type Int->Int->Int gives different integers depending
> > on the order of evaluation of its arguments. Our Haskell98 code uses
> > nothing but the standard input. We conclude that extolling the purity
> > of Haskell and advertising lazy IO is inconsistent.
> ...
> > Running the code with Hugs exhibits the same behavior. Thus a pure
> > function (-) of the pure type gives different results depending on the
> > order of evaluating its arguments.
> >
> > Is 1 = -1?
>
> Lazy IO *as implemented (originally) in GHC* (and copied into the
> Haskell standard) breaks referential transparency.[1] Clean's object IO
> system, I believe, would not have this problem. Nor would a
> well-designed Haskell IO system.
jcc
[1] Oops, ignore this reference. I decided against saying what I was
going to here.
More information about the Haskell
mailing list