
Bulat Ziganshin wrote:
Hello Bertram,
Sunday, April 18, 2010, 12:11:05 AM, you wrote:
always a = -- let act = a >> act in act do _ <- a always a
hinting at the real problem: 'always' actually creates a long chain of actions instead of tying the knot.
can you explain it deeper? it's what i see: always definition is equivalent to
always a = do a always a
what's the same as
always a = a >> always a
This expands as always a = a >> always a = a >> a >> always a = a >> a >> a >> always a ... where each >> application is represented by a newly allocated object (or several, I have not looked at it in detail) on the heap. With always a = let act = a >> act in act there's only one >> application being allocated. The principle is the same as with repeat x = x : repeat x versus repeat x = let xs = x : xs in xs HTH, Bertram