numhask-0.8.1.0: A numeric class hierarchy.
Safe HaskellNone
LanguageHaskell2010

NumHask.Algebra.Additive

Description

Additive classes

Synopsis

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

Methods

(+) :: a -> a -> a infixl 6 Source #

zero :: a Source #

Instances

Instances details
Additive Bool Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

(+) :: Bool -> Bool -> Bool Source #

zero :: Bool Source #

Additive Double Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Float Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Int Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

(+) :: Int -> Int -> Int Source #

zero :: Int Source #

Additive Int8 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

(+) :: Int8 -> Int8 -> Int8 Source #

zero :: Int8 Source #

Additive Int16 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Int32 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Int64 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Integer Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Natural Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Word Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

(+) :: Word -> Word -> Word Source #

zero :: Word Source #

Additive Word8 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Word16 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Word32 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive Word64 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Additive a => Additive (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

Methods

(+) :: Complex a -> Complex a -> Complex a Source #

zero :: Complex a Source #

(Ord a, Signed a, Integral a, Ring a) => Additive (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

Methods

(+) :: Ratio a -> Ratio a -> Ratio a Source #

zero :: Ratio a Source #

Additive b => Additive (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

(+) :: (a -> b) -> (a -> b) -> a -> b Source #

zero :: a -> b Source #

sum :: (Additive a, Foldable f) => f a -> a Source #

Compute the sum of a Foldable.

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

negate

Methods

negate :: a -> a Source #

(-) :: a -> a -> a infixl 6 Source #

Instances

Instances details
Subtractive Bool Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

negate :: Bool -> Bool Source #

(-) :: Bool -> Bool -> Bool Source #

Subtractive Double Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Float Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Int Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

negate :: Int -> Int Source #

(-) :: Int -> Int -> Int Source #

Subtractive Int8 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

negate :: Int8 -> Int8 Source #

(-) :: Int8 -> Int8 -> Int8 Source #

Subtractive Int16 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Int32 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Int64 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Integer Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Natural Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Word Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

negate :: Word -> Word Source #

(-) :: Word -> Word -> Word Source #

Subtractive Word8 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Word16 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Word32 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive Word64 Source # 
Instance details

Defined in NumHask.Algebra.Additive

Subtractive a => Subtractive (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

Methods

negate :: Complex a -> Complex a Source #

(-) :: Complex a -> Complex a -> Complex a Source #

(Ord a, Signed a, Integral a, Ring a) => Subtractive (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

Methods

negate :: Ratio a -> Ratio a Source #

(-) :: Ratio a -> Ratio a -> Ratio a Source #

Subtractive b => Subtractive (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Additive

Methods

negate :: (a -> b) -> a -> b Source #

(-) :: (a -> b) -> (a -> b) -> a -> b Source #