laziness in `length'
beroal at ukr.net
Tue Jun 15 17:33:22 EDT 2010
On 15.06.10 17:52, Denys Rtveliashvili wrote:
> Please could you explain which Nums are not strict? The ones I am
> aware about are all strict.
Any value of any type is not strict in Haskell.
> Also, why doesn't it require building the full thunk for non-strict
> Nums? Even if they are not strict, an addition requires both parts to
> be evaluated. This means the thunk will have to be pre-built, doesn't it?
Yes, 'print' and '+' force numbers to be evaluated, and numbers can be
evaluated earlier. But GHC does not deduce this without "-O".
This question is more suited for the haskell-cafe mailing list.
Unfortunately, I can not find an explanation in the wiki, though your
example perhaps is the simplest one.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Glasgow-haskell-users