Re: [Haskell-cafe] Numerics & implementing different instances of the same class

2008-12-12 Thread David Menendez
2008/12/12 George Pollard : > > 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 think that the

Re: [Haskell-cafe] Numerics & implementing different instances of the same class

2008-12-12 Thread Dan Weston
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)

[Haskell-cafe] Numerics & implementing different instances of the same class

2008-12-12 Thread George Pollard
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 whe