[Haskell-cafe] laziness

Matthew Brecknell haskell at brecknell.org
Sun Dec 10 01:53:22 EST 2006


Ranjan Bagchi:
> foo x (l,payload) = ((x:l), payload)
> (x,_) = foldr foo ([], Nothing) [1..]
> (take 10) x
> 
> Doesn't terminate, until the stack overflows

Try making the (l, payload) pattern match lazy:

foo x ~(l, payload) = (x:l, payload)



More information about the Haskell-Cafe mailing list