
What is confusing to me is the recursion on the let construct. Oh sry I may have misunderstood your question then.
You can think of defining 'forever' itself as a let construct. Starting
from the "simpler" implementation:
let forever a = a >> forever a
Now let's just give the rhs another name, again using 'let':
let forever a = (let a' = a >> forever a in a')
But we can see that a' is actually equal to (forever a), so we can replace
on in the rhs:
let forever a = (let a' = a >> a' in a')
There is no trickery, no getting away, this recursion is the same as what
you have thought of:)
On 24 December 2013 02:46, Eduardo Sato
On Tuesday, December 24, 2013, Clark Gaebel wrote:
forever :: Monad m => m a -> m b forever a = a >> forever a
Thanks for your response. This is actually how I would have implemented it.
What is confusing to me is the recursion on the let construct.
What is not clear to me is when we can "get away" with doing that kind of thing. I mentioned the "tying the knot article" because it, too, uses recursion on a let construct.
-- Eduardo Sato
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe