numhask-0.11.0.2: A numeric class hierarchy.
Safe HaskellSafe-Inferred
LanguageGHC2021

NumHask.Algebra.Multiplicative

Description

Multiplicative classes

Synopsis

Documentation

class Multiplicative a where Source #

or Multiplication

For practical reasons, we begin the class tree with Additive and Multiplicative. 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 -> one * a == a
\a -> a * one == a
\a b c -> (a * b) * c == a * (b * c)

By convention, (*) is regarded as not necessarily commutative, but this is not universal, and the introduction of another symbol which means commutative multiplication seems a bit dogmatic.

>>> one * 2
2
>>> 2 * 3
6

Methods

(*) :: a -> a -> a infixl 7 Source #

one :: a Source #

Instances

Instances details
Multiplicative Int16 Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

(*) :: Int16 -> Int16 -> Int16 Source #

one :: Int16 Source #

Multiplicative Int32 Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

(*) :: Int32 -> Int32 -> Int32 Source #

one :: Int32 Source #

Multiplicative Int64 Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

(*) :: Int64 -> Int64 -> Int64 Source #

one :: Int64 Source #

Multiplicative Int8 Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

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

one :: Int8 Source #

Multiplicative Word16 Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Multiplicative Word32 Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Multiplicative Word64 Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Multiplicative Word8 Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

(*) :: Word8 -> Word8 -> Word8 Source #

one :: Word8 Source #

Multiplicative Integer Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Multiplicative Natural Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Multiplicative Bool Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

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

one :: Bool Source #

Multiplicative Double Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Multiplicative Float Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

(*) :: Float -> Float -> Float Source #

one :: Float Source #

Multiplicative Int Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

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

one :: Int Source #

Multiplicative Word Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Methods

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

one :: Word Source #

Multiplicative a => Multiplicative (EuclideanPair a) Source # 
Instance details

Defined in NumHask.Algebra.Metric

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

Defined in NumHask.Data.Complex

Methods

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

one :: Complex a Source #

(Ord a, EndoBased a, Integral a, Ring a) => Multiplicative (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

Methods

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

one :: Ratio a Source #

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

Defined in NumHask.Algebra.Multiplicative

Methods

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

one :: a -> b Source #

product :: (Multiplicative a, Foldable f) => f a -> a Source #

Compute the product of a Foldable.

>>> product [1..5]
120

accproduct :: (Multiplicative a, Traversable f) => f a -> f a Source #

Compute the accumulating product of a Traversable.

>>> accproduct [1..5]
[1,2,6,24,120]

class Multiplicative a => Divisive a where Source #

or Division

Though unusual, the term Divisive usefully fits in with the grammer of other classes and avoids name clashes that occur with some popular libraries.

\(a :: Double) -> a / a ~= one || a == zero
\(a :: Double) -> recip a ~= one / a || a == zero
\(a :: Double) -> recip a * a ~= one || a == zero
\(a :: Double) -> a * recip a ~= one || a == zero
>>> recip 2.0
0.5
>>> 1 / 2
0.5

Minimal complete definition

(/) | recip

Methods

recip :: a -> a Source #

(/) :: a -> a -> a infixl 7 Source #

Instances

Instances details
Divisive Double Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

Divisive Float Source # 
Instance details

Defined in NumHask.Algebra.Multiplicative

(Subtractive a, Divisive a) => Divisive (EuclideanPair a) Source # 
Instance details

Defined in NumHask.Algebra.Metric

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

Defined in NumHask.Data.Complex

Methods

recip :: Complex a -> Complex a Source #

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

(Ord a, EndoBased a, Integral a, Ring a) => Divisive (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

Methods

recip :: Ratio a -> Ratio a Source #

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

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

Defined in NumHask.Algebra.Multiplicative

Methods

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

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