Is there a good way of doing this? My running example is Monoid:
class Monoid a where
operation :: a - a - a
identity :: a
With the obvious examples on Num:
instance (Num a) = Monoid a where
operation = (+)
identity = 1
instance (Num a) = Monoid a where
What about something like
data AddMult a b = AddMult a b
class Monoid a where
operation :: a - a - a
identity :: a
instance (Monoid a, Monoid b) = Monoid (AddMult a b) where
operation (AddMult a1 m1)
(AddMult a2 m2)
= AddMult (operation a1 a2)
2008/12/12 George Pollard por...@porg.es:
However, when it comes to defining (e.g.) a Field class you have two
Abelian groups over the same type, which won't work straight off:
Especially since you generally can't take the multiplicative inverse
of the additive identity.
I'm beginning to