-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Adjunctions -- -- Adjunctions @package adjunctions @version 0.5.2 module Data.Functor.Composition -- | We often need to distinguish between various forms of Functor-like -- composition in Haskell in order to please the type system. This lets -- us work with these representations uniformly. class Composition compose decompose :: Composition compose => compose f g x -> f (g x) compose :: Composition compose => f (g x) -> compose f g x instance Composition Compose 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, 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) -- | 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) -- |
--   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.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, 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) -- | The densityT comonad for a functor. aka the comonad generated by a -- functor The ''densityT'' 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 DensityT k a DensityT :: (k b -> a) -> k b -> DensityT k a -- | The natural isomorphism between a comonad w and the comonad generated -- by w (forwards). liftDensityT :: Comonad w => w a -> DensityT w a densityTToAdjunction :: Adjunction f g => DensityT f a -> f (g a) adjunctionToDensityT :: Adjunction f g => f (g a) -> DensityT f a instance ComonadTrans DensityT instance Comonad (DensityT f) instance Extend (DensityT f) instance Functor (DensityT 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 CodensityT m a CodensityT :: (forall b. (a -> m b) -> m b) -> CodensityT m a runCodensityT :: CodensityT m a -> forall b. (a -> m b) -> m b lowerCodensityT :: Monad m => CodensityT m a -> m a codensityTToAdjunction :: Adjunction f g => CodensityT g a -> g (f a) adjunctionToCodensityT :: Adjunction f g => g (f a) -> CodensityT g a instance MonadTrans CodensityT instance Monad (CodensityT f) instance Applicative (CodensityT f) instance Apply (CodensityT f) instance Functor (CodensityT 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 module Data.Functor.Yoneda type Yoneda = YonedaT Identity yoneda :: (forall b. (a -> b) -> b) -> Yoneda a runYoneda :: Yoneda a -> (a -> b) -> b liftYoneda :: a -> Yoneda a lowerYoneda :: Yoneda a -> a newtype YonedaT f a YonedaT :: (forall b. (a -> b) -> f b) -> YonedaT f a runYonedaT :: YonedaT f a -> forall b. (a -> b) -> f b liftYonedaT :: Functor f => f a -> YonedaT f a lowerYonedaT :: YonedaT f a -> f a maxF :: (Functor f, Ord (f a)) => YonedaT f a -> YonedaT f a -> YonedaT f a minF :: (Functor f, Ord (f a)) => YonedaT f a -> YonedaT f a -> YonedaT f a maxM :: (Monad m, Ord (m a)) => YonedaT m a -> YonedaT m a -> YonedaT m a minM :: (Monad m, Ord (m a)) => YonedaT m a -> YonedaT m a -> YonedaT m a instance ComonadTrans YonedaT instance Comonad w => Comonad (YonedaT w) instance Extend w => Extend (YonedaT w) instance MonadTrans YonedaT instance MonadPlus m => MonadPlus (YonedaT m) instance MonadFix m => MonadFix (YonedaT m) instance Monad m => Monad (YonedaT m) instance Alternative f => Alternative (YonedaT f) instance Plus f => Plus (YonedaT f) instance Alt f => Alt (YonedaT f) instance Ord (f a) => Ord (YonedaT f a) instance Eq (f a) => Eq (YonedaT f a) instance (Functor f, Read (f a)) => Read (YonedaT f a) instance Show (f a) => Show (YonedaT f a) instance Adjunction f g => Adjunction (YonedaT f) (YonedaT g) instance Distributive f => Distributive (YonedaT f) instance Traversable f => Traversable (YonedaT f) instance Foldable f => Foldable (YonedaT f) instance Applicative f => Applicative (YonedaT f) instance Apply f => Apply (YonedaT f) instance Functor (YonedaT f) module Data.Functor.Yoneda.Contravariant type Yoneda = YonedaT Identity yoneda :: (b -> a) -> b -> Yoneda a liftYoneda :: a -> Yoneda a lowerYoneda :: Yoneda a -> a liftYonedaT :: f a -> YonedaT f a lowerYonedaT :: Functor f => YonedaT f a -> f a lowerM :: Monad f => YonedaT f a -> f a -- | The contravariant Yoneda lemma applied to a covariant functor data YonedaT f a YonedaT :: (b -> a) -> f b -> YonedaT f a instance Adjunction f g => Adjunction (YonedaT f) (YonedaT g) instance (Functor f, Ord (f a)) => Ord (YonedaT f a) instance (Functor f, Eq (f a)) => Eq (YonedaT f a) instance (Functor f, Read (f a)) => Read (YonedaT f a) instance (Functor f, Show (f a)) => Show (YonedaT f a) instance Distributive f => Distributive (YonedaT f) instance Traversable f => Traversable (YonedaT f) instance (Foldable f, Functor f) => Foldable (YonedaT f) instance ComonadTrans YonedaT instance Comonad w => Comonad (YonedaT w) instance Extend w => Extend (YonedaT w) instance MonadPlus f => MonadPlus (YonedaT f) instance MonadFix f => MonadFix (YonedaT f) instance MonadTrans YonedaT instance Monad m => Monad (YonedaT m) instance Plus f => Plus (YonedaT f) instance Alt f => Alt (YonedaT f) instance Alternative f => Alternative (YonedaT f) instance Applicative f => Applicative (YonedaT f) instance Functor (YonedaT f) module Data.Functor.KanExtension newtype Ran g h a Ran :: (forall b. (a -> g b) -> h b) -> Ran g h a runRan :: Ran g h a -> forall b. (a -> g b) -> h b -- | toRan and fromRan witness a higher kinded adjunction. -- from (`'Compose'` g) to Ran g toRan :: (Composition compose, Functor k) => (forall a. compose k g a -> h a) -> k b -> Ran g h b fromRan :: Composition compose => (forall a. k a -> Ran g h a) -> compose k g b -> h b composeRan :: Composition compose => Ran f (Ran g h) a -> Ran (compose f g) h a decomposeRan :: (Composition compose, Functor f) => Ran (compose f g) h a -> Ran f (Ran g h) a adjointToRan :: Adjunction f g => f a -> Ran g Identity a ranToAdjoint :: Adjunction f g => Ran g Identity a -> f a ranToComposedAdjoint :: (Composition compose, Adjunction f g) => Ran g h a -> compose h f a composedAdjointToRan :: (Composition compose, Adjunction f g, Functor h) => compose h f a -> Ran g h a data Lan g h a Lan :: (g b -> a) -> h b -> Lan g h a toLan :: (Composition compose, Functor f) => (forall a. h a -> compose f g a) -> Lan g h b -> f b fromLan :: Composition compose => (forall a. Lan g h a -> f a) -> h b -> compose f g b adjointToLan :: Adjunction f g => g a -> Lan f Identity a lanToAdjoint :: Adjunction f g => Lan f Identity a -> g a -- | lanToComposedAdjoint and composedAdjointToLan witness -- the natural isomorphism between Lan f h and Compose h -- g given f -| g lanToComposedAdjoint :: (Composition compose, Functor h, Adjunction f g) => Lan f h a -> compose h g a composedAdjointToLan :: Composition compose => Adjunction f g => compose h g a -> Lan f h a -- | composeLan and decomposeLan witness the natural -- isomorphism from Lan f (Lan g h) and Lan (f o g) -- h composeLan :: (Composition compose, Functor f) => Lan f (Lan g h) a -> Lan (compose f g) h a decomposeLan :: Composition compose => Lan (compose f g) h a -> Lan f (Lan g h) a instance Functor (Lan f g) instance Functor (Ran g h) 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)