-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Adjunctions -- -- Adjunctions @package adjunctions @version 0.3 module Data.Functor.Contravariant.DualAdjunction -- | An adjunction from Hask to Hask^op -- --
-- Hask (f a) b ~ Op a (g b) ---- --
-- rightAdjunct unit = id -- leftAdjunct counit = id --class (Contravariant f, Contravariant g) => DualAdjunction f g | f -> g, g -> f unitOp :: DualAdjunction f g => g (f a) -> a counitOp :: DualAdjunction f g => f (g a) -> a leftAdjunctOp :: DualAdjunction f g => (f a -> b) -> g b -> a rightAdjunctOp :: DualAdjunction f g => (g b -> a) -> f a -> b module Data.Functor.Contravariant.Adjunction -- | An adjunction from Hask^op to Hask -- --
-- Op (f a) b ~ Hask a (g b) ---- --
-- rightAdjunct unit = id -- leftAdjunct counit = id --class (Contravariant f, Contravariant g) => Adjunction f g | f -> g, g -> f unit :: Adjunction f g => a -> g (f a) counit :: Adjunction f g => a -> f (g a) leftAdjunct :: Adjunction f g => (b -> f a) -> a -> g b rightAdjunct :: Adjunction f g => (a -> g b) -> b -> f a -- | A representation of a contravariant functor data Representation f x Representation :: (forall a. (a -> x) -> f a) -> (forall a. f a -> (a -> x)) -> Representation f x rep :: Representation f x -> forall a. (a -> x) -> f a unrep :: Representation f x -> forall a. f a -> (a -> x) -- | Represent a contravariant functor that has a left adjoint repAdjunction :: Adjunction f g => Representation g (f ()) repFlippedAdjunction :: Adjunction f g => Representation f (g ()) instance Adjunction Predicate Predicate instance Adjunction (Op r) (Op r) module Data.Functor.Adjunction -- | An adjunction between Hask and Hask. -- --
-- rightAdjunct unit = id -- leftAdjunct counit = id --class (Functor f, Functor g) => Adjunction f g | f -> g, g -> f unit :: Adjunction f g => a -> g (f a) counit :: Adjunction f g => f (g a) -> a leftAdjunct :: Adjunction f g => (f a -> b) -> a -> g b rightAdjunct :: Adjunction f g => (a -> g b) -> f a -> b data Representation f x Representation :: (forall a. (x -> a) -> f a) -> (forall a. f a -> x -> a) -> Representation f x rep :: Representation f x -> forall a. (x -> a) -> f a unrep :: Representation f x -> forall a. f a -> x -> a repAdjunction :: Adjunction f g => Representation g (f ()) instance (Adjunction f g, DualAdjunction f' g') => Adjunction (Compose f' f) (Compose g g') instance (Adjunction f g, Adjunction f' g') => Adjunction (Compose f' f) (Compose g g') instance Adjunction w m => Adjunction (EnvT e w) (ReaderT e m) instance Adjunction f g => Adjunction (IdentityT f) (IdentityT g) instance Adjunction Identity Identity instance Adjunction ((,) e) ((->) e) module Control.Monad.Trans.Adjoint type Adjoint f g = AdjointT f g Identity runAdjoint :: Functor g => Adjoint f g a -> g (f a) adjoint :: Functor g => g (f a) -> Adjoint f g a newtype AdjointT f g m a AdjointT :: g (m (f a)) -> AdjointT f g m a runAdjointT :: AdjointT f g m a -> g (m (f a)) instance (Adjunction f g, Traversable f) => MonadTrans (AdjointT f g) instance (Adjunction f g, Monad m) => Monad (AdjointT f g m) instance (Adjunction f g, Monad m) => Applicative (AdjointT f g m) instance (Adjunction f g, Monad m) => Functor (AdjointT f g m) module Control.Comonad.Trans.Adjoint type Adjoint f g = AdjointT f g Identity runAdjoint :: Functor f => Adjoint f g a -> f (g a) adjoint :: Functor f => f (g a) -> Adjoint f g a newtype AdjointT f g w a AdjointT :: f (w (g a)) -> AdjointT f g w a runAdjointT :: AdjointT f g w a -> f (w (g a)) instance (Adjunction f g, Distributive g) => ComonadTrans (AdjointT f g) instance (Adjunction f g, Comonad m) => Comonad (AdjointT f g m) instance (Adjunction f g, Functor m) => Functor (AdjointT f g m) module Data.Functor.Zap newtype Zap f g Zap :: (forall a b c. (a -> b -> c) -> f a -> g b -> c) -> Zap f g zapWith :: Zap f g -> forall a b c. (a -> b -> c) -> f a -> g b -> c zap :: Zap f g -> f (a -> b) -> g a -> b flipZap :: Zap f g -> Zap g f zapAdjunction :: Adjunction f g => Zap g f composeZap :: Zap f g -> Zap h i -> Zap (Compose f h) (Compose g i) newtype Bizap p q Bizap :: (forall a b c d e. (a -> c -> e) -> (b -> d -> e) -> p a b -> q c d -> e) -> Bizap p q bizapWith :: Bizap p q -> forall a b c d e. (a -> c -> e) -> (b -> d -> e) -> p a b -> q c d -> e bizap :: Bizap p q -> p (a -> c) (b -> c) -> q a b -> c flipBizap :: Bizap p q -> Bizap q p bizapProductSum :: Bizap (,) Either -- | Use a contravariant adjunction to Hask^op to build a Comonad to -- Monad transformer. module Control.Monad.Contra type Contra f g = ContraT f g Identity runContra :: Contravariant g => Contra f g a -> g (f a) contra :: Contravariant g => g (f a) -> Contra f g a newtype ContraT f g w a ContraT :: g (w (f a)) -> ContraT f g w a runContraT :: ContraT f g w a -> g (w (f a)) instance (Adjunction f g, Comonad w) => Monad (ContraT f g w) instance (Adjunction f g, Comonad w) => Applicative (ContraT f g w) instance (Adjunction f g, Functor w) => Functor (ContraT f g w)