-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Adjunctions -- -- Adjunctions @package adjunctions @version 3.2 -- |
--   Cont r ~ Contravariant.Adjoint (Op r) (Op r)
--   Conts r ~ Contravariant.AdjointT (Op r) (Op r)
--   ContsT r w m ~ Contravariant.AdjointT (Op (m r)) (Op (m r)) w
--   
module Control.Monad.Trans.Conts type Cont r = ContsT r Identity Identity cont :: ((a -> r) -> r) -> Cont r a runCont :: Cont r a -> (a -> r) -> r type Conts r w = ContsT r w Identity runConts :: Functor w => Conts r w a -> w (a -> r) -> r conts :: Functor w => (w (a -> r) -> r) -> Conts r w a newtype ContsT r w m a ContsT :: (w (a -> m r) -> m r) -> ContsT r w m a runContsT :: ContsT r w m a -> w (a -> m r) -> m r callCC :: Comonad w => ((a -> ContsT r w m b) -> ContsT r w m a) -> ContsT r w m a instance Comonad w => MonadTrans (ContsT r w) instance Comonad w => Monad (ContsT r w m) instance Comonad w => Applicative (ContsT r w m) instance Comonad w => Apply (ContsT r w m) instance Functor w => Functor (ContsT r w m) 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
--   
-- -- Any adjunction from Hask to Hask^op would indirectly -- permit unsafePerformIO, and therefore does not exist. class (Contravariant f, Representable g) => Adjunction f g | f -> g, g -> f where unit = leftAdjunct id counit = rightAdjunct id leftAdjunct f = contramap f . unit rightAdjunct f = contramap f . counit 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 -- | Represent a Contravariant functor that has a left adjoint contrarepAdjunction :: Adjunction f g => (a -> f ()) -> g a coindexAdjunction :: Adjunction f g => g a -> a -> f () instance Adjunction Predicate Predicate instance Adjunction (Op r) (Op r) -- | Uses a contravariant adjunction: -- -- f -| g : Hask^op -> Hask -- -- to build a Comonad to Monad transformer. Sadly, the dual -- construction, which builds a Comonad out of a Monad, is -- uninhabited, because any Adjunction of the form -- --
--   f -| g : Hask -> Hask^op
--   
-- -- would trivially admit unsafePerformIO. module Control.Monad.Trans.Contravariant.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) module Data.Functor.Adjunction -- | An adjunction between Hask and Hask. -- -- Minimal definition: both unit and counit or both -- leftAdjunct and rightAdjunct, subject to the constraints -- imposed by the default definitions that the following laws should -- hold. -- --
--   unit = leftAdjunct id
--   counit = rightAdjunct id
--   leftAdjunct f = fmap f . unit
--   rightAdjunct f = counit . fmap f
--   
-- -- Any implementation is required to ensure that leftAdjunct and -- rightAdjunct witness an isomorphism from Nat (f a, b) -- to Nat (a, g b) -- --
--   rightAdjunct unit = id
--   leftAdjunct counit = id 
--   
class (Functor f, Representable u) => Adjunction f u | f -> u, u -> f where unit = leftAdjunct id counit = rightAdjunct id leftAdjunct f = fmap f . unit rightAdjunct f = counit . fmap f unit :: Adjunction f u => a -> u (f a) counit :: Adjunction f u => f (u a) -> a leftAdjunct :: Adjunction f u => (f a -> b) -> a -> u b rightAdjunct :: Adjunction f u => (a -> u b) -> f a -> b -- | Every right adjoint is representable by its left adjoint applied to a -- unit element -- -- Use this definition and the primitives in Data.Functor.Representable -- to meet the requirements of the superclasses of Representable. tabulateAdjunction :: Adjunction f u => (f () -> b) -> u b indexAdjunction :: Adjunction f u => u b -> f a -> b zapWithAdjunction :: Adjunction f u => (a -> b -> c) -> u a -> f b -> c -- | A right adjoint functor admits an intrinsic notion of zipping zipR :: Adjunction f u => (u a, u b) -> u (a, b) -- | Every functor in Haskell permits unzipping unzipR :: Functor u => u (a, b) -> (u a, u b) -- | A left adjoint must be inhabited, or we can derive bottom. unabsurdL :: Adjunction f u => f Void -> Void absurdL :: Void -> f Void -- | And a left adjoint must be inhabited by exactly one element cozipL :: Adjunction f u => f (Either a b) -> Either (f a) (f b) -- | Every functor in Haskell permits uncozipping uncozipL :: Functor f => Either (f a) (f b) -> f (Either a b) extractL :: Adjunction f u => f a -> a duplicateL :: Adjunction f u => f a -> f (f a) splitL :: Adjunction f u => f a -> (a, f ()) unsplitL :: Functor f => a -> f () -> f a instance Adjunction f u => Adjunction (Free f) (Cofree u) instance (Adjunction f g, Adjunction f' g') => Adjunction (Coproduct f f') (Product g g') instance (Adjunction f g, Adjunction f' g') => Adjunction (Compose f' f) (Compose g g') instance Adjunction m w => Adjunction (WriterT s m) (TracedT s w) 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 w) => Comonad (AdjointT f g w) instance (Adjunction f g, Extend w) => Extend (AdjointT f g w) instance (Adjunction f g, Functor w) => Functor (AdjointT f g w) 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)