Contravariant
public protocol Contravariant : Invariant
A Contravariant Functor is the dual of a Covariant Functor, usually referred to as just Functor. Whereas an intuition behind Covariant Functors is that they can be seen as containing or producing values, Contravariant Functors can be seen as consuming values.
-
Creates a new value transforming the type using the provided function, preserving the structure of the original type.
Declaration
Parameters
faValue to be transformed.
fTransforming function.
Return Value
The result of transforming the value type using the provided function, maintaining the structure of the original value.
-
imap(_:_:_:)Extension method -
contralift(_:)Extension methodGiven a function, provides a new function lifted to the context type implementing this instance of
Contravariant, but reversing the direction of the arrow.Declaration
Parameters
fFunction to be lifted.
Return Value
Function in the context implementing this instance.
Install in Dash
Contravariant Protocol Reference