[Haskell-cafe] Thoughts about redesigning "Num" type class

Richard A. O'Keefe ok at cs.otago.ac.nz
Tue Sep 8 03:47:47 UTC 2015


On 8/09/2015, at 2:08 am, DreamApart AtHaskells <rnmss.hs at gmail.com> wrote:
>     class SemiGroup a where
>         (+)         :: a -> a -> a
> 
>     class Group a => Ring a where   -- not sure about the name ...
>         (*)         :: a -> a -> a
>     
>     class Ring a => Num a where
>         abs         :: a -> a
>         signum      :: a -> a
>         fromInteger :: Integer -> a
> 
>     sum :: (Foldable t, Monoid a) => t a -> a
>     sum = foldl' (+) zero

Traditionally, + is used only for Abelian groups,
with a non-commutative binary operation being thought
of as a "product", not a sum.  I am not very happy
at the idea of being told to use the wrong operator
for a group operation.

Sounds like you want NumericPrelude.
(Or possibly the AXIOM computer algebra language...)



More information about the Haskell-Cafe mailing list