adjunctions icon indicating copy to clipboard operation
adjunctions copied to clipboard

Remove cotraverse1 and distribute1 methods

Open treeowl opened this issue 4 years ago • 5 comments

  • The cotraverse and distribute1 methods were incompatible with GeneralizedNewtypeDeriving. Remove them, leaving collect1 and cotraverseMap1. Use GND to derive the Representable instance for Co, which bakes in a test that this remains possible.

  • Add an optimized version of cotraverseMap1Iso for the case where the isomorphism is a coercion. Also, require less polymorphism in one argument of cotraverseMap1Iso.

  • Add a MonadFix instance for Co.

  • Make the Functor instance for Co use the Representable instance.

  • Flesh out more class methods for Co (for example, <*, *>, and <$ admit particularly simple and efficient definitions).

Fixes #62

treeowl avatar Sep 05 '19 14:09 treeowl

@aaronvargo, I would appreciate your input on this. Also: I'm not totally convinced that we win anything by making collect1 a class method rather than just a function. Do you know of a case where we do? If not, I'd be very tempted to remove it for now.

treeowl avatar Sep 05 '19 14:09 treeowl

Please DO NOT SQUASH. I've broken this PR into one commit that creates Data.Functor.Rep.Internal and a separate one that actually makes substantive changes.

treeowl avatar Sep 05 '19 18:09 treeowl

What's the right way to fix things so git recognizes that first thing as a move? I don't want to get all the git blame for the whole module.

treeowl avatar Sep 05 '19 19:09 treeowl

One potentially controversial point: the new Functor instance for Co will be bad if the Representable instance doesn't define cotraverseMap1.

treeowl avatar Sep 13 '19 19:09 treeowl

(But I think that's okay; Co is presumably mostly for DerivingVia, and people are free not to use it if they don't want it.)

treeowl avatar Sep 13 '19 19:09 treeowl