Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in characterization of free theorem for functors #104

Open
dfoxfranke opened this issue Apr 19, 2019 · 0 comments
Open

Error in characterization of free theorem for functors #104

dfoxfranke opened this issue Apr 19, 2019 · 0 comments

Comments

@dfoxfranke
Copy link

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:

data F a = A a | B a

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant