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

Comments

Projects
None yet
2 participants
@snoyberg
Copy link
Owner

commented Oct 13, 2015

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

This comment has been minimized.

Copy link
Collaborator

commented Oct 13, 2015

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

@snoyberg

This comment has been minimized.

Copy link
Owner Author

commented Oct 13, 2015

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

This comment has been minimized.

Copy link
Collaborator

commented Oct 13, 2015

Ok

@snoyberg snoyberg closed this in d679ff2 Oct 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.