Closed rjmk closed 7 years ago
Hm interesting! Two main reasons (as I see it) why this can be useful are: 1) a type might have contramap
but not map
so it cannot implement promap
2) it's annoying to pass x => x
to promap
when we want to use only contravariant map. Is this how you see it too? Do you have any examples of a type for #1
?
Is this how you see it too?
Yes. I also think it has pedagogical and conceptual advantages -- one can understand the concepts in their parts before their combination.
Do you have any examples of a type for
#1
?
I believe functions with a fixed codomain are contravariant. e.g.
newtype Predicate a = { getPredicate :: a -> Bool}
Yea, that a good example! One problem though, I really don't want to go on a road where Static Land starts to diverse from Fantasy Land unless there are really good reasons. Would you consider to open same issue in FL repo?
Sure!
Would you be interested in a contravariant functor added to the spec?
It would have a method
contramap :: Contravariant f => (a -> b, f b) -> f a
. It would become a dependency toprofunctor
. The laws are pretty much the same as for functor, but with a flip on the functions in compositionHappy to make a PR for you to look over