You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chapter 6 in the section "Polymorphism" claims that it is impossible to write a function of type (a -> b) -> f a -> f b that doesn't satisfy forall f g. fmap f . fmap g = fmap (f . g). But this is false:
dataFa=Aa | Ba
bad_fmap f (A x) =B (f x)
bad_fmap f (B x) =A (f x)
A result you do get from the free theorem for fmap is that fmap id = id <==> forall f g. fmap f . fmap g = fmap (f . g); that is, if your fmap satisfies one of the two functors laws then it necessarily satisfies the other one too. The above example satisfies neither.
The text was updated successfully, but these errors were encountered:
Chapter 6 in the section "Polymorphism" claims that it is impossible to write a function of type
(a -> b) -> f a -> f b
that doesn't satisfyforall f g. fmap f . fmap g = fmap (f . g)
. But this is false:A result you do get from the free theorem for
fmap
is thatfmap id = id <==> forall f g. fmap f . fmap g = fmap (f . g)
; that is, if yourfmap
satisfies one of the two functors laws then it necessarily satisfies the other one too. The above example satisfies neither.The text was updated successfully, but these errors were encountered: