You saw this, right?(Just in case, maybe it was you who included this topic.)Alexey.
On Monday, September 7, 2015 at 4:08:54 PM UTC+2, DreamApart AtHaskells wrote:The class Num defines the method functions like (+), (-), (*), negate, ...But they are actually different concepts.We often meet situations that we want an addition for some type, butnot a multiplication. For example:data Vec3 = Vec3 Float Float FloatThe additive (and subtractive) operation is obvious, but not for amultiplication.Note(*) :: a -> a -> a -- not avaliable for a Vec3scale :: Float -> Vec3 -> Vec3dot :: Vec3 -> Vec3 -> FloatWe cannot define a (+) alone for a type, so we got many different functionsfrom different libs, like mappend, mplus, plus, (<+>), (.+.), (+.), which all reads"plus".My opinion is that the methods of Num should be seperated into different typeclasses, so we don't need to invent a new symbol for a new lib.A feasible design is:import Prelude hiding ( Num (..), Monoid (..), sum )class SemiGroup a where(+) :: a -> a -> aclass SemiGroup a => Monoid a wherezero :: aclass Monoid a => Group a wherenegate :: a -> a(-) :: a -> a -> ax - y = x + negate ynegate x = zero - xclass Group a => Ring a where -- not sure about the name ...(*) :: a -> a -> aclass Ring a => Num a whereabs :: a -> asignum :: a -> afromInteger :: Integer -> asum :: (Foldable t, Monoid a) => t a -> asum = foldl' (+) zero-- for compatibilitymempty = zeromappend = (+)mconcat = sum