-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Functors, theirs compositions and transformations -- -- Attempt to define categorical abstractions in more robust and useful -- way. @package morphisms-functors @version 0.1.2 module Control.Functor.Contravariant -- |
-- When providing a new instance, you should ensure it satisfies the two laws: -- * Identity morphism: contramap identity ≡ identity -- * Composition of morphisms: contramap f . contramap g ≡ contramap (g . f) --class Contravariant (t :: * -> *) -- | Infix version of contramap (>$<) :: Contravariant t => (a -> b) -> t b -> t a -- | Prefix version of >$< contramap :: Contravariant t => (a -> b) -> t b -> t a -- | Replace all locations in the output with the same value (>$) :: Contravariant t => b -> t b -> t a -- | Flipped version of >$ ($<) :: Contravariant t => t b -> b -> t a -- | Fill the input of evaluation full :: Contravariant t => t () -> t a module Control.Functor.Covariant -- |
-- When providing a new instance, you should ensure it satisfies the two laws: -- * Identity morphism: comap identity ≡ identity -- * Composition of morphisms: comap (f . g) ≡ comap f . comap g --class Covariant (t :: * -> *) -- | Infix version of comap (<$>) :: Covariant t => (a -> b) -> t a -> t b -- | Prefix version of <$> comap :: Covariant t => (a -> b) -> t a -> t b -- | Replace all locations in the input with the same value (<$) :: Covariant t => a -> t b -> t a -- | Flipped version of <$ ($>) :: Covariant t => t a -> b -> t b -- | Discards the result of evaluation void :: Covariant t => t a -> t () module Control.Functor.Composition type (:.:) t u a = (Covariant t, Covariant u) => t (u a) type (:.%) t u a = (Covariant t, Contravariant u) => t (u a) type (%.:) t u a = (Contravariant t, Covariant u) => t (u a) type (%.%) t u a = (Contravariant t, Contravariant u) => t (u a) module Control.Functor.Composition.Extendable -- |
-- When providing a new instance, you should ensure it satisfies the three laws: -- * Duplication interchange: comap (comap f) . duplicate ≡ duplicate . comap f -- * Extension interchange: extend f ≡ comap f . duplicate --class Covariant t => Extendable t -- | Infix and flipped version of extend, the dual of -- >>= (=>>) :: Extendable t => t a -> (t a -> b) -> t b -- | Flipped version of >>=, the dual of =<< (<<=) :: Extendable t => (t a -> b) -> t a -> t b -- | Prefix and flipped version of =>>, the dual of -- bind extend :: Extendable t => (t a -> b) -> t a -> t b -- | Clone existing structure, the dual of join duplicate :: Extendable t => t a -> (t :.: t) a module Control.Functor.Composition.Distributive -- |
-- Let f :: Distributive g => (a -> g b) ---- --
-- When providing a new instance, you should ensure it satisfies the two laws: -- * Identity morphism: distribute . distribute ≡ identity -- * Interchange collection: collect f ≡ distribute . comap f --class Covariant u => Distributive u -- | Infix version of collect (>>-) :: (Distributive u, Covariant t) => t a -> (a -> u b) -> (u :.: t) b -- | Prefix version of >>- collect :: (Distributive u, Covariant t) => (a -> u b) -> t a -> (u :.: t) b -- | The dual of sequence distribute :: (Distributive u, Covariant t) => (t :.: u) a -> (u :.: t) a module Control.Functor.Composition.Bindable -- |
-- When providing a new instance, you should ensure it satisfies the one law: -- * Interchange: t >>= f = join (f <$> t) --class Covariant t => Bindable t -- | Infix and flipped version of bind, the dual of -- =>> (>>=) :: Bindable t => t a -> (a -> t b) -> t b -- | Flipped version of >>=, the dual of <<= (=<<) :: Bindable t => (a -> t b) -> t a -> t b -- | Prefix and flipped version of >>=, the dual of -- extend bind :: Bindable t => (a -> t b) -> t a -> t b -- | Merge effects/contexts, the dual of duplicate join :: Bindable t => (t :.: t) a -> t a module Control.Functor.Composition.Adjoint -- |
-- When providing a new instance, you should ensure it satisfies the four laws: -- * Left adjunction identity: phi counit ≡ identity -- * Right adjunction identity: psi unit ≡ identity -- * Left adjunction interchange: phi f ≡ comap f . eta -- * Right adjunction interchange: psi f ≡ epsilon . comap f --class (Covariant t, Covariant u) => Adjoint t u | t -> u, u -> t -- | Left adjunction phi :: Adjoint t u => (t a -> b) -> a -> u b -- | Right adjunction psi :: Adjoint t u => (a -> u b) -> t a -> b eta :: Adjoint t u => a -> (u :.: t) a epsilon :: Adjoint t u => (t :.: u) a -> a type -| = Adjoint module Control.Functor.Applicative -- |
-- When providing a new instance, you should ensure it satisfies the three laws: -- * Composition: (.) <$> u <*> v <*> w ≡ u <*> (v <*> w) -- * Left interchange: x <*> (f <$> y) ≡ (. f) <$> x <*> y -- * Right interchange: f <$> (x <*> y) ≡ (f .) <$> x <*> y --class Covariant t => Applicative t -- | Infix version of apply (<*>) :: Applicative t => t (a -> b) -> t a -> t b -- | Prefix version of <*> apply :: Applicative t => t (a -> b) -> t a -> t b -- | Sequence actions, discarding the value of the first argument (*>) :: Applicative t => t a -> t b -> t b -- | Sequence actions, discarding the value of the second argument (<*) :: Applicative t => t a -> t b -> t a -- | Repeat an action indefinitely forever :: Applicative t => t a -> t b module Control.Functor.Alternative -- |
-- When providing a new instance, you should ensure it satisfies the two laws: -- * Associativity of <+>: (x <+> y) <+> z ≡ x <+> (y <+> z) -- * Left-distributes <$> over <+>: f <$> (x <+> y) ≡ (f <$> x) <+> (f <$> y) --class Covariant t => Alternative t -- | Infix version of alter (<+>) :: Alternative t => t a -> t a -> t a -- | Prefix version of <+> alter :: Alternative t => t a -> t a -> t a module Control.Functor.Exclusive class Alternative t => Exclusive t exclusive :: Exclusive t => t a module Control.Functor.Extractable class Extractable (t :: * -> *) extract :: Extractable t => t a -> a module Control.Functor.Composition.Comonad -- |
-- Let f :: (Pointable t, Bindable t) => t a -> b -- Let g :: (Pointable t, Bindable t) => t a -> b ---- --
-- When using this constraint, you should ensure it satisfies the three laws: -- * Left identity: extend extract ≡ identity -- * Right identity: extract . extend f ≡ f -- * Associativity: extend f . extend g ≡ extend (f . extend g) --type Comonad t = (Extractable t, Extendable t) module Control.Functor.Invariant -- |
-- When providing a new instance, you should ensure it satisfies the two laws: -- Identity morphisms: invmap identity identity = identity -- Composition of morphisms: invmap g j . invmap f h = invmap (g . f) (h . j) --class Invariant (t :: * -> *) -- | Infix version of invmap (<$<) :: Invariant t => (a -> b) -> (b -> a) -> t a -> t b -- | Prefix version of <$< invmap :: Invariant t => (a -> b) -> (b -> a) -> t a -> t b -- | Flipped version of <$< (>$>) :: Invariant t => (b -> a) -> (a -> b) -> t a -> t b module Control.Functor.Pointable class Pointable (t :: * -> *) point :: Pointable t => a -> t a module Control.Functor.Composition.Traversable -- |
-- Let f :: (Applicative t, Applicative g) => t a -> u a -- Let p :: (Pointable t, Pointable g) => t a -> u a ---- --
-- When providing a new instance, you should ensure it satisfies the four laws: -- * Naturality of traversing: g . traverse f ≡ traverse (g . f) -- * Naturality of sequencing: f . sequence = sequence . comap f -- * Preserving point: p (point x) ≡ point x -- * Preserving apply: f (x <*> y) ≡ f x <*> f y --class Covariant t => Traversable t -- | Infix version of traverse (->>) :: (Traversable t, Pointable u, Applicative u) => t a -> (a -> u b) -> (u :.: t) b -- | Prefix version of ->> traverse :: (Traversable t, Pointable u, Applicative u) => (a -> u b) -> t a -> (u :.: t) b -- | The dual of distribute sequence :: (Traversable t, Pointable u, Applicative u) => (t :.: u) a -> (u :.: t) a module Control.Functor.Composition.Monad -- |
-- Let f :: (Pointable t, Bindable t) => a -> t a -- Let g :: (Pointable t, Bindable t) => a -> t a -- Let h :: (Pointable t, Bindable t) => t a ---- --
-- When using this constraint, you should ensure it satisfies the three laws: -- * Left identity: point a >>= f ≡ f a -- * Right identity: h >>= point ≡ h -- * Associativity: h >>= (\x -> f x >>= g) ≡ (h >>= f) >>= g --type Monad t = (Pointable t, Bindable t) module Control.Transformation.Natural type Natural t u = forall a. (Covariant t, Covariant u) => t a -> u a type (~>) t u = Natural t u