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

ChunkedData: Why isn't every Applicative a Zip3, etc? #209

Open
ivanbakel opened this issue Jun 21, 2022 · 0 comments
Open

ChunkedData: Why isn't every Applicative a Zip3, etc? #209

ivanbakel opened this issue Jun 21, 2022 · 0 comments

Comments

@ivanbakel
Copy link

Thanks for maintaining the library!

I recently wrote an instance for Zip3 Maybe for a project, and I noticed that the type signatures suggest that every applicative functor could have a valid instance for Zip3 (and vice versa.) There's even a commented-out default implementation for unzip3 in the code that would allow for this instance:

instance Applicative f => Zip3 f where
  zipWith3 f a b c d = f <$> a <*> b <*> c <*> d
  unzip3 = fmap (\(x,_,_)->x) &&& fmap (\(_,x,_)->x) &&& fmap (\(_,_,x)->x)

I vaguely remember reading in the docs somewhere that this instance isn't defined in general because unzip3 would hold 3 references to the original functor value, but I think this could be avoided by using seq to kill some of the thunking. Does it not work that way? Is there another reason to not define this instance (and others for Zip4, etc.?) Would you take a PR that does this?

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