class Contravariant :: (Type -> Type) -> Constraintclass Contravariant f  where

A Contravariant functor can be seen as a way of changing the input type of a consumer of input, in contrast to the standard covariant Functor that can be seen as a way of changing the output type of a producer of output.

Contravariant instances should satisfy the following laws:

  • Identity cmap id = id
  • Composition cmap f <<< cmap g = cmap (g <<< f)


  • cmap :: forall a b. (b -> a) -> f a -> f b



Operator alias for Data.Functor.Contravariant.cmap (left-associative / precedence 4)


cmapFlipped :: forall a b f. Contravariant f => f a -> (b -> a) -> f b

cmapFlipped is cmap with its arguments reversed.


Operator alias for Data.Functor.Contravariant.cmapFlipped (left-associative / precedence 4)


coerce :: forall f a b. Contravariant f => Functor f => f a -> f b


imapC :: forall f a b. Contravariant f => (a -> b) -> (b -> a) -> f a -> f b

As all Contravariant functors are also trivially Invariant, this function can be used as the imap implementation for any types that have an existing Contravariant instance.