(head . map f) xs = (f . head) xs
当f严格时,它适用于每个xs列表。 任何人都可以举例说明,为什么非严格的f它不起作用?
答案 0 :(得分:4)
我们选择非严格函数f = const ()
和xs = undefined
。在这种情况下,我们有
map f undefined = undefined
但
f undefined = ()
等等
(head . map f) undefined = head (map f undefined) = head undefined = undefined
但
(f . head) undefined = f (head undefined) = f undefined = ()
Q.E.D。