Invariant
public protocol Invariant
An Invariant Functor provides a type the ability to transform its value type into another type. An instance of Functor
or Contravariant
are Invariant Functors as well.
-
Transforms the value type using the functions provided.
The implementation of this function must obey the following laws:
imap(fa, id, id) == fa imap(imap(fa, f1, g1), f2, g2) == imap(fa, compose(f2, f1), compose(g2, g1))
Declaration
Parameters
fa
Value whose value type will be transformed.
f
Transforming function.
g
Transforming function.
Return Value
A new value in the same context as the original value, with the value type transformed.