Safe Haskell | None |
---|---|
Language | Haskell2010 |
Additive classes
Documentation
class Additive a where Source #
or Addition
For practical reasons, we begin the class tree with Additive
. Starting with Associative
and Unital
, or using Semigroup
and Monoid
from base tends to confuse the interface once you start having to disinguish between (say) monoidal addition and monoidal multiplication.
\a -> zero + a == a \a -> a + zero == a \a b c -> (a + b) + c == a + (b + c) \a b -> a + b == b + a
By convention, (+) is regarded as commutative, but this is not universal, and the introduction of another symbol which means non-commutative addition seems a bit dogmatic.
>>>
zero + 1
1
>>>
1 + 1
2
Instances
Additive Bool Source # | |
Additive Double Source # | |
Additive Float Source # | |
Additive Int Source # | |
Additive Int8 Source # | |
Additive Int16 Source # | |
Additive Int32 Source # | |
Additive Int64 Source # | |
Additive Integer Source # | |
Additive Natural Source # | |
Additive Word Source # | |
Additive Word8 Source # | |
Additive Word16 Source # | |
Additive Word32 Source # | |
Additive Word64 Source # | |
Additive a => Additive (Complex a) Source # | |
(Ord a, Signed a, Integral a, Ring a) => Additive (Ratio a) Source # | |
Additive b => Additive (a -> b) Source # | |
class Additive a => Subtractive a where Source #
or Subtraction
\a -> a - a == zero \a -> negate a == zero - a \a -> negate a + a == zero \a -> a + negate a == zero
>>>
negate 1
-1
>>>
1 - 2
-1
Instances
Subtractive Bool Source # | |
Subtractive Double Source # | |
Subtractive Float Source # | |
Subtractive Int Source # | |
Subtractive Int8 Source # | |
Subtractive Int16 Source # | |
Subtractive Int32 Source # | |
Subtractive Int64 Source # | |
Subtractive Integer Source # | |
Subtractive Natural Source # | |
Subtractive Word Source # | |
Subtractive Word8 Source # | |
Subtractive Word16 Source # | |
Subtractive Word32 Source # | |
Subtractive Word64 Source # | |
Subtractive a => Subtractive (Complex a) Source # | |
(Ord a, Signed a, Integral a, Ring a) => Subtractive (Ratio a) Source # | |
Subtractive b => Subtractive (a -> b) Source # | |