Control.Functor.Algebra
 Portability non-portable (rank-2 polymorphism) Stability experimental Maintainer Edward Kmett
Description
Algebras, Coalgebras, Bialgebras, and Dialgebras and their (co)monadic variants
Synopsis
 type Dialgebra f g a = f a -> g a type GDialgebra f g w m a = f (w a) -> g (m a) type Bialgebra f g a = (Algebra f a, Coalgebra g a) type GBialgebra f g w m a = (GAlgebra f w a, GCoalgebra g m a) type Algebra f a = f a -> a type GAlgebra f w a = f (w a) -> a type Coalgebra f a = a -> f a type GCoalgebra f m a = a -> f (m a) type Trialgebra f g h a = (Algebra f a, Dialgebra g h a) liftAlgebra :: (Functor f, Comonad w) => Algebra f :~> GAlgebra f w liftCoalgebra :: (Functor f, Monad m) => Coalgebra f :~> GCoalgebra f m liftDialgebra :: (Functor g, Functor f, Comonad w, Monad m) => Dialgebra f g :~> GDialgebra f g w m lowerAlgebra :: (Functor f, Comonad w) => Dist f w -> GAlgebra f w a -> Algebra f (w a) lowerCoalgebra :: (Functor f, Monad m) => Dist m f -> GCoalgebra f m a -> Coalgebra f (m a) fromCoalgebra :: Coalgebra f :~> Dialgebra Identity f fromAlgebra :: Algebra f :~> Dialgebra f Identity fromBialgebra :: Bialgebra f g :~> Dialgebra (f :*: Identity) (Identity :*: g)
Documentation
type Dialgebra f g a = f a -> g a
F,G-dialgebras generalize algebras and coalgebras NB: these definitions are actually wrong.
type GDialgebra f g w m a = f (w a) -> g (m a)
type Bialgebra f g a = (Algebra f a, Coalgebra g a)
F-G-bialgebras are representable by DiAlg (f :+: Identity) (Identity :+: g) a and so add no expressive power, but are a lot more convenient.
type GBialgebra f g w m a = (GAlgebra f w a, GCoalgebra g m a)
type Algebra f a = f a -> a
F-Algebras
type GAlgebra f w a = f (w a) -> a
type Coalgebra f a = a -> f a
F-Coalgebras
type GCoalgebra f m a = a -> f (m a)