1
(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?

Cactus
  • 27,075
  • 9
  • 69
  • 149
beja
  • 29
  • 2

1 Answers1

4

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.

Cactus
  • 27,075
  • 9
  • 69
  • 149