Dear Group,


I want to define two classes called Group and Ring.
The Group class is for Abelian Groups (G,+), i.e.
groups with a binary commutative operator ``+'' and an
identity element normally denoted by ``0''.

The Ring class is meant for cummutative
rings (R,+,*) with binary operators ``+'' and ``*'', where ``+'' is
commutative and has identity element ``0'', and ``*'' is
commutative with identity ``1''. 

I want to use classes because I want to define rings in terms of
existing rings later.

A neat way to define the Group and Ring classes seems to have the Ring
class being a subclass of the Group class (each Ring should inherit
the properties for addition from some Group). Let R be a Ring defined
as such.

Now it seems to me I have to do something along the following lines:

> instance Num R where
>   (+) r1 r2  = ..      -- because r1 + r2 reads a lot better than ``plus r1 r2''
>   (*) r1 r2  = ..      --      ,,    *          ,,                  times ,,
>   fromEnum i = ..      -- so one can say sexy things like 1::R and the like

> instance Group R where -- I only want to use (+) :: R -> R -> R

but where I can use (*) :: R -> R -> R, which (to me) does not seem
to be appropriate.

Is there a proper (and simple) way of defining my Group and Ring which still
allows me to overload (+) and (*)?


Regards,


Marc

Reply via email to