On Sat, Jul 31, 2010 at 5:59 PM, michael rice <nowg...@yahoo.com> wrote:
>
> OK, in f, *length* already knows it's argument is a list.
>
> In g, *length* doesn't know what's inside the parens, extra evaluation there. 
> So g is already ahead before we get to what's inside the [] and ().

According to the types, we already know both are lists. The question
is, of course, what kind of list.

> But since both still have eval x to *thunk* : *thunk*,  g evaluates "to a 
> deeper level?"
>
> Michael
>

I think this question is being quite sneaky. The use of head and tail
is pretty much irrelevant. Try the pointfree versions:

f = length . (:[]) . head
g = length . tail

and see if that helps you see why f is lazier than g.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to