[Haskell-cafe] forever function laziness
0slemi0 at gmail.com
Tue Dec 24 02:56:12 UTC 2013
>> 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 <eduardo.sato at gmail.com> wrote:
> 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
> 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 at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe