ekmett / lens

Lenses, Folds, and Traversals - Join us on web.libera.chat #haskell-lens
http://lens.github.io/
Other
2.03k stars 273 forks source link

Move `coerce` to `contravariant`? #271

Closed shachaf closed 11 years ago

shachaf commented 11 years ago

The main issue would probably be with lens 3.8's dependencies.

Taneb commented 11 years ago

I disagree with this: if this move happens, it would make sense for tagged to be moved to profunctors similarly, which would mean that profunctors would be forced to have a bifunctors dependency, which they have very little to do with at all.

ehird commented 11 years ago

(Well, "very little" is a bit of a stretch; Bifunctor models functors Hask x Hask -> Hask, whereas Profunctor models functors Hask^op x Hask -> Hask; they're both bifunctors from a CT point of view.)

shachaf commented 11 years ago

The idea is to move it somewhere other than lens, which is a huge dependency for a small function. contravariant seems like a good place for it since Gettable iw nothing more than Functor and Cntravariant.

Note: When I opened this issue, there was no Gettable class, just coerce :: (Functor f, Contravariant f) => f a -> f b. Now that Gettable is back, maybe the argument against it is slightly stronger -- but it still seems like the most reasonable place to me, class or not.

ekmett commented 11 years ago

I'm pretty negative about this. Taken to its logical extreme we should do the same for something similar for Reviewable, which would make you want to have one of profunctors or bifunctors depend on the other, and its an otherwise symmetric relationship.

shachaf commented 11 years ago

Reviewable (i.e. first argument is phantom, second is covariant) is much more special-purpose than "argument is phantom", though. The latter is a useful thing to talk about in various non-lens contexts, whereas I've never had much of a specific reason to parameterize on something which is the former.

ekmett commented 11 years ago

I'm going to close this as a rejected for now. Doing this causes lots of packaging headaches for little benefit.