RE: "do" notation and ">>"
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 Koen's example f = do <expr1> <expr2> regardless of whether the translation uses >> or >>=, 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 >>= or >> in the translation of do-notation is better: they're both equivalent as far as the current language specification is concerned. Cheers, Simon
Simon Marlow wrote: | 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" :-). I was not suggesting that the Haskell'98 report should change or even give a warning -- I was giving a warning to compiler implementors, that this simple change might have disastrous effects. BTW, I remember a similar discussion along these lines on the Haskell mailing list that happened in 1997 I think, but I cannot find the archives. Another comment one can make here is the following: if Haskell does not care about sharing, why is the monomorphism restriction there? Regards, /Koen. -- Koen Claessen http://www.cs.chalmers.se/~koen Chalmers University, Gothenburg, Sweden.
participants (2)
-
Koen Claessen -
Simon Marlow