free-algebras-0.0.3.0: Free algebras in Haskell.

Safe HaskellNone
LanguageHaskell2010

Control.Algebra.Free

Contents

Synopsis

Classes

type family AlgebraType0 (f :: k) (a :: l) :: Constraint Source #

Type family which limits Hask to its full subcategory which satisfies a given constraints. Some free algebras, like free groups, or free abelian semigroups have additional constraints on on generators, like Eq or Ord.

Instances
type AlgebraType0 Coyoneda (g :: l) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 Coyoneda (g :: l) = ()
type AlgebraType0 Maybe (a :: l) Source # 
Instance details

Defined in Data.Algebra.Free

type AlgebraType0 Maybe (a :: l) = ()
type AlgebraType0 [] (a :: l) Source # 
Instance details

Defined in Data.Algebra.Free

type AlgebraType0 [] (a :: l) = ()
type AlgebraType0 NonEmpty (a :: l) Source # 
Instance details

Defined in Data.Algebra.Free

type AlgebraType0 NonEmpty (a :: l) = ()
type AlgebraType0 (FreeMSet m :: * -> *) (a :: l) Source # 
Instance details

Defined in Data.Monoid.MSet

type AlgebraType0 (FreeMSet m :: * -> *) (a :: l) = ()
type AlgebraType0 FreeGroup (a :: *) Source # 
Instance details

Defined in Data.Group.Free

type AlgebraType0 FreeGroup (a :: *) = Eq a
type AlgebraType0 FreeAbelianSemigroup (a :: *) Source # 
Instance details

Defined in Data.Semigroup.Abelian

type AlgebraType0 FreeAbelianMonoid (a :: *) Source # 
Instance details

Defined in Data.Monoid.Abelian

type AlgebraType0 FreeSemiLattice (a :: *) Source # 
Instance details

Defined in Data.Semigroup.SemiLattice

type AlgebraType0 MaybeT (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 MaybeT (m :: * -> *) = Monad m
type AlgebraType0 F (f :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 F (f :: * -> *) = Functor f
type AlgebraType0 Free (f :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 Free (f :: * -> *) = Functor f
type AlgebraType0 Ap (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 Ap (g :: * -> *) = Functor g
type AlgebraType0 Ap (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 Ap (g :: * -> *) = Functor g
type AlgebraType0 Ap (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 Ap (g :: * -> *) = Functor g
type AlgebraType0 Alt (f :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 Alt (f :: * -> *) = Functor f
type AlgebraType0 ListT (f :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 ListT (f :: * -> *) = Monad f
type AlgebraType0 DayF (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 DayF (g :: * -> *) = Applicative g
type AlgebraType0 (ExceptT e :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 (ExceptT e :: (* -> *) -> * -> *) (m :: * -> *) = Monad m
type AlgebraType0 (StateT s :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 (StateT s :: (* -> *) -> * -> *) (m :: * -> *) = Monad m
type AlgebraType0 (StateT s :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 (StateT s :: (* -> *) -> * -> *) (m :: * -> *) = Monad m
type AlgebraType0 (WriterT w :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 (WriterT w :: (* -> *) -> * -> *) (m :: * -> *) = (Monad m, Monoid w)
type AlgebraType0 (WriterT w :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 (WriterT w :: (* -> *) -> * -> *) (m :: * -> *) = (Monad m, Monoid w)
type AlgebraType0 (ReaderT r :: (k -> *) -> k -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 (ReaderT r :: (k -> *) -> k -> *) (m :: * -> *) = Monad m
type AlgebraType0 (RWST r w s :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 (RWST r w s :: (* -> *) -> * -> *) (m :: * -> *) = (Monad m, Monoid w)
type AlgebraType0 (RWST r w s :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 (RWST r w s :: (* -> *) -> * -> *) (m :: * -> *) = (Monad m, Monoid w)
type AlgebraType0 (FreeMAction m :: (k2 -> k1) -> k2 -> *) (f :: * -> *) Source # 
Instance details

Defined in Control.Monad.Action

type AlgebraType0 (FreeMAction m :: (k2 -> k1) -> k2 -> *) (f :: * -> *) = Functor f

type family AlgebraType (f :: k) (a :: l) :: Constraint Source #

Type family which for each free algebra m returns a type level lambda from types to constraints. It is describe the class of algebras for which this free algebra is free.

A lawful instance for this type family must guarantee that the constraint AlgebraType0 m f is implied by the AlgebraType m f constraint. This guarantees that there exists a forgetful functor from the category of types of kind * -> * which satisfy AlgebraType m constrain to the category of types of kind * -> * which satisfy the 'AlgebraType0 m constraint.

Instances
type AlgebraType [] (m :: *) Source # 
Instance details

Defined in Data.Algebra.Free

type AlgebraType [] (m :: *) = Monoid m
type AlgebraType Maybe (m :: *) Source # 
Instance details

Defined in Data.Algebra.Free

type AlgebraType Maybe (m :: *) = Pointed m
type AlgebraType NonEmpty (m :: *) Source # 
Instance details

Defined in Data.Algebra.Free

type AlgebraType FreeGroup (g :: *) Source # 
Instance details

Defined in Data.Group.Free

type AlgebraType FreeGroup (g :: *) = (Eq g, Group g)
type AlgebraType FreeAbelianSemigroup (a :: *) Source # 
Instance details

Defined in Data.Semigroup.Abelian

type AlgebraType FreeAbelianMonoid (m :: *) Source # 
Instance details

Defined in Data.Monoid.Abelian

type AlgebraType FreeSemiLattice (a :: *) Source # 
Instance details

Defined in Data.Semigroup.SemiLattice

type AlgebraType (FreeMSet m :: * -> *) (a :: *) Source # 
Instance details

Defined in Data.Monoid.MSet

type AlgebraType (FreeMSet m :: * -> *) (a :: *) = MSet m a
type AlgebraType MaybeT (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType MaybeT (m :: * -> *) = (Monad m, MonadMaybe m)
type AlgebraType F (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType F (m :: * -> *) = Monad m
type AlgebraType Free (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType Free (m :: * -> *) = Monad m
type AlgebraType Ap (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType Ap (g :: * -> *) = Applicative g
type AlgebraType Ap (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType Ap (g :: * -> *) = Applicative g
type AlgebraType Ap (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType Ap (g :: * -> *) = Applicative g
type AlgebraType Alt (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType Alt (m :: * -> *) = Alternative m
type AlgebraType Coyoneda (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType Coyoneda (g :: * -> *) = Functor g
type AlgebraType ListT (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType ListT (m :: * -> *) = MonadList m
type AlgebraType DayF (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType DayF (g :: * -> *) = Applicative g
type AlgebraType (ExceptT e :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType (ExceptT e :: (* -> *) -> * -> *) (m :: * -> *) = MonadError e m
type AlgebraType (StateT s :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType (StateT s :: (* -> *) -> * -> *) (m :: * -> *) = MonadState s m
type AlgebraType (StateT s :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType (StateT s :: (* -> *) -> * -> *) (m :: * -> *) = MonadState s m
type AlgebraType (WriterT w :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType (WriterT w :: (* -> *) -> * -> *) (m :: * -> *) = MonadWriter w m
type AlgebraType (WriterT w :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType (WriterT w :: (* -> *) -> * -> *) (m :: * -> *) = MonadWriter w m
type AlgebraType (ReaderT r :: (k -> *) -> k -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType (ReaderT r :: (k -> *) -> k -> *) (m :: * -> *) = MonadReader r m
type AlgebraType (RWST r w s :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType (RWST r w s :: (* -> *) -> * -> *) (m :: * -> *) = MonadRWS r w s m
type AlgebraType (RWST r w s :: (* -> *) -> * -> *) (m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType (RWST r w s :: (* -> *) -> * -> *) (m :: * -> *) = MonadRWS r w s m
type AlgebraType (FreeMAction m :: (k -> *) -> k -> *) (f :: * -> *) Source # 
Instance details

Defined in Control.Monad.Action

type AlgebraType (FreeMAction m :: (k -> *) -> k -> *) (f :: * -> *) = MAction m f

newtype Proof (c :: Constraint) (a :: l) Source #

A proof that constraint c holds for type a.

Constructors

Proof (Dict c) 

class FreeAlgebra1 (m :: (Type -> Type) -> Type -> Type) where Source #

Higher kinded version of FreeAlgebra. Instances includes free functors, free applicative functors, free monads, state monads etc.

A lawful instance should guarantee that foldNatFree is an isomorphism with inverses unFoldNatFree.

This guaranties that m is a left adjoint functor from the category of types of kind Type -> Type which satisfy AlgebraType0 m constraint, to the category of types of kind Type -> Type which satisfy the AlgebraType m constraint. This functor is left adjoin to the forgetful functor (which is well defined if the laws on AlgebraType0 family are satisfied. This in turn guarantees that m composed with this forgetful functor is a monad. In result we get the monadic combinators: liftFree (return of this monad) and bindFree1 (its bind) and joinFree1 - its join operator.

Minimal complete definition

liftFree, foldNatFree, proof1, forget1

Methods

liftFree :: AlgebraType0 m f => f a -> m f a Source #

Natural transformation that embeds generators into m.

foldNatFree Source #

Arguments

:: forall (d :: Type -> Type). (AlgebraType m d, AlgebraType0 m f) 
=> (forall x. f x -> d x)

natural transformation which embeds generators of m into d

-> m f a -> d a

a homomorphism from m f to d

The freeness property.

proof1 :: forall f. AlgebraType0 m f => Proof (AlgebraType m (m f)) (m f) Source #

A proof that AlgebraType m (m f) holds for all AlgebraType0 f => f. Together with hoistFree1 this proves that FreeAlgebra m => m is a functor from the full subcategory of types of kind Type -> Type which satisfy AlgebraType0 m f to ones that satisfy AlgebraType m f.

forget1 :: forall f. AlgebraType m f => Proof (AlgebraType0 m f) (m f) Source #

A proof that the forgetful functor from the full subcategory of types of kind Type -> Type satisfying AlgebraType m f constraint to types satisfying AlgebraType0 m f is well defined.

Instances
FreeAlgebra1 MaybeT Source # 
Instance details

Defined in Control.Algebra.Free

FreeAlgebra1 F Source # 
Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 F f => f a -> F f a Source #

foldNatFree :: (AlgebraType F d, AlgebraType0 F f) => (forall x. f x -> d x) -> F f a -> d a Source #

proof1 :: AlgebraType0 F f => Proof (AlgebraType F (F f)) (F f) Source #

forget1 :: AlgebraType F f => Proof (AlgebraType0 F f) (F f) Source #

FreeAlgebra1 Free Source #

Free monad is free in the class of monad over the class of functors.

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 Free f => f a -> Free f a Source #

foldNatFree :: (AlgebraType Free d, AlgebraType0 Free f) => (forall x. f x -> d x) -> Free f a -> d a Source #

proof1 :: AlgebraType0 Free f => Proof (AlgebraType Free (Free f)) (Free f) Source #

forget1 :: AlgebraType Free f => Proof (AlgebraType0 Free f) (Free f) Source #

FreeAlgebra1 Ap Source # 
Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 Ap f => f a -> Ap f a Source #

foldNatFree :: (AlgebraType Ap d, AlgebraType0 Ap f) => (forall x. f x -> d x) -> Ap f a -> d a Source #

proof1 :: AlgebraType0 Ap f => Proof (AlgebraType Ap (Ap f)) (Ap f) Source #

forget1 :: AlgebraType Ap f => Proof (AlgebraType0 Ap f) (Ap f) Source #

FreeAlgebra1 Ap Source # 
Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 Ap f => f a -> Ap f a Source #

foldNatFree :: (AlgebraType Ap d, AlgebraType0 Ap f) => (forall x. f x -> d x) -> Ap f a -> d a Source #

proof1 :: AlgebraType0 Ap f => Proof (AlgebraType Ap (Ap f)) (Ap f) Source #

forget1 :: AlgebraType Ap f => Proof (AlgebraType0 Ap f) (Ap f) Source #

FreeAlgebra1 Ap Source #

Ap is a free in the class of applicative functors, over any functor (Ap f is applicative whenever f is a functor)

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 Ap f => f a -> Ap f a Source #

foldNatFree :: (AlgebraType Ap d, AlgebraType0 Ap f) => (forall x. f x -> d x) -> Ap f a -> d a Source #

proof1 :: AlgebraType0 Ap f => Proof (AlgebraType Ap (Ap f)) (Ap f) Source #

forget1 :: AlgebraType Ap f => Proof (AlgebraType0 Ap f) (Ap f) Source #

FreeAlgebra1 Alt Source # 
Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 Alt f => f a -> Alt f a Source #

foldNatFree :: (AlgebraType Alt d, AlgebraType0 Alt f) => (forall x. f x -> d x) -> Alt f a -> d a Source #

proof1 :: AlgebraType0 Alt f => Proof (AlgebraType Alt (Alt f)) (Alt f) Source #

forget1 :: AlgebraType Alt f => Proof (AlgebraType0 Alt f) (Alt f) Source #

FreeAlgebra1 Coyoneda Source # 
Instance details

Defined in Control.Algebra.Free

FreeAlgebra1 ListT Source # 
Instance details

Defined in Control.Algebra.Free

FreeAlgebra1 DayF Source #

DayF, as Ap is a free applicative functor, but over applicative functors (DayF f is applicative if f is an applicative functor).

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 DayF f => f a -> DayF f a Source #

foldNatFree :: (AlgebraType DayF d, AlgebraType0 DayF f) => (forall x. f x -> d x) -> DayF f a -> d a Source #

proof1 :: AlgebraType0 DayF f => Proof (AlgebraType DayF (DayF f)) (DayF f) Source #

forget1 :: AlgebraType DayF f => Proof (AlgebraType0 DayF f) (DayF f) Source #

FreeAlgebra1 (ExceptT e) Source #

ExceptT e is a free algebra among all MonadError e monads.

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 (ExceptT e) f => f a -> ExceptT e f a Source #

foldNatFree :: (AlgebraType (ExceptT e) d, AlgebraType0 (ExceptT e) f) => (forall x. f x -> d x) -> ExceptT e f a -> d a Source #

proof1 :: AlgebraType0 (ExceptT e) f => Proof (AlgebraType (ExceptT e) (ExceptT e f)) (ExceptT e f) Source #

forget1 :: AlgebraType (ExceptT e) f => Proof (AlgebraType0 (ExceptT e) f) (ExceptT e f) Source #

FreeAlgebra1 (StateT s) Source #

Lazy StateT monad transformer is a free algebra in the class of monads which satisfy the MonadState constraint. Note that this instance captures that StateT s is a monad transformer:

 liftFree = lift

This is also true for all the other monad transformers.

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 (StateT s) f => f a -> StateT s f a Source #

foldNatFree :: (AlgebraType (StateT s) d, AlgebraType0 (StateT s) f) => (forall x. f x -> d x) -> StateT s f a -> d a Source #

proof1 :: AlgebraType0 (StateT s) f => Proof (AlgebraType (StateT s) (StateT s f)) (StateT s f) Source #

forget1 :: AlgebraType (StateT s) f => Proof (AlgebraType0 (StateT s) f) (StateT s f) Source #

FreeAlgebra1 (StateT s) Source #

Strict StateT monad transformer is also a free algebra, thus hoistFreeH is an isomorphism between the strict and lazy versions.

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 (StateT s) f => f a -> StateT s f a Source #

foldNatFree :: (AlgebraType (StateT s) d, AlgebraType0 (StateT s) f) => (forall x. f x -> d x) -> StateT s f a -> d a Source #

proof1 :: AlgebraType0 (StateT s) f => Proof (AlgebraType (StateT s) (StateT s f)) (StateT s f) Source #

forget1 :: AlgebraType (StateT s) f => Proof (AlgebraType0 (StateT s) f) (StateT s f) Source #

FreeAlgebra1 (WriterT w) Source #

Lazy WriterT is free for algebras of type MonadWriter.

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 (WriterT w) f => f a -> WriterT w f a Source #

foldNatFree :: (AlgebraType (WriterT w) d, AlgebraType0 (WriterT w) f) => (forall x. f x -> d x) -> WriterT w f a -> d a Source #

proof1 :: AlgebraType0 (WriterT w) f => Proof (AlgebraType (WriterT w) (WriterT w f)) (WriterT w f) Source #

forget1 :: AlgebraType (WriterT w) f => Proof (AlgebraType0 (WriterT w) f) (WriterT w f) Source #

FreeAlgebra1 (WriterT w) Source #

Strict WriterT monad transformer is a free algebra among all MonadWriters.

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 (WriterT w) f => f a -> WriterT w f a Source #

foldNatFree :: (AlgebraType (WriterT w) d, AlgebraType0 (WriterT w) f) => (forall x. f x -> d x) -> WriterT w f a -> d a Source #

proof1 :: AlgebraType0 (WriterT w) f => Proof (AlgebraType (WriterT w) (WriterT w f)) (WriterT w f) Source #

forget1 :: AlgebraType (WriterT w) f => Proof (AlgebraType0 (WriterT w) f) (WriterT w f) Source #

FreeAlgebra1 (ReaderT r :: (Type -> *) -> Type -> *) Source #

ReaderT is a free monad in the class of all MonadReader monads.

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 (ReaderT r) f => f a -> ReaderT r f a Source #

foldNatFree :: (AlgebraType (ReaderT r) d, AlgebraType0 (ReaderT r) f) => (forall x. f x -> d x) -> ReaderT r f a -> d a Source #

proof1 :: AlgebraType0 (ReaderT r) f => Proof (AlgebraType (ReaderT r) (ReaderT r f)) (ReaderT r f) Source #

forget1 :: AlgebraType (ReaderT r) f => Proof (AlgebraType0 (ReaderT r) f) (ReaderT r f) Source #

FreeAlgebra1 (RWST r w s) Source # 
Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 (RWST r w s) f => f a -> RWST r w s f a Source #

foldNatFree :: (AlgebraType (RWST r w s) d, AlgebraType0 (RWST r w s) f) => (forall x. f x -> d x) -> RWST r w s f a -> d a Source #

proof1 :: AlgebraType0 (RWST r w s) f => Proof (AlgebraType (RWST r w s) (RWST r w s f)) (RWST r w s f) Source #

forget1 :: AlgebraType (RWST r w s) f => Proof (AlgebraType0 (RWST r w s) f) (RWST r w s f) Source #

FreeAlgebra1 (RWST r w s) Source # 
Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 (RWST r w s) f => f a -> RWST r w s f a Source #

foldNatFree :: (AlgebraType (RWST r w s) d, AlgebraType0 (RWST r w s) f) => (forall x. f x -> d x) -> RWST r w s f a -> d a Source #

proof1 :: AlgebraType0 (RWST r w s) f => Proof (AlgebraType (RWST r w s) (RWST r w s f)) (RWST r w s f) Source #

forget1 :: AlgebraType (RWST r w s) f => Proof (AlgebraType0 (RWST r w s) f) (RWST r w s f) Source #

Monad m => FreeAlgebra1 (FreeMAction m :: (Type -> *) -> Type -> *) Source # 
Instance details

Defined in Control.Monad.Action

Combinators

wrapFree :: (FreeAlgebra1 m, AlgebraType0 m f, Monad (m f)) => f (m f a) -> m f a Source #

Anything that carries FreeAlgebra1 constraint is also an instance of MonadFree, but not vice versa. You can use wrap to define a MonadFree instance. ContT is an example of a monad which does have an FreeAlgebra1 instance, but has an MonadFree instance.

The Monad constrain will be satisfied for many monads through the 'AlgebraType m' constraint.

foldFree1 :: forall m f a. (FreeAlgebra1 m, AlgebraType m f) => m f a -> f a Source #

FreeAlgebra1 m implies that m f is a foldable.

 foldFree1 . liftFree == id :: f a -> f a

foldFree1 is the unit of the adjunction imposed by FreeAlgebra1 constraint.

It can be specialized to:

unFoldNatFree :: (FreeAlgebra1 m, AlgebraType0 m f) => (forall x. m f x -> d x) -> f a -> d a Source #

unFoldNatFree is an inverse of foldNatFree

unFoldNatFree id = ruturnFree1

Note that unFoldNatFree id is the unit of the adjunction imposed by the FreeAlgebra1 constraint.

hoistFree1 Source #

Arguments

:: (FreeAlgebra1 m, AlgebraType0 m g, AlgebraType0 m f) 
=> (forall x. f x -> g x)

a natural transformation f ~> g

-> m f a 
-> m g a 

This is a functor instance for m when considered as an endofuctor of some subcategory of Type -> Type (e.g. endofunctors of _Hask_).

It can be specialized to:

hoistFreeH :: forall m n f a. (FreeAlgebra1 m, FreeAlgebra1 n, AlgebraType0 m f, AlgebraType0 n f, AlgebraType m (n f)) => m f a -> n f a Source #

joinFree1 :: forall m f a. (FreeAlgebra1 m, AlgebraType0 m f) => m (m f) a -> m f a Source #

joinFree1 makes m a monad in some subcatgory of types of kind Type -> Type (usually the endo-functor category of Hask). It is just a specialization of foldFree1.

bindFree1 Source #

Arguments

:: (FreeAlgebra1 m, AlgebraType0 m g, AlgebraType0 m f) 
=> m f a 
-> (forall x. f x -> m g x)

natural transformation f ~> m g

-> m g a 

Bind operator for the joinFree1 monad, this is just foldNatFree in disguise.

assocFree1 :: forall m f a. (FreeAlgebra1 m, AlgebraType m f, Functor (m (m f))) => m f (m f a) -> m (m f) (f a) Source #

iterFree1 :: forall m f a. (FreeAlgebra1 m, AlgebraType0 m f, AlgebraType m Identity) => (forall x. f x -> x) -> m f a -> a Source #

Specialization of foldNatFree @_ @Identity; it will further specialize to:

cataFree1 :: forall m f a. (FreeAlgebra1 m, AlgebraType m f, Monad f, Traversable (m f)) => Fix (m f) -> f a Source #

Fix (m f) is the initial algebra of type AlgebraType m and AlgebraType0 f (whenever it exists).

Day convolution

newtype DayF f a Source #

Day f f newtype wrapper. It is isomorphic with Ap f for applicative functors f via dayToAp (and apToDay).

Constructors

DayF 

Fields

Instances
FreeAlgebra1 DayF Source #

DayF, as Ap is a free applicative functor, but over applicative functors (DayF f is applicative if f is an applicative functor).

Instance details

Defined in Control.Algebra.Free

Methods

liftFree :: AlgebraType0 DayF f => f a -> DayF f a Source #

foldNatFree :: (AlgebraType DayF d, AlgebraType0 DayF f) => (forall x. f x -> d x) -> DayF f a -> d a Source #

proof1 :: AlgebraType0 DayF f => Proof (AlgebraType DayF (DayF f)) (DayF f) Source #

forget1 :: AlgebraType DayF f => Proof (AlgebraType0 DayF f) (DayF f) Source #

Functor (DayF f) Source # 
Instance details

Defined in Control.Algebra.Free

Methods

fmap :: (a -> b) -> DayF f a -> DayF f b #

(<$) :: a -> DayF f b -> DayF f a #

Applicative f => Applicative (DayF f) Source # 
Instance details

Defined in Control.Algebra.Free

Methods

pure :: a -> DayF f a #

(<*>) :: DayF f (a -> b) -> DayF f a -> DayF f b #

liftA2 :: (a -> b -> c) -> DayF f a -> DayF f b -> DayF f c #

(*>) :: DayF f a -> DayF f b -> DayF f b #

(<*) :: DayF f a -> DayF f b -> DayF f a #

type AlgebraType0 DayF (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType0 DayF (g :: * -> *) = Applicative g
type AlgebraType DayF (g :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

type AlgebraType DayF (g :: * -> *) = Applicative g

dayToAp :: Applicative f => Day f f a -> Ap f a Source #

apToDay :: Applicative f => Ap f a -> Day f f a Source #

Various classes (higher algebra types)

class Monad m => MonadList m where Source #

Algebra type for ListT monad transformer.

Minimal complete definition

mempty1, mappend1

Methods

mempty1 :: m a Source #

mappend1 :: m a -> m a -> m a Source #

Instances
Monad m => MonadList (ListT m) Source # 
Instance details

Defined in Control.Algebra.Free

Methods

mempty1 :: ListT m a Source #

mappend1 :: ListT m a -> ListT m a -> ListT m a Source #

class MonadMaybe m where Source #

A higher version Pointed class.

With QuantifiedConstraints this class will be redundant.

Minimal complete definition

point

Methods

point :: forall a. m a Source #

Instances
Monad m => MonadMaybe (MaybeT m :: * -> *) Source # 
Instance details

Defined in Control.Algebra.Free

Methods

point :: MaybeT m a Source #