Safe Haskell | Safe-Infered |
---|
Control.ForFree
Contents
- class Plus f where
- newtype OpT f a b = OpT {
- getOpT :: f b -> a
- newtype Yoneda f x = Yoneda {
- runYoneda :: forall z. (x -> z) -> f z
- unreduceYoneda :: Functor w => (forall z. w z -> f z) -> w x -> Yoneda f x
- data CoYoneda f x = forall z . CoYoneda (z -> x) (f z)
- reduceCoYoneda :: Functor m => (forall z. f z -> m z) -> CoYoneda f x -> m x
- data Free f x
- reduceFree :: Monad m => (forall z. f z -> m z) -> Free f x -> m x
- affectFree :: Functor g => (forall z. (s, f z) -> g (s, z)) -> (s, Free f x) -> Free g (s, x)
- newtype FreeT f m r = FreeT {}
- reduceFreeT :: Monad m => (forall z. f z -> m z) -> FreeT f m x -> m x
- data Cofree f x = x :< (f (Cofree f x))
- unreduceCofree :: Comonad w => (forall z. w z -> f z) -> w x -> Cofree f x
- affectCofree :: Functor g => (forall z. (s, f z) -> g (s, z)) -> (s, Cofree f x) -> Cofree g (s, x)
- data CofreeT f w x = CofreeT (w x) (f (CofreeT f w x))
- unreduceCofreeT :: Comonad w => (forall z. w z -> f z) -> w x -> CofreeT f w x
- newtype Codensity f x = Codensity {
- runCodensity :: forall z. (x -> f z) -> f z
- lowerCodensity :: Applicative f => Codensity f x -> f x
- data Density f x = forall z . Density (f z -> x) (f z)
- liftDensity :: Comonad w => w a -> Density w a
- newtype CoT w m a = CoT {
- runCoT :: forall r. w (a -> m r) -> m r
- type Co w = CoT w Identity
- runCo :: Functor w => Co w a -> w (a -> r) -> r
- liftCoT0 :: Comonad w => (forall a. w a -> s) -> CoT w m s
- lowerCoT0 :: (Functor w, Applicative m) => CoT w m s -> w a -> m s
- lowerCo0 :: Functor w => Co w s -> w a -> s
- liftCoT1 :: (forall a. w a -> a) -> CoT w m ()
- lowerCoT1 :: (Functor w, Applicative m) => CoT w m z -> w a -> m a
- lowerCo1 :: Functor w => Co w z -> w a -> a
- newtype CodensityAsk w x = CodensityAsk {
- runCodensityAsk :: forall z. w z -> (x -> z) -> z
- peekCodensityAsk :: w x -> CodensityAsk w x -> x
- newtype CodensityAskT w m x = CodensityAskT {
- runCodensityAskT :: forall z. w (m z) -> (x -> m z) -> m z
- peekCodensityAskT :: Applicative m => w (m x) -> CodensityAskT w m x -> m x
- lowerCodensityAskT :: (Plus w, Applicative m) => CodensityAskT w m x -> m x
- catchCodensityAsk :: w (CodensityAsk w x) -> CodensityAsk w x -> CodensityAsk w x
- catchCodensityAskT :: (Functor w, Monad m) => w (CodensityAskT w m x) -> CodensityAskT w m x -> CodensityAskT w m x
- data DensityAskT p f x = forall z . DensityAskT (p z -> f z -> x) (f z)
- type DensityAsk p = DensityAskT p Identity
- liftDensityAsk :: Comonad w => w x -> DensityAskT p w x
- data Finalize x = Finalize
- data Initialize x
- data Decompose where
- data Recompose where
- newtype Op a b = Op {
- getOp :: b -> a
- newtype Endo a = Endo {
- appEndo :: a -> a
- newtype Const a b = Const {
- getConst :: a
Plus
Instances
Plus [] | |
Plus Endo | |
Plus Maybe | |
Plus Seq | |
Plus IntMap | |
Plus Comparison | |
Monoid x => Plus (Const x) | |
Ord k => Plus (Map k) | |
Monoid x => Plus (Op x) | |
(Functor m, Monad m) => Plus (MaybeT m) | |
Comonad w => Plus (CodensityAsk w) | |
Plus f => Plus (Codensity f) | |
Plus f => Plus (Free f) | |
Plus f => Plus (Yoneda f) | |
(ArrowZero a, ArrowPlus a) => Plus (WrappedArrow a b) | |
Plus f => Plus (WriterT x f) | |
MonadPlus m => Plus (StateT s m) | |
Plus f => Plus (ReaderT x f) | |
Comonad w => Plus (CodensityAskT w f) | |
Plus m => Plus (FreeT f m) | |
Monoid x => Plus (OpT f x) | |
(Monoid w, Functor m, MonadPlus m) => Plus (RWST r w s m) |
Like Op
but apply another type.
Yoneda
Right Yoneda lemma
unreduceYoneda :: Functor w => (forall z. w z -> f z) -> w x -> Yoneda f xSource
Build the right Yoneda by specifying the translation from a functor to anything.
CoYoneda
Left Yoneda lemma
Constructors
forall z . CoYoneda (z -> x) (f z) |
reduceCoYoneda :: Functor m => (forall z. f z -> m z) -> CoYoneda f x -> m xSource
Lower the left Yoneda by specifying the translation from the inner type to any functor.
Free monad
Free monad from a functor
Instances
ComonadHoist Free | |
Functor f => Monad (Free f) | |
Functor f => Functor (Free f) | |
(Functor f, Plus f) => MonadPlus (Free f) | |
Functor f => Applicative (Free f) | |
(Functor f, Plus f) => Alternative (Free f) | |
Plus f => Plus (Free f) | |
(Eq (f (Free f a)), Eq a) => Eq (Free f a) | |
(Ord (f (Free f a)), Ord a) => Ord (Free f a) | |
(Read (f (Free f a)), Read a) => Read (Free f a) | |
(Show (f (Free f a)), Show a) => Show (Free f a) |
reduceFree :: Monad m => (forall z. f z -> m z) -> Free f x -> m xSource
Lowers the free monad to another monad by giving the translation from the functor to the monad.
affectFree :: Functor g => (forall z. (s, f z) -> g (s, z)) -> (s, Free f x) -> Free g (s, x)Source
Affect each level of the structure and pass a result of reading them to the leaf nodes.
Transformer of free monad.
Instances
MonadTrans (FreeT f) | |
(Functor f, Monad m) => Monad (FreeT f m) | |
(Functor f, Functor m) => Functor (FreeT f m) | |
(Functor f, MonadPlus m) => MonadPlus (FreeT f m) | |
(Functor f, Applicative m, Monad m) => Applicative (FreeT f m) | |
(Functor f, Monad m, Alternative m) => Alternative (FreeT f m) | |
Plus m => Plus (FreeT f m) |
reduceFreeT :: Monad m => (forall z. f z -> m z) -> FreeT f m x -> m xSource
As reduceFree
for transformers (you must reduce to the monad being transformed).
Free comonad
Free comonad from a functor
Instances
ComonadHoist Cofree | |
Functor f => Functor (Cofree f) | |
Applicative f => Applicative (Cofree f) | |
Functor f => Comonad (Cofree f) | |
Functor f => Extend (Cofree f) | |
(Eq (f (Cofree f a)), Eq a) => Eq (Cofree f a) | |
(Ord (f (Cofree f a)), Ord a) => Ord (Cofree f a) | |
(Read (f (Cofree f a)), Read a) => Read (Cofree f a) | |
(Show (f (Cofree f a)), Show a) => Show (Cofree f a) |
unreduceCofree :: Comonad w => (forall z. w z -> f z) -> w x -> Cofree f xSource
Build the free comonad from a comonad by giving the translation from the comonad to a functor.
affectCofree :: Functor g => (forall z. (s, f z) -> g (s, z)) -> (s, Cofree f x) -> Cofree g (s, x)Source
Affect each level of the structure and pass a result of reading them to each node.
unreduceCofreeT :: Comonad w => (forall z. w z -> f z) -> w x -> CofreeT f w xSource
As unreduceCofree
for transformers (you must unreduce from the comonad being transformed).
Codensity monad
Codensity monad from anything (it doesn't have to be a functor)
Constructors
Codensity | |
Fields
|
lowerCodensity :: Applicative f => Codensity f x -> f xSource
You can reduce the codensity monad of any applicative functor to that applicative functor.
Density comonad
Density comonad from anything (it doesn't have to be a functor)
Constructors
forall z . Density (f z -> x) (f z) |
Instances
ComonadTrans Density | |
Functor (Density f) | |
Applicative f => Applicative (Density f) | |
Comonad (Density f) | |
Extend (Density f) |
liftDensity :: Comonad w => w a -> Density w aSource
You can make the density comonad from any copointed functor.
Monads from comonads
Make a monad transformer from any comonad as Edward Kmett described.
lowerCoT0 :: (Functor w, Applicative m) => CoT w m s -> w a -> m sSource
lowerCoT1 :: (Functor w, Applicative m) => CoT w m z -> w a -> m aSource
Codensity ask monad
newtype CodensityAsk w x Source
Codensity monad taking a parameter holding something related to the output type. If this parameter is a comonad, you get a MonadPlus
.
Constructors
CodensityAsk | |
Fields
|
Instances
Monad (CodensityAsk w) | |
Functor (CodensityAsk w) | |
Comonad w => MonadPlus (CodensityAsk w) | |
Applicative (CodensityAsk w) | |
Comonad w => Alternative (CodensityAsk w) | |
Comonad w => Plus (CodensityAsk w) |
peekCodensityAsk :: w x -> CodensityAsk w x -> xSource
Access the result of some CodensityAsk
by specifying an input which corresponds to the result.
newtype CodensityAskT w m x Source
Constructors
CodensityAskT | |
Fields
|
Instances
MonadTrans (CodensityAskT w) | |
Monad (CodensityAskT w m) | |
Functor (CodensityAskT w m) | |
Comonad w => MonadPlus (CodensityAskT w m) | |
Applicative (CodensityAskT w f) | |
Comonad w => Alternative (CodensityAskT w f) | |
Comonad w => Plus (CodensityAskT w f) |
peekCodensityAskT :: Applicative m => w (m x) -> CodensityAskT w m x -> m xSource
lowerCodensityAskT :: (Plus w, Applicative m) => CodensityAskT w m x -> m xSource
catchCodensityAsk :: w (CodensityAsk w x) -> CodensityAsk w x -> CodensityAsk w xSource
catchCodensityAskT :: (Functor w, Monad m) => w (CodensityAskT w m x) -> CodensityAskT w m x -> CodensityAskT w m xSource
Density ask comonad
data DensityAskT p f x Source
Constructors
forall z . DensityAskT (p z -> f z -> x) (f z) |
Instances
Plus p => ComonadTrans (DensityAskT p) | |
Functor (DensityAskT p f) | |
Plus p => Comonad (DensityAskT p f) | |
Plus p => Extend (DensityAskT p f) |
type DensityAsk p = DensityAskT p IdentitySource
Density comonad taking a parameter holding something related to the output type. If this parameter is a Plus
, you get a comonad.
liftDensityAsk :: Comonad w => w x -> DensityAskT p w xSource
Miscellaneous
Finalize monad on '(->)' category. (The Finalize monad is the only possible monad of a endofunctor taking all objects to one final object of the category.)
Constructors
Finalize |
data Initialize x Source
Initialize comonad on '(->)' category. (The Initialize comonad is dual to the Finalize monad.)
Instances
Instances of types from other modules
newtype Op a b
Dual function arrows.
newtype Endo a
The monoid of endomorphisms under composition.