-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Adjunctions -- -- Adjunctions @package adjunctions @version 0.4.0 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) -- | Use a contravariant adjunction to Hask^op to build a Comonad to -- Monad transformer. module Control.Monad.Contra.Adjoint type Adjoint f g = AdjointT f g Identity runAdjoint :: Contravariant g => Adjoint f g a -> g (f a) adjoint :: Contravariant g => g (f a) -> Adjoint f g a newtype AdjointT f g w a AdjointT :: g (w (f a)) -> AdjointT f g w a runAdjointT :: AdjointT f g w a -> g (w (f a)) instance (Adjunction f g, Comonad w) => Monad (AdjointT f g w) instance (Adjunction f g, Comonad w) => Applicative (AdjointT f g w) instance (Adjunction f g, Functor w) => Functor (AdjointT f g w) -- |
--   ContT r ~ AdjointT (Op r) (Op r)
--   
module Control.Monad.Contra.Cont type Cont r = ContT r Identity runCont :: Cont r a -> (a -> r) -> r cont :: ((a -> r) -> r) -> Cont r a newtype ContT r w a ContT :: (w (a -> r) -> r) -> ContT r w a runContT :: ContT r w a -> w (a -> r) -> r callCC :: Comonad w => ((a -> ContT r w b) -> ContT r w a) -> ContT r w a instance Comonad w => Monad (ContT r w) instance Comonad w => Applicative (ContT r w) instance Comonad w => FunctorApply (ContT r w) instance Functor w => Functor (ContT r w) 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.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.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) -- | The density comonad for a functor. aka the comonad cogenerated by a -- functor The ''density'' term dates back to Dubuc''s 1974 thesis. The -- term ''monad genererated by a functor'' dates back to 1972 in -- Street''s ''Formal Theory of Monads''. module Control.Comonad.Trans.Density data Density k a Density :: (k b -> a) -> k b -> Density k a -- | The natural isomorphism between a comonad w and the comonad generated -- by w (forwards). liftDensity :: Comonad w => w a -> Density w a densityToAdjunction :: Adjunction f g => Density f a -> f (g a) adjunctionToDensity :: Adjunction f g => f (g a) -> Density f a instance ComonadTrans Density instance Comonad (Density f) instance Functor (Density f) 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.Monad.Trans.Codensity newtype Codensity m a Codensity :: (forall b. (a -> m b) -> m b) -> Codensity m a runCodensity :: Codensity m a -> forall b. (a -> m b) -> m b lowerCodensity :: Monad m => Codensity m a -> m a codensityToAdjunction :: Adjunction f g => Codensity g a -> g (f a) adjunctionToCodensity :: Adjunction f g => g (f a) -> Codensity g a instance MonadTrans Codensity instance Monad (Codensity f) instance Applicative (Codensity f) instance FunctorApply (Codensity f) instance Functor (Codensity k) 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 dual adjunction from Hask^op to build a -- Monad to Comonad transformer. module Control.Comonad.Contra.Adjoint type Adjoint f g = AdjointT f g Identity runAdjoint :: Contravariant f => Adjoint f g a -> f (g a) adjoint :: Contravariant f => f (g a) -> Adjoint f g a newtype AdjointT f g m a AdjointT :: f (m (g a)) -> AdjointT f g m a runAdjointT :: AdjointT f g m a -> f (m (g a)) instance (DualAdjunction f g, Monad m) => Comonad (AdjointT f g m) instance (Contravariant f, Contravariant g, Monad m) => Functor (AdjointT f g m)