| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
NumHask.Algebra.Multiplicative
Description
Multiplicative classes
Synopsis
- class Multiplicative a where
- product :: (Multiplicative a, Foldable f) => f a -> a
- accproduct :: (Multiplicative a, Traversable f) => f a -> f a
- class Multiplicative a => Divisive a where
Documentation
class Multiplicative a where Source #
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 * 22
>>>2 * 36
Instances
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.00.5
>>>1 / 20.5
Minimal complete definition
Nothing