17 Apr 23:21 2013

## ANN: algebraic-classes, conversions between algebraic classes and F-algebras

Sjoerd Visscher <sjoerd <at> w3future.com>

2013-04-17 21:21:32 GMT

2013-04-17 21:21:32 GMT

Hi all, I'd like to announce a hopefully useful new package: algebraic-classes. In short it provides conversions between algebraic classes and F-algebras, which should make generating instances of certain classes easier. Algebraic classes are classes where every method has the same result type, which is the class parameter. Examples are Num and Monoid. F-algebras are functions of the form f a -> a, with f a functor, which can be called the signature of the algebra. They are equivalent as follows: Algebraic classes are signatures, and the instances of algebraic classes are specific algebras. Take for example the Monoid class: class Monoid a where mempty :: a mappend :: a -> a -> a The equivalent signature would be: data MonoidSignature a = Op_mempty | Op_mappend a a And the list instance instance Monoid [a] where mempty = [] mappend = (++) would be equivalent to the algebra: listAlgebra :: MonoidSignature [a] -> [a] listAlgebra Op_mempty = [] listAlgebra (Op_mappend a b) = a ++ b(Continue reading)