Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Invariant
class Invariant f where Source #
A functor is Invariant
if it is parametric in its type
parameter a
.
Laws
invmap
id
id
≡id
invmap
f2
f2'
.
invmap
f1
f1'
≡invmap
(f2
.
f1
) (f1'
.
f2'
)
Nothing
invmap :: (a -> a') -> (a' -> a) -> f a -> f a' Source #
Given two isomorphic functions f
and g
, map over the
invariant parameter a
.
Examples
>>>
:t invmap @Identity (read @Bool) show
invmap @Identity (read @Bool) show :: Identity String -> Identity Bool
>>>
invmap @Identity (read @Bool) show (Identity "True")
Identity True
Instances
Invariant ZipList Source # | |
Invariant Identity Source # | |
Invariant IO Source # | |
Invariant NonEmpty Source # | |
Invariant Maybe Source # | |
Invariant [] Source # | |
Defined in Data.Functor.Invariant | |
Invariant (Either e) Source # | |
Invariant ((,) x1) Source # | |
Defined in Data.Functor.Invariant | |
Invariant ((,,) x1 x2) Source # | |
Defined in Data.Functor.Invariant | |
(Functor f, Functor g) => Invariant (Product f g) Source # | |
(Functor f, Functor g) => Invariant (Sum f g) Source # | |
Invariant ((,,,) x1 x2 x3) Source # | |
Defined in Data.Functor.Invariant | |
(Functor f, Functor g) => Invariant (Compose f g) Source # | |