Just out of curiosity, why do you (and many others I've seen with similar proposals) talk about additive monoids? are they somehow fundamentally different from multiplicative monoids? Or is it just a matter of notation? When I was playing with building an algebraic hierarchy, I picked a "neutral" operator for my monoids (I actually started at magma, but it's the same thing) and then introduced the addition and multiplication distinction at semirings, as it seemed pointless to distinguish them until you have a notion of a distributive law between the two.



On Fri, Oct 22, 2010 at 9:11 PM, wren ng thornton <wren@freegeek.org> wrote:
On 10/22/10 8:46 AM, Alexey Khudyakov wrote:
Hello everyone!

It's well known that Num & Co type classes are not adequate for vectors
(I don't mean arrays). I have an idea how to address this problem.

Conal Elliott wrote very nice set of type classes for vectors.
(Definition below). I used them for some time and quite pleased. Code is
concise and readable.

 > class AdditiveGroup v where
 > zeroV :: v
 > (^+^) :: v -> v -> v
 > negateV :: v -> v
[...]

I'd like to know opinion of haskellers on this and specifically opinion
of Conal Eliott as author and maintainer (I CC'ed him)

Just my standard complaint: lack of support for semirings, modules, and other simple/general structures. How come everyone's in such a hurry to run off towards Euclidean spaces et al.?

I'd rather see,

   class Additive v where -- or AdditiveMonoid, if preferred

       zeroV :: v
       (^+^) :: v -> v -> v

   class Additive v => AdditiveGroup v where
       negateV :: v -> v

   type family Scalar :: * -> *

   class Additive v => LeftModule v where
       (*^) :: Scalar v -> v -> v

   class Additive v => RightModule v where
       (^*) :: v -> Scalar v -> v

   ...

Though I don't know how much that'd affect the niceness properties you mentioned.

--
Live well,
~wren

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