(head . map f) xs = (f . head) xs
It works for every xs list when f is strict. Can anyone give me example, why with non-strict f it doesnt work?
(head . map f) xs = (f . head) xs
It works for every xs list when f is strict. Can anyone give me example, why with non-strict f it doesnt work?
Let's take the non-strict function f = const ()
, and xs = undefined
. In this case, we have
map f undefined = undefined
but
f undefined = ()
and so
(head . map f) undefined = head (map f undefined) = head undefined = undefined
but
(f . head) undefined = f (head undefined) = f undefined = ()
Q.E.D.