Portability | non-portable (rank-2 polymorphism) |
---|---|

Stability | experimental |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Algebras, Coalgebras, Bialgebras, and Dialgebras and their (co)monadic variants

- 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)
- 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
- fromCoalgebra :: Coalgebra f :~> Dialgebra Identity f
- fromAlgebra :: Algebra f :~> Dialgebra f Identity
- fromBialgebra :: Bialgebra f g :~> Dialgebra (f :*: Identity) (Identity :*: g)

# Documentation

type GDialgebra f g w m a = f (w a) -> g (m a)Source

type Bialgebra f g a = (Algebra f a, Coalgebra g a)Source

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)Source

type GCoalgebra f m a = a -> f (m a)Source

F-M-Monadic Coalgebras for a given monad M

liftAlgebra :: (Functor f, Comonad w) => Algebra f :~> GAlgebra f wSource

Turn an F-algebra into a F-W-algebra by throwing away the comonad

liftCoalgebra :: (Functor f, Monad m) => Coalgebra f :~> GCoalgebra f mSource

Turn a F-coalgebra into a F-M-coalgebra by returning into a monad

liftDialgebra :: (Functor g, Functor f, Comonad w, Monad m) => Dialgebra f g :~> GDialgebra f g w mSource