"do" notation and ">>"
Wed, 24 Apr 2002 14:55:42 +0100
> > I don't believe that it will break many programs. How many programs
> > produce large *input independent* output, that is not already
> > literally in the source, in a caf with a long life-time?
> That sounds like a description of all the animation programs in Paul
> Hudak's School of Expression book and there's plenty more examples
> like that.
> [I haven't tested whether these programs do leak space with the
> modified compiler - my point is that there is a large class of
> programs with exactly the characteristics you describe.]
> Alastair Reid
> ps I think your CAF restriction is a bit of a red herring - Koen's
> modification to make his example leak in GHC (which GCs CAFs) shows
> that the leak happens as long as the relevant thunk isn't collected.
This whole discussion is a red herring. The Haskell report doesn't say
anything about sharing - it doesn't even mandate laziness (look in the
index - you won't find the term "lazy" :-). Different compilers will
behave differently, GHC in particular will probably share <expr2> in
f =3D do <expr1>
regardless of whether the translation uses >> or >>=3D, because GHC
implements full laziness (when -O is turned on).
So you might reasonably argue that Haskell should provide more control
over such things, and I might well agree. But there's no point in
discussing whether using >>=3D or >> in the translation of do-notation =
better: they're both equivalent as far as the current language
specification is concerned.