Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | sjoerd@w3future.com |
Safe Haskell | None |
- type family Signature c :: * -> *
- class Traversable f => AlgebraSignature f where
- type Class f :: * -> Constraint
- evaluate :: Class f b => f b -> b
- class Algebra f a where
- algebra :: AlgebraSignature f => f a -> a
- algebraA :: (Applicative g, Class f b, AlgebraSignature f) => f (g b) -> g b
Documentation
class Traversable f => AlgebraSignature f whereSource
type Class f :: * -> ConstraintSource
The class for which f
is the signature.
algebra :: AlgebraSignature f => f a -> aSource
An algebra f a -> a
corresponds to an instance of a
of the class Class f
.
In some cases, for example for tuple types, you can give an algebra generically for every signature:
instance (Class f m, Class f n) => Algebra f (m, n) where algebra fmn = (evaluate (fmap fst fmn), evaluate (fmap snd fmn))
algebraA :: (Applicative g, Class f b, AlgebraSignature f) => f (g b) -> g bSource
If you just want to applicatively lift existing instances, you can use this default implementation of algebra
.