Hello there. I find it very nice to have an analog for Applicative for Contravariant functors. But it feels like something is missing; where are our nice Traversables?
It seems like there is room for a typeclass like this:
class Functor t => Contraversable t
where
{-# MINIMAL contraverse | consequence #-}
contraverse :: Decidable f => (a -> f b) -> t a -> f (t b)
consequence :: Decidable f => t (f a) -> f (t b)
A simple application is to note that finite products (e.g. Vec n) are Contraversable. Thus the consequence of a container-ful of Predicates conditions :: Vec n (Predicate a) is consequence conditions :: Predicate (Vec n a), a predicate that gives the conjunction of the result of each predicate in conditions. Similarly, a finite productful of flipped folds can be consequenced to a flipped fold over the product. etc. etc.
Would you be open to a PR that adds this typeclass?
Hello there. I find it very nice to have an analog for
Applicative
forContravariant
functors. But it feels like something is missing; where are our niceTraversable
s?It seems like there is room for a typeclass like this:
A simple application is to note that finite products (e.g.
Vec n
) areContraversable
. Thus theconsequence
of a container-ful ofPredicate
sconditions :: Vec n (Predicate a)
isconsequence conditions :: Predicate (Vec n a)
, a predicate that gives the conjunction of the result of each predicate inconditions
. Similarly, a finite productful of flipped folds can beconsequence
d to a flipped fold over the product. etc. etc.Would you be open to a PR that adds this typeclass?