On Mon, 31 Jan 2011, MattMan wrote:

I'm new to Haskell, and am trying to implement some simple typeclasses for
doing algebra.  For example I have type class (simplified for the sake of
argument)

class AbGroup a where
   add :: a -> a -> a

I would like any type instantiating Num to also be an abelian group:

instance (Num a) => AbGroup a where
add i j = i+j,

If all methods of AbGroup can be defined for all Num types - why do you want an AbGroup at all? You could simply write functions with Num constraint.

You may be also interested in existing approaches to algebra in Haskell:
  http://www.haskell.org/haskellwiki/Mathematical_prelude_discussion


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to