algebraic-classes-0.3.1: Conversions between algebraic classes and F-algebras.

Portabilitynon-portable
Stabilityexperimental
Maintainersjoerd@w3future.com
Safe HaskellNone

Data.Algebra.Internal

Description

 

Synopsis

Documentation

class Traversable f => AlgebraSignature f whereSource

Associated Types

type Class f :: * -> ConstraintSource

The class for which f is the signature.

Methods

evaluate :: Class f b => f b -> bSource

Translate the operations of the signature to method calls of the class.

class Algebra f a whereSource

Methods

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

Instances

Algebra f () 
Class f b => Algebra f (STM b) 
Class f b => Algebra f (Maybe b) 
Class f b => Algebra f (IO b) 
(Monoid m, Class f b) => Algebra f (Const m b) 
Class f b => Algebra f (Either a b) 
Class f b => Algebra f (a -> b) 
(Class f m, Class f n) => Algebra f (m, n) 

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.