Safe Haskell | None |
---|---|
Language | Haskell2010 |
NumHask.Algebra.Additive
Description
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 # | |
(ExpField a, LowerBoundedField a, Ord a) => Additive (LogField a) Source # | |
Additive a => Additive (Wrapped a) Source # | |
Additive a => Additive (Positive 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
Minimal complete definition
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 # | |
(ExpField a, Ord a, LowerBoundedField a, UpperBoundedField a) => Subtractive (LogField a) Source # | |
Subtractive a => Subtractive (Wrapped a) Source # | |
(Ord a, Subtractive a) => Subtractive (Positive a) Source # | |
Subtractive b => Subtractive (a -> b) Source # | |