monoidal-functors-0.2.0.0: Monoidal Functors Library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Functor.Invariant

Contents

Synopsis

Invariant

class Invariant f where Source #

A functor is Invariant if it is parametric in its type parameter a.

Laws

invmap id idid
invmap f2 f2' . invmap f1 f1'invmap (f2 . f1) (f1' . f2')

Minimal complete definition

Nothing

Methods

invmap :: (a -> a') -> (a' -> a) -> f a -> f a' Source #

Given two isomorphic functions f and g, map over the invariant parameter a.

Examples

Expand
>>> :t invmap @Identity (read @Bool) show
invmap @Identity (read @Bool) show :: Identity String -> Identity Bool
>>> invmap @Identity (read @Bool) show (Identity "True")
Identity True

default invmap :: Functor f => (a -> a') -> (a' -> a) -> f a -> f a' Source #

Instances

Instances details
Invariant ZipList Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> ZipList a -> ZipList a' Source #

Invariant Identity Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> Identity a -> Identity a' Source #

Invariant IO Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> IO a -> IO a' Source #

Invariant NonEmpty Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> NonEmpty a -> NonEmpty a' Source #

Invariant Maybe Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> Maybe a -> Maybe a' Source #

Invariant [] Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> [a] -> [a'] Source #

Invariant (Either e) Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> Either e a -> Either e a' Source #

Invariant ((,) x1) Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> (x1, a) -> (x1, a') Source #

Invariant ((,,) x1 x2) Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> (x1, x2, a) -> (x1, x2, a') Source #

(Functor f, Functor g) => Invariant (Product f g) Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> Product f g a -> Product f g a' Source #

(Functor f, Functor g) => Invariant (Sum f g) Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> Sum f g a -> Sum f g a' Source #

Invariant ((,,,) x1 x2 x3) Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> (x1, x2, x3, a) -> (x1, x2, x3, a') Source #

(Functor f, Functor g) => Invariant (Compose f g) Source # 
Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> a') -> (a' -> a) -> Compose f g a -> Compose f g a' Source #

invIso :: Invariant f => Iso (->) a a' -> Iso (->) (f a) (f a') Source #