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

Functor instance for MinLen breaks abstraction #82

Closed
snoyberg opened this issue Oct 13, 2015 · 3 comments
Closed

Functor instance for MinLen breaks abstraction #82

snoyberg opened this issue Oct 13, 2015 · 3 comments

Comments

@snoyberg
Copy link
Owner

Simple demonstration of the problem:

import Data.MinLen

len1 :: MinLen (Succ Zero) [()]
len1 = mlcons () (toMinLenZero [])

len0 :: MinLen (Succ Zero) [()]
len0 = fmap (drop 1) len1

main :: IO ()
main = print $ Data.MinLen.head len0

Results in:

Data.MonoTraversable.headEx: empty

I see no option but to release a new major version with the Functor instance removed. Slightly tweaked: we can make the Functor instance apply only to MinLen Zero.

Pinging @gregwebs, in case you have another idea.

@gregwebs
Copy link
Collaborator

Functor instance should act on what is inside the newtype, not the newtype itself

@snoyberg
Copy link
Owner Author

If we try to implement that, we'd have to change the kind of MinLen, and most likely lose support for monomorphic containers in the process. What you're describing is handled by the MonoFunctor instance right now.

@gregwebs
Copy link
Collaborator

Ok

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

2 participants