semiring-num-1.5.0.0: Basic semiring class and instances

Data.Semiring

Description

Synopsis

# Semiring classes

class Semiring a where Source #

A Semiring is like the the combination of two Monoids. The first is called <+>; it has the identity element zero, and it is commutative. The second is called <.>; it has identity element one, and it must distribute over <+>.

# Laws

## Normal Monoid laws

(a <+> b) <+> c = a <+> (b <+> c)
zero <+> a = a <+> zero = a
(a <.> b) <.> c = a <.> (b <.> c)
one <.> a = a <.> one = a

## Commutativity of <+>

a <+> b = b <+> a

## Distribution of <.> over <+>

a <.> (b <+> c) = (a <.> b) <+> (a <.> c)
(a <+> b) <.> c = (a <.> c) <+> (b <.> c)

## Annihilation

zero <.> a = a <.> zero = zero

An ordered semiring follows the laws:

x <= y => x <+> z <= y <+> z
x <= y => x <+> z <= y <+> z
zero <= z && x <= y => x <.> z <= y <.> z && z <.> x <= z <.> y

Minimal complete definition

Methods

zero :: a Source #

The identity of <+>.

one :: a Source #

The identity of <.>.

(<.>) :: a -> a -> a infixl 7 Source #

An associative binary operation, which distributes over <+>.

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

An associative, commutative binary operation.

add :: [a] -> a Source #

Takes the sum of the elements of a Foldable. Analogous to sum on numbers, or or on Bools.

>>> add [1..5]
15
>>> add [False, False]
False
>>> add [False, True]
True
>>> add [True, undefined]
True


mul :: [a] -> a Source #

Takes the product of the elements of a Foldable. Analogous to product on numbers, or and on Bools.

>>> mul [1..5]
120
>>> mul [True, True]
True
>>> mul [True, False]
False
>>> mul [False, undefined]
False


Instances

 Source # Methods(<.>) :: Bool -> Bool -> Bool Source #(<+>) :: Bool -> Bool -> Bool Source #add :: [Bool] -> Bool Source #mul :: [Bool] -> Bool Source # Source # Methodsadd :: [Double] -> Double Source #mul :: [Double] -> Double Source # Source # Methodsadd :: [Float] -> Float Source #mul :: [Float] -> Float Source # Source # Methods(<.>) :: Int -> Int -> Int Source #(<+>) :: Int -> Int -> Int Source #add :: [Int] -> Int Source #mul :: [Int] -> Int Source # Source # Methods(<.>) :: Int8 -> Int8 -> Int8 Source #(<+>) :: Int8 -> Int8 -> Int8 Source #add :: [Int8] -> Int8 Source #mul :: [Int8] -> Int8 Source # Source # Methodsadd :: [Int16] -> Int16 Source #mul :: [Int16] -> Int16 Source # Source # Methodsadd :: [Int32] -> Int32 Source #mul :: [Int32] -> Int32 Source # Source # Methodsadd :: [Int64] -> Int64 Source #mul :: [Int64] -> Int64 Source # Source # Methodsadd :: [Integer] -> Integer Source #mul :: [Integer] -> Integer Source # Source # Methods(<.>) :: Word -> Word -> Word Source #(<+>) :: Word -> Word -> Word Source #add :: [Word] -> Word Source #mul :: [Word] -> Word Source # Source # Methodsadd :: [Word8] -> Word8 Source #mul :: [Word8] -> Word8 Source # Source # Methodsadd :: [Word16] -> Word16 Source #mul :: [Word16] -> Word16 Source # Source # Methodsadd :: [Word32] -> Word32 Source #mul :: [Word32] -> Word32 Source # Source # Methodsadd :: [Word64] -> Word64 Source #mul :: [Word64] -> Word64 Source # Semiring () Source # Methodszero :: () Source #one :: () Source #(<.>) :: () -> () -> () Source #(<+>) :: () -> () -> () Source #add :: [()] -> () Source #mul :: [()] -> () Source # Source # Methodsadd :: [Natural] -> Natural Source #mul :: [Natural] -> Natural Source # Source # Methods(<.>) :: CDev -> CDev -> CDev Source #(<+>) :: CDev -> CDev -> CDev Source #add :: [CDev] -> CDev Source #mul :: [CDev] -> CDev Source # Source # Methods(<.>) :: CIno -> CIno -> CIno Source #(<+>) :: CIno -> CIno -> CIno Source #add :: [CIno] -> CIno Source #mul :: [CIno] -> CIno Source # Source # Methodsadd :: [CMode] -> CMode Source #mul :: [CMode] -> CMode Source # Source # Methods(<.>) :: COff -> COff -> COff Source #(<+>) :: COff -> COff -> COff Source #add :: [COff] -> COff Source #mul :: [COff] -> COff Source # Source # Methods(<.>) :: CPid -> CPid -> CPid Source #(<+>) :: CPid -> CPid -> CPid Source #add :: [CPid] -> CPid Source #mul :: [CPid] -> CPid Source # Source # Methodsadd :: [CSsize] -> CSsize Source #mul :: [CSsize] -> CSsize Source # Source # Methods(<.>) :: CGid -> CGid -> CGid Source #(<+>) :: CGid -> CGid -> CGid Source #add :: [CGid] -> CGid Source #mul :: [CGid] -> CGid Source # Source # Methodsadd :: [CNlink] -> CNlink Source #mul :: [CNlink] -> CNlink Source # Source # Methods(<.>) :: CUid -> CUid -> CUid Source #(<+>) :: CUid -> CUid -> CUid Source #add :: [CUid] -> CUid Source #mul :: [CUid] -> CUid Source # Source # Methods(<.>) :: CCc -> CCc -> CCc Source #(<+>) :: CCc -> CCc -> CCc Source #add :: [CCc] -> CCc Source #mul :: [CCc] -> CCc Source # Source # Methodsadd :: [CSpeed] -> CSpeed Source #mul :: [CSpeed] -> CSpeed Source # Source # Methodsadd :: [CTcflag] -> CTcflag Source #mul :: [CTcflag] -> CTcflag Source # Source # Methodsadd :: [CRLim] -> CRLim Source #mul :: [CRLim] -> CRLim Source # Source # Methods(<.>) :: Fd -> Fd -> Fd Source #(<+>) :: Fd -> Fd -> Fd Source #add :: [Fd] -> Fd Source #mul :: [Fd] -> Fd Source # Source # Methodsadd :: [WordPtr] -> WordPtr Source #mul :: [WordPtr] -> WordPtr Source # Source # Methodsadd :: [IntPtr] -> IntPtr Source #mul :: [IntPtr] -> IntPtr Source # Source # Methodsadd :: [CChar] -> CChar Source #mul :: [CChar] -> CChar Source # Source # Methodsadd :: [CSChar] -> CSChar Source #mul :: [CSChar] -> CSChar Source # Source # Methodsadd :: [CUChar] -> CUChar Source #mul :: [CUChar] -> CUChar Source # Source # Methodsadd :: [CShort] -> CShort Source #mul :: [CShort] -> CShort Source # Source # Methodsadd :: [CUShort] -> CUShort Source #mul :: [CUShort] -> CUShort Source # Source # Methods(<.>) :: CInt -> CInt -> CInt Source #(<+>) :: CInt -> CInt -> CInt Source #add :: [CInt] -> CInt Source #mul :: [CInt] -> CInt Source # Source # Methodsadd :: [CUInt] -> CUInt Source #mul :: [CUInt] -> CUInt Source # Source # Methodsadd :: [CLong] -> CLong Source #mul :: [CLong] -> CLong Source # Source # Methodsadd :: [CULong] -> CULong Source #mul :: [CULong] -> CULong Source # Source # Methodsadd :: [CLLong] -> CLLong Source #mul :: [CLLong] -> CLLong Source # Source # Methodsadd :: [CULLong] -> CULLong Source #mul :: [CULLong] -> CULLong Source # Source # Methodsadd :: [CFloat] -> CFloat Source #mul :: [CFloat] -> CFloat Source # Source # Methodsadd :: [CDouble] -> CDouble Source #mul :: [CDouble] -> CDouble Source # Source # Methodsadd :: [CPtrdiff] -> CPtrdiff Source #mul :: [CPtrdiff] -> CPtrdiff Source # Source # Methodsadd :: [CSize] -> CSize Source #mul :: [CSize] -> CSize Source # Source # Methodsadd :: [CWchar] -> CWchar Source #mul :: [CWchar] -> CWchar Source # Source # Methodsadd :: [CSigAtomic] -> CSigAtomic Source #mul :: [CSigAtomic] -> CSigAtomic Source # Source # Methodsadd :: [CClock] -> CClock Source #mul :: [CClock] -> CClock Source # Source # Methodsadd :: [CTime] -> CTime Source #mul :: [CTime] -> CTime Source # Source # Methodsadd :: [CUSeconds] -> CUSeconds Source #mul :: [CUSeconds] -> CUSeconds Source # Source # Methodsadd :: [CSUSeconds] -> CSUSeconds Source #mul :: [CSUSeconds] -> CSUSeconds Source # Source # Methodsadd :: [CIntPtr] -> CIntPtr Source #mul :: [CIntPtr] -> CIntPtr Source # Source # Methodsadd :: [CUIntPtr] -> CUIntPtr Source #mul :: [CUIntPtr] -> CUIntPtr Source # Source # Methodsadd :: [CIntMax] -> CIntMax Source #mul :: [CIntMax] -> CIntMax Source # Source # Methodsadd :: [CUIntMax] -> CUIntMax Source #mul :: [CUIntMax] -> CUIntMax Source # Source # Methods(<.>) :: All -> All -> All Source #(<+>) :: All -> All -> All Source #add :: [All] -> All Source #mul :: [All] -> All Source # Source # Methods(<.>) :: Any -> Any -> Any Source #(<+>) :: Any -> Any -> Any Source #add :: [Any] -> Any Source #mul :: [Any] -> Any Source # Source # Methodsadd :: [Scientific] -> Scientific Source #mul :: [Scientific] -> Scientific Source # Source # Methods Source # Methodsadd :: [DiffTime] -> DiffTime Source #mul :: [DiffTime] -> DiffTime Source # Semiring a => Semiring [a] Source # A polynomial in x can be defined as a list of its coefficients, where the ith element is the coefficient of x^i. This is the semiring for such a list. Adapted from here. Methodszero :: [a] Source #one :: [a] Source #(<.>) :: [a] -> [a] -> [a] Source #(<+>) :: [a] -> [a] -> [a] Source #add :: [[a]] -> [a] Source #mul :: [[a]] -> [a] Source # Integral a => Semiring (Ratio a) Source # Methods(<.>) :: Ratio a -> Ratio a -> Ratio a Source #(<+>) :: Ratio a -> Ratio a -> Ratio a Source #add :: [Ratio a] -> Ratio a Source #mul :: [Ratio a] -> Ratio a Source # Semiring a => Semiring (Identity a) Source # Methods(<.>) :: Identity a -> Identity a -> Identity a Source #(<+>) :: Identity a -> Identity a -> Identity a Source #add :: [Identity a] -> Identity a Source #mul :: [Identity a] -> Identity a Source # HasResolution a => Semiring (Fixed a) Source # Methods(<.>) :: Fixed a -> Fixed a -> Fixed a Source #(<+>) :: Fixed a -> Fixed a -> Fixed a Source #add :: [Fixed a] -> Fixed a Source #mul :: [Fixed a] -> Fixed a Source # RealFloat a => Semiring (Complex a) Source # Methods(<.>) :: Complex a -> Complex a -> Complex a Source #(<+>) :: Complex a -> Complex a -> Complex a Source #add :: [Complex a] -> Complex a Source #mul :: [Complex a] -> Complex a Source # Monoid a => Semiring (Endo a) Source # This is not a true semiring. In particular, it requires the underlying monoid to be commutative, and even then, it is only a near semiring. It is, however, extremely useful. For instance, this type:forall a. Endo (Endo a)Is a valid encoding of church numerals, with addition and multiplication being their semiring variants. Methods(<.>) :: Endo a -> Endo a -> Endo a Source #(<+>) :: Endo a -> Endo a -> Endo a Source #add :: [Endo a] -> Endo a Source #mul :: [Endo a] -> Endo a Source # Semiring a => Semiring (Sum a) Source # Methods(<.>) :: Sum a -> Sum a -> Sum a Source #(<+>) :: Sum a -> Sum a -> Sum a Source #add :: [Sum a] -> Sum a Source #mul :: [Sum a] -> Sum a Source # Semiring a => Semiring (Product a) Source # Methods(<.>) :: Product a -> Product a -> Product a Source #(<+>) :: Product a -> Product a -> Product a Source #add :: [Product a] -> Product a Source #mul :: [Product a] -> Product a Source # (Monoid a, Ord a) => Semiring (Set a) Source # Methods(<.>) :: Set a -> Set a -> Set a Source #(<+>) :: Set a -> Set a -> Set a Source #add :: [Set a] -> Set a Source #mul :: [Set a] -> Set a Source # (Precise a, RealFloat a) => Semiring (Log a) Source # Methods(<.>) :: Log a -> Log a -> Log a Source #(<+>) :: Log a -> Log a -> Log a Source #add :: [Log a] -> Log a Source #mul :: [Log a] -> Log a Source # (Monoid a, Hashable a, Eq a) => Semiring (HashSet a) Source # Methods(<.>) :: HashSet a -> HashSet a -> HashSet a Source #(<+>) :: HashSet a -> HashSet a -> HashSet a Source #add :: [HashSet a] -> HashSet a Source #mul :: [HashSet a] -> HashSet a Source # Semiring a => Semiring (Vector a) Source # Methods(<.>) :: Vector a -> Vector a -> Vector a Source #(<+>) :: Vector a -> Vector a -> Vector a Source #add :: [Vector a] -> Vector a Source #mul :: [Vector a] -> Vector a Source # (Storable a, Semiring a) => Semiring (Vector a) Source # Methods(<.>) :: Vector a -> Vector a -> Vector a Source #(<+>) :: Vector a -> Vector a -> Vector a Source #add :: [Vector a] -> Vector a Source #mul :: [Vector a] -> Vector a Source # (Unbox a, Semiring a) => Semiring (Vector a) Source # Methods(<.>) :: Vector a -> Vector a -> Vector a Source #(<+>) :: Vector a -> Vector a -> Vector a Source #add :: [Vector a] -> Vector a Source #mul :: [Vector a] -> Vector a Source # (Semiring a, Ord a, HasNegativeInfinity a) => Semiring (Max a) Source # Methods(<.>) :: Max a -> Max a -> Max a Source #(<+>) :: Max a -> Max a -> Max a Source #add :: [Max a] -> Max a Source #mul :: [Max a] -> Max a Source # (Semiring a, Ord a, HasPositiveInfinity a) => Semiring (Min a) Source # Methods(<.>) :: Min a -> Min a -> Min a Source #(<+>) :: Min a -> Min a -> Min a Source #add :: [Min a] -> Min a Source #mul :: [Min a] -> Min a Source # Semiring a => Semiring (Mul a) Source # Methods(<.>) :: Mul a -> Mul a -> Mul a Source #(<+>) :: Mul a -> Mul a -> Mul a Source #add :: [Mul a] -> Mul a Source #mul :: [Mul a] -> Mul a Source # Semiring a => Semiring (Add a) Source # Methods(<.>) :: Add a -> Add a -> Add a Source #(<+>) :: Add a -> Add a -> Add a Source #add :: [Add a] -> Add a Source #mul :: [Add a] -> Add a Source # Ord a => Semiring (Free a) Source # Methods(<.>) :: Free a -> Free a -> Free a Source #(<+>) :: Free a -> Free a -> Free a Source #add :: [Free a] -> Free a Source #mul :: [Free a] -> Free a Source # (DetectableZero a, Ord a) => Semiring (Infinite a) Source # Not distributive. Methods(<.>) :: Infinite a -> Infinite a -> Infinite a Source #(<+>) :: Infinite a -> Infinite a -> Infinite a Source #add :: [Infinite a] -> Infinite a Source #mul :: [Infinite a] -> Infinite a Source # Source # Only lawful when used with positive numbers. Methods Source # Doesn't follow annihilateL or mulDistribR. Methods Semiring a => Semiring (PosInt a) Source # Methods(<.>) :: PosInt a -> PosInt a -> PosInt a Source #(<+>) :: PosInt a -> PosInt a -> PosInt a Source #add :: [PosInt a] -> PosInt a Source #mul :: [PosInt a] -> PosInt a Source # Semiring a => Semiring (PosFrac a) Source # Methods(<.>) :: PosFrac a -> PosFrac a -> PosFrac a Source #(<+>) :: PosFrac a -> PosFrac a -> PosFrac a Source #add :: [PosFrac a] -> PosFrac a Source #mul :: [PosFrac a] -> PosFrac a Source # (Ord a, Semiring a) => Semiring (Viterbi a) Source # Methods(<.>) :: Viterbi a -> Viterbi a -> Viterbi a Source #(<+>) :: Viterbi a -> Viterbi a -> Viterbi a Source #add :: [Viterbi a] -> Viterbi a Source #mul :: [Viterbi a] -> Viterbi a Source # (Ord a, Num a) => Semiring (Łukasiewicz a) Source # Methodsadd :: [Łukasiewicz a] -> Łukasiewicz a Source #mul :: [Łukasiewicz a] -> Łukasiewicz a Source # (Integral a, Semiring a) => Semiring (Division a) Source # Only expects positive numbers Methods(<.>) :: Division a -> Division a -> Division a Source #(<+>) :: Division a -> Division a -> Division a Source #add :: [Division a] -> Division a Source #mul :: [Division a] -> Division a Source # (Bounded a, Ord a) => Semiring (Bottleneck a) Source # Methods(<.>) :: Bottleneck a -> Bottleneck a -> Bottleneck a Source #(<+>) :: Bottleneck a -> Bottleneck a -> Bottleneck a Source #add :: [Bottleneck a] -> Bottleneck a Source #mul :: [Bottleneck a] -> Bottleneck a Source # Semiring b => Semiring (a -> b) Source # The (->) instance is analogous to the one for Monoid. Methodszero :: a -> b Source #one :: a -> b Source #(<.>) :: (a -> b) -> (a -> b) -> a -> b Source #(<+>) :: (a -> b) -> (a -> b) -> a -> b Source #add :: [a -> b] -> a -> b Source #mul :: [a -> b] -> a -> b Source # (Semiring a, Semiring b) => Semiring (a, b) Source # Methodszero :: (a, b) Source #one :: (a, b) Source #(<.>) :: (a, b) -> (a, b) -> (a, b) Source #(<+>) :: (a, b) -> (a, b) -> (a, b) Source #add :: [(a, b)] -> (a, b) Source #mul :: [(a, b)] -> (a, b) Source # (Ord a, Monoid a, Semiring b) => Semiring (Map a b) Source # Methodszero :: Map a b Source #one :: Map a b Source #(<.>) :: Map a b -> Map a b -> Map a b Source #(<+>) :: Map a b -> Map a b -> Map a b Source #add :: [Map a b] -> Map a b Source #mul :: [Map a b] -> Map a b Source # (Hashable a, Monoid a, Semiring b, Eq a) => Semiring (HashMap a b) Source # Methodszero :: HashMap a b Source #one :: HashMap a b Source #(<.>) :: HashMap a b -> HashMap a b -> HashMap a b Source #(<+>) :: HashMap a b -> HashMap a b -> HashMap a b Source #add :: [HashMap a b] -> HashMap a b Source #mul :: [HashMap a b] -> HashMap a b Source # (Semiring a, Semiring b, Semiring c) => Semiring (a, b, c) Source # Methodszero :: (a, b, c) Source #one :: (a, b, c) Source #(<.>) :: (a, b, c) -> (a, b, c) -> (a, b, c) Source #(<+>) :: (a, b, c) -> (a, b, c) -> (a, b, c) Source #add :: [(a, b, c)] -> (a, b, c) Source #mul :: [(a, b, c)] -> (a, b, c) Source # (Traversable f, Applicative f, Semiring a, (~) (* -> *) f g) => Semiring (Matrix f g a) Source # Methodszero :: Matrix f g a Source #one :: Matrix f g a Source #(<.>) :: Matrix f g a -> Matrix f g a -> Matrix f g a Source #(<+>) :: Matrix f g a -> Matrix f g a -> Matrix f g a Source #add :: [Matrix f g a] -> Matrix f g a Source #mul :: [Matrix f g a] -> Matrix f g a Source # (Semiring a, Semiring b, Semiring c, Semiring d) => Semiring (a, b, c, d) Source # Methodszero :: (a, b, c, d) Source #one :: (a, b, c, d) Source #(<.>) :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #(<+>) :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source #add :: [(a, b, c, d)] -> (a, b, c, d) Source #mul :: [(a, b, c, d)] -> (a, b, c, d) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e) => Semiring (a, b, c, d, e) Source # Methodszero :: (a, b, c, d, e) Source #one :: (a, b, c, d, e) Source #(<.>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #(<+>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source #add :: [(a, b, c, d, e)] -> (a, b, c, d, e) Source #mul :: [(a, b, c, d, e)] -> (a, b, c, d, e) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f) => Semiring (a, b, c, d, e, f) Source # Methodszero :: (a, b, c, d, e, f) Source #one :: (a, b, c, d, e, f) Source #(<.>) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #(<+>) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #add :: [(a, b, c, d, e, f)] -> (a, b, c, d, e, f) Source #mul :: [(a, b, c, d, e, f)] -> (a, b, c, d, e, f) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g) => Semiring (a, b, c, d, e, f, g) Source # Methodszero :: (a, b, c, d, e, f, g) Source #one :: (a, b, c, d, e, f, g) Source #(<.>) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #(<+>) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #add :: [(a, b, c, d, e, f, g)] -> (a, b, c, d, e, f, g) Source #mul :: [(a, b, c, d, e, f, g)] -> (a, b, c, d, e, f, g) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g, Semiring h) => Semiring (a, b, c, d, e, f, g, h) Source # Methodszero :: (a, b, c, d, e, f, g, h) Source #one :: (a, b, c, d, e, f, g, h) Source #(<.>) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source #(<+>) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source #add :: [(a, b, c, d, e, f, g, h)] -> (a, b, c, d, e, f, g, h) Source #mul :: [(a, b, c, d, e, f, g, h)] -> (a, b, c, d, e, f, g, h) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g, Semiring h, Semiring i) => Semiring (a, b, c, d, e, f, g, h, i) Source # Methodszero :: (a, b, c, d, e, f, g, h, i) Source #one :: (a, b, c, d, e, f, g, h, i) Source #(<.>) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) Source #(<+>) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) Source #add :: [(a, b, c, d, e, f, g, h, i)] -> (a, b, c, d, e, f, g, h, i) Source #mul :: [(a, b, c, d, e, f, g, h, i)] -> (a, b, c, d, e, f, g, h, i) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g, Semiring h, Semiring i, Semiring j) => Semiring (a, b, c, d, e, f, g, h, i, j) Source # Methodszero :: (a, b, c, d, e, f, g, h, i, j) Source #one :: (a, b, c, d, e, f, g, h, i, j) Source #(<.>) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) Source #(<+>) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) Source #add :: [(a, b, c, d, e, f, g, h, i, j)] -> (a, b, c, d, e, f, g, h, i, j) Source #mul :: [(a, b, c, d, e, f, g, h, i, j)] -> (a, b, c, d, e, f, g, h, i, j) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g, Semiring h, Semiring i, Semiring j, Semiring k) => Semiring (a, b, c, d, e, f, g, h, i, j, k) Source # Methodszero :: (a, b, c, d, e, f, g, h, i, j, k) Source #one :: (a, b, c, d, e, f, g, h, i, j, k) Source #(<.>) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) Source #(<+>) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) Source #add :: [(a, b, c, d, e, f, g, h, i, j, k)] -> (a, b, c, d, e, f, g, h, i, j, k) Source #mul :: [(a, b, c, d, e, f, g, h, i, j, k)] -> (a, b, c, d, e, f, g, h, i, j, k) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g, Semiring h, Semiring i, Semiring j, Semiring k, Semiring l) => Semiring (a, b, c, d, e, f, g, h, i, j, k, l) Source # Methodszero :: (a, b, c, d, e, f, g, h, i, j, k, l) Source #one :: (a, b, c, d, e, f, g, h, i, j, k, l) Source #(<.>) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) Source #(<+>) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) Source #add :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> (a, b, c, d, e, f, g, h, i, j, k, l) Source #mul :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> (a, b, c, d, e, f, g, h, i, j, k, l) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g, Semiring h, Semiring i, Semiring j, Semiring k, Semiring l, Semiring m) => Semiring (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # Methodszero :: (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #one :: (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #(<.>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #(<+>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #add :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #mul :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g, Semiring h, Semiring i, Semiring j, Semiring k, Semiring l, Semiring m, Semiring n) => Semiring (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # Methodszero :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #one :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #(<.>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #(<+>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #add :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #mul :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # (Semiring a, Semiring b, Semiring c, Semiring d, Semiring e, Semiring f, Semiring g, Semiring h, Semiring i, Semiring j, Semiring k, Semiring l, Semiring m, Semiring n, Semiring o) => Semiring (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # Methodszero :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #one :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #(<.>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #(<+>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #add :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #mul :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #

class Semiring a => StarSemiring a where Source #

A Star semiring adds one operation, star to a Semiring, such that it follows the law:

star x = one <+> x <.> star x = one <+> star x <.> x

For the semiring of types, this is equivalent to a list. When looking at the Applicative and Alternative classes as (near-) semirings, this is equivalent to the many operation.

Another operation, plus, can be defined in relation to star:

plus x = x <.> star x

This should be recognizable as a non-empty list on types, or the some operation in Alternative.

Minimal complete definition

Methods

star :: a -> a Source #

plus :: a -> a Source #

Instances

 Source # Methods Source # Methodsstar :: () -> () Source #plus :: () -> () Source # Source # Methods Source # Methods StarSemiring a => StarSemiring [a] Source # Methodsstar :: [a] -> [a] Source #plus :: [a] -> [a] Source # (Monoid a, Eq a) => StarSemiring (Endo a) Source # Methodsstar :: Endo a -> Endo a Source #plus :: Endo a -> Endo a Source # Source # Methodsstar :: Max a -> Max a Source #plus :: Max a -> Max a Source # Source # Methodsstar :: Min a -> Min a Source #plus :: Min a -> Min a Source # StarSemiring a => StarSemiring (Mul a) Source # Methodsstar :: Mul a -> Mul a Source #plus :: Mul a -> Mul a Source # StarSemiring a => StarSemiring (Add a) Source # Methodsstar :: Add a -> Add a Source #plus :: Add a -> Add a Source # Source # Methods (Eq a, Semiring a, HasPositiveInfinity a) => StarSemiring (PosInt a) Source # Methodsstar :: PosInt a -> PosInt a Source #plus :: PosInt a -> PosInt a Source # (Ord a, Fractional a, Semiring a, HasPositiveInfinity a) => StarSemiring (PosFrac a) Source # Methodsstar :: PosFrac a -> PosFrac a Source #plus :: PosFrac a -> PosFrac a Source # StarSemiring b => StarSemiring (a -> b) Source # Methodsstar :: (a -> b) -> a -> b Source #plus :: (a -> b) -> a -> b Source # (StarSemiring a, StarSemiring b) => StarSemiring (a, b) Source # Methodsstar :: (a, b) -> (a, b) Source #plus :: (a, b) -> (a, b) Source # (StarSemiring a, StarSemiring b, StarSemiring c) => StarSemiring (a, b, c) Source # Methodsstar :: (a, b, c) -> (a, b, c) Source #plus :: (a, b, c) -> (a, b, c) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d) => StarSemiring (a, b, c, d) Source # Methodsstar :: (a, b, c, d) -> (a, b, c, d) Source #plus :: (a, b, c, d) -> (a, b, c, d) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e) => StarSemiring (a, b, c, d, e) Source # Methodsstar :: (a, b, c, d, e) -> (a, b, c, d, e) Source #plus :: (a, b, c, d, e) -> (a, b, c, d, e) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f) => StarSemiring (a, b, c, d, e, f) Source # Methodsstar :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source #plus :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g) => StarSemiring (a, b, c, d, e, f, g) Source # Methodsstar :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source #plus :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g, StarSemiring h) => StarSemiring (a, b, c, d, e, f, g, h) Source # Methodsstar :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source #plus :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g, StarSemiring h, StarSemiring i) => StarSemiring (a, b, c, d, e, f, g, h, i) Source # Methodsstar :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) Source #plus :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g, StarSemiring h, StarSemiring i, StarSemiring j) => StarSemiring (a, b, c, d, e, f, g, h, i, j) Source # Methodsstar :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) Source #plus :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g, StarSemiring h, StarSemiring i, StarSemiring j, StarSemiring k) => StarSemiring (a, b, c, d, e, f, g, h, i, j, k) Source # Methodsstar :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) Source #plus :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g, StarSemiring h, StarSemiring i, StarSemiring j, StarSemiring k, StarSemiring l) => StarSemiring (a, b, c, d, e, f, g, h, i, j, k, l) Source # Methodsstar :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) Source #plus :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g, StarSemiring h, StarSemiring i, StarSemiring j, StarSemiring k, StarSemiring l, StarSemiring m) => StarSemiring (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # Methodsstar :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #plus :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g, StarSemiring h, StarSemiring i, StarSemiring j, StarSemiring k, StarSemiring l, StarSemiring m, StarSemiring n) => StarSemiring (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # Methodsstar :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #plus :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # (StarSemiring a, StarSemiring b, StarSemiring c, StarSemiring d, StarSemiring e, StarSemiring f, StarSemiring g, StarSemiring h, StarSemiring i, StarSemiring j, StarSemiring k, StarSemiring l, StarSemiring m, StarSemiring n, StarSemiring o) => StarSemiring (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # Methodsstar :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #plus :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #

mulFoldable :: (Foldable f, Semiring a) => f a -> a Source #

The product of the contents of a Foldable.

addFoldable :: (Foldable f, Semiring a) => f a -> a Source #

The sum of the contents of a Foldable.

# Helper classes

class HasPositiveInfinity a where Source #

A class for semirings with a concept of "infinity". It's important that this isn't regarded as the same as "bounded": x <+> positiveInfinity should probably equal positiveInfinity.

Minimal complete definition

Methods

A positive infinite value

Test if a value is positive infinity.

Instances

 Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods

class HasNegativeInfinity a where Source #

A class for semirings with a concept of "negative infinity". It's important that this isn't regarded as the same as "bounded": x <+> negativeInfinity should probably equal negativeInfinity.

Minimal complete definition

Methods

A negative infinite value

Test if a value is negative infinity.

Instances

 Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods

class Semiring a => DetectableZero a where Source #

Useful for operations where zeroes may need to be discarded: for instance in sparse matrix calculations.

Minimal complete definition

isZero

Methods

isZero :: a -> Bool Source #

True if x is zero.

Instances

 Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # MethodsisZero :: () -> Bool Source # Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods DetectableZero a => DetectableZero [a] Source # MethodsisZero :: [a] -> Bool Source # Integral a => DetectableZero (Ratio a) Source # MethodsisZero :: Ratio a -> Bool Source # Source # Methods Source # MethodsisZero :: Fixed a -> Bool Source # Source # MethodsisZero :: Complex a -> Bool Source # (Enum a, Bounded a, Eq a, Monoid a) => DetectableZero (Endo a) Source # MethodsisZero :: Endo a -> Bool Source # Source # MethodsisZero :: Sum a -> Bool Source # Source # MethodsisZero :: Product a -> Bool Source # (Monoid a, Ord a) => DetectableZero (Set a) Source # MethodsisZero :: Set a -> Bool Source # (Precise a, RealFloat a) => DetectableZero (Log a) Source # MethodsisZero :: Log a -> Bool Source # (Monoid a, Hashable a, Eq a) => DetectableZero (HashSet a) Source # MethodsisZero :: HashSet a -> Bool Source # Source # MethodsisZero :: Vector a -> Bool Source # (Storable a, DetectableZero a) => DetectableZero (Vector a) Source # MethodsisZero :: Vector a -> Bool Source # (Unbox a, DetectableZero a) => DetectableZero (Vector a) Source # MethodsisZero :: Vector a -> Bool Source # (Semiring a, Ord a, HasNegativeInfinity a) => DetectableZero (Max a) Source # MethodsisZero :: Max a -> Bool Source # (Semiring a, Ord a, HasPositiveInfinity a) => DetectableZero (Min a) Source # MethodsisZero :: Min a -> Bool Source # Source # MethodsisZero :: Mul a -> Bool Source # Source # MethodsisZero :: Add a -> Bool Source # (DetectableZero a, Ord a) => DetectableZero (Infinite a) Source # Methods Source # Methods Source # Methods (Eq a, Semiring a) => DetectableZero (PosInt a) Source # MethodsisZero :: PosInt a -> Bool Source # (Eq a, Semiring a) => DetectableZero (PosFrac a) Source # MethodsisZero :: PosFrac a -> Bool Source # (Ord a, DetectableZero a) => DetectableZero (Viterbi a) Source # MethodsisZero :: Viterbi a -> Bool Source # (Ord a, Num a) => DetectableZero (Łukasiewicz a) Source # Methods (Integral a, DetectableZero a) => DetectableZero (Division a) Source # Methods (Bounded a, Ord a) => DetectableZero (Bottleneck a) Source # Methods (DetectableZero a, DetectableZero b) => DetectableZero (a, b) Source # MethodsisZero :: (a, b) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c) => DetectableZero (a, b, c) Source # MethodsisZero :: (a, b, c) -> Bool Source # (Traversable f, Applicative f, DetectableZero a, (~) (* -> *) f g) => DetectableZero (Matrix f g a) Source # MethodsisZero :: Matrix f g a -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d) => DetectableZero (a, b, c, d) Source # MethodsisZero :: (a, b, c, d) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e) => DetectableZero (a, b, c, d, e) Source # MethodsisZero :: (a, b, c, d, e) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f) => DetectableZero (a, b, c, d, e, f) Source # MethodsisZero :: (a, b, c, d, e, f) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g) => DetectableZero (a, b, c, d, e, f, g) Source # MethodsisZero :: (a, b, c, d, e, f, g) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g, DetectableZero h) => DetectableZero (a, b, c, d, e, f, g, h) Source # MethodsisZero :: (a, b, c, d, e, f, g, h) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g, DetectableZero h, DetectableZero i) => DetectableZero (a, b, c, d, e, f, g, h, i) Source # MethodsisZero :: (a, b, c, d, e, f, g, h, i) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g, DetectableZero h, DetectableZero i, DetectableZero j) => DetectableZero (a, b, c, d, e, f, g, h, i, j) Source # MethodsisZero :: (a, b, c, d, e, f, g, h, i, j) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g, DetectableZero h, DetectableZero i, DetectableZero j, DetectableZero k) => DetectableZero (a, b, c, d, e, f, g, h, i, j, k) Source # MethodsisZero :: (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g, DetectableZero h, DetectableZero i, DetectableZero j, DetectableZero k, DetectableZero l) => DetectableZero (a, b, c, d, e, f, g, h, i, j, k, l) Source # MethodsisZero :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g, DetectableZero h, DetectableZero i, DetectableZero j, DetectableZero k, DetectableZero l, DetectableZero m) => DetectableZero (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # MethodsisZero :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g, DetectableZero h, DetectableZero i, DetectableZero j, DetectableZero k, DetectableZero l, DetectableZero m, DetectableZero n) => DetectableZero (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # MethodsisZero :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source # (DetectableZero a, DetectableZero b, DetectableZero c, DetectableZero d, DetectableZero e, DetectableZero f, DetectableZero g, DetectableZero h, DetectableZero i, DetectableZero j, DetectableZero k, DetectableZero l, DetectableZero m, DetectableZero n, DetectableZero o) => DetectableZero (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # MethodsisZero :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source #

# Monoidal wrappers

Monoid under <+>. Analogous to Sum, but uses the Semiring constraint, rather than Num.

Constructors

Instances

 Source # Methodsfmap :: (a -> b) -> Add a -> Add b #(<) :: a -> Add b -> Add a # Source # Methodsfold :: Monoid m => Add m -> m #foldMap :: Monoid m => (a -> m) -> Add a -> m #foldr :: (a -> b -> b) -> b -> Add a -> b #foldr' :: (a -> b -> b) -> b -> Add a -> b #foldl :: (b -> a -> b) -> b -> Add a -> b #foldl' :: (b -> a -> b) -> b -> Add a -> b #foldr1 :: (a -> a -> a) -> Add a -> a #foldl1 :: (a -> a -> a) -> Add a -> a #toList :: Add a -> [a] #null :: Add a -> Bool #length :: Add a -> Int #elem :: Eq a => a -> Add a -> Bool #maximum :: Ord a => Add a -> a #minimum :: Ord a => Add a -> a #sum :: Num a => Add a -> a #product :: Num a => Add a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Add a -> f (Add b) #sequenceA :: Applicative f => Add (f a) -> f (Add a) #mapM :: Monad m => (a -> m b) -> Add a -> m (Add b) #sequence :: Monad m => Add (m a) -> m (Add a) # Source # Associated Typestype Rep1 (Add :: * -> *) :: * -> * # Methodsfrom1 :: Add a -> Rep1 Add a #to1 :: Rep1 Add a -> Add a # Source # MethodsliftEq :: (a -> b -> Bool) -> Add a -> Add b -> Bool # Source # MethodsliftCompare :: (a -> b -> Ordering) -> Add a -> Add b -> Ordering # Source # MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Add a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Add a] # Source # MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Add a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Add a] -> ShowS # Bounded a => Bounded (Add a) Source # MethodsminBound :: Add a #maxBound :: Add a # Enum a => Enum (Add a) Source # Methodssucc :: Add a -> Add a #pred :: Add a -> Add a #toEnum :: Int -> Add a #fromEnum :: Add a -> Int #enumFrom :: Add a -> [Add a] #enumFromThen :: Add a -> Add a -> [Add a] #enumFromTo :: Add a -> Add a -> [Add a] #enumFromThenTo :: Add a -> Add a -> Add a -> [Add a] # Eq a => Eq (Add a) Source # Methods(==) :: Add a -> Add a -> Bool #(/=) :: Add a -> Add a -> Bool # Fractional a => Fractional (Add a) Source # Methods(/) :: Add a -> Add a -> Add a #recip :: Add a -> Add a # Num a => Num (Add a) Source # Methods(+) :: Add a -> Add a -> Add a #(-) :: Add a -> Add a -> Add a #(*) :: Add a -> Add a -> Add a #negate :: Add a -> Add a #abs :: Add a -> Add a #signum :: Add a -> Add a # Ord a => Ord (Add a) Source # Methodscompare :: Add a -> Add a -> Ordering #(<) :: Add a -> Add a -> Bool #(<=) :: Add a -> Add a -> Bool #(>) :: Add a -> Add a -> Bool #(>=) :: Add a -> Add a -> Bool #max :: Add a -> Add a -> Add a #min :: Add a -> Add a -> Add a # Read a => Read (Add a) Source # MethodsreadsPrec :: Int -> ReadS (Add a) #readList :: ReadS [Add a] #readPrec :: ReadPrec (Add a) # Real a => Real (Add a) Source # MethodstoRational :: Add a -> Rational # RealFrac a => RealFrac (Add a) Source # MethodsproperFraction :: Integral b => Add a -> (b, Add a) #truncate :: Integral b => Add a -> b #round :: Integral b => Add a -> b #ceiling :: Integral b => Add a -> b #floor :: Integral b => Add a -> b # Show a => Show (Add a) Source # MethodsshowsPrec :: Int -> Add a -> ShowS #show :: Add a -> String #showList :: [Add a] -> ShowS # Generic (Add a) Source # Associated Typestype Rep (Add a) :: * -> * # Methodsfrom :: Add a -> Rep (Add a) x #to :: Rep (Add a) x -> Add a # Semiring a => Semigroup (Add a) Source # Methods(<>) :: Add a -> Add a -> Add a #sconcat :: NonEmpty (Add a) -> Add a #stimes :: Integral b => b -> Add a -> Add a # Semiring a => Monoid (Add a) Source # Methodsmempty :: Add a #mappend :: Add a -> Add a -> Add a #mconcat :: [Add a] -> Add a # Storable a => Storable (Add a) Source # MethodssizeOf :: Add a -> Int #alignment :: Add a -> Int #peekElemOff :: Ptr (Add a) -> Int -> IO (Add a) #pokeElemOff :: Ptr (Add a) -> Int -> Add a -> IO () #peekByteOff :: Ptr b -> Int -> IO (Add a) #pokeByteOff :: Ptr b -> Int -> Add a -> IO () #peek :: Ptr (Add a) -> IO (Add a) #poke :: Ptr (Add a) -> Add a -> IO () # Source # MethodsisZero :: Add a -> Bool Source # StarSemiring a => StarSemiring (Add a) Source # Methodsstar :: Add a -> Add a Source #plus :: Add a -> Add a Source # Semiring a => Semiring (Add a) Source # Methods(<.>) :: Add a -> Add a -> Add a Source #(<+>) :: Add a -> Add a -> Add a Source #add :: [Add a] -> Add a Source #mul :: [Add a] -> Add a Source # type Rep1 Add Source # type Rep1 Add = D1 (MetaData "Add" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Add" PrefixI True) (S1 (MetaSel (Just Symbol "getAdd") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1)) type Rep (Add a) Source # type Rep (Add a) = D1 (MetaData "Add" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Add" PrefixI True) (S1 (MetaSel (Just Symbol "getAdd") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) newtype Mul a Source # Monoid under <.>. Analogous to Product, but uses the Semiring constraint, rather than Num. Constructors  Mul FieldsgetMul :: a Instances  Source # Methodsfmap :: (a -> b) -> Mul a -> Mul b #(<) :: a -> Mul b -> Mul a # Source # Methodsfold :: Monoid m => Mul m -> m #foldMap :: Monoid m => (a -> m) -> Mul a -> m #foldr :: (a -> b -> b) -> b -> Mul a -> b #foldr' :: (a -> b -> b) -> b -> Mul a -> b #foldl :: (b -> a -> b) -> b -> Mul a -> b #foldl' :: (b -> a -> b) -> b -> Mul a -> b #foldr1 :: (a -> a -> a) -> Mul a -> a #foldl1 :: (a -> a -> a) -> Mul a -> a #toList :: Mul a -> [a] #null :: Mul a -> Bool #length :: Mul a -> Int #elem :: Eq a => a -> Mul a -> Bool #maximum :: Ord a => Mul a -> a #minimum :: Ord a => Mul a -> a #sum :: Num a => Mul a -> a #product :: Num a => Mul a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Mul a -> f (Mul b) #sequenceA :: Applicative f => Mul (f a) -> f (Mul a) #mapM :: Monad m => (a -> m b) -> Mul a -> m (Mul b) #sequence :: Monad m => Mul (m a) -> m (Mul a) # Source # Associated Typestype Rep1 (Mul :: * -> *) :: * -> * # Methodsfrom1 :: Mul a -> Rep1 Mul a #to1 :: Rep1 Mul a -> Mul a # Source # MethodsliftEq :: (a -> b -> Bool) -> Mul a -> Mul b -> Bool # Source # MethodsliftCompare :: (a -> b -> Ordering) -> Mul a -> Mul b -> Ordering # Source # MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Mul a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Mul a] # Source # MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Mul a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Mul a] -> ShowS # Bounded a => Bounded (Mul a) Source # MethodsminBound :: Mul a #maxBound :: Mul a # Enum a => Enum (Mul a) Source # Methodssucc :: Mul a -> Mul a #pred :: Mul a -> Mul a #toEnum :: Int -> Mul a #fromEnum :: Mul a -> Int #enumFrom :: Mul a -> [Mul a] #enumFromThen :: Mul a -> Mul a -> [Mul a] #enumFromTo :: Mul a -> Mul a -> [Mul a] #enumFromThenTo :: Mul a -> Mul a -> Mul a -> [Mul a] # Eq a => Eq (Mul a) Source # Methods(==) :: Mul a -> Mul a -> Bool #(/=) :: Mul a -> Mul a -> Bool # Fractional a => Fractional (Mul a) Source # Methods(/) :: Mul a -> Mul a -> Mul a #recip :: Mul a -> Mul a # Num a => Num (Mul a) Source # Methods(+) :: Mul a -> Mul a -> Mul a #(-) :: Mul a -> Mul a -> Mul a #(*) :: Mul a -> Mul a -> Mul a #negate :: Mul a -> Mul a #abs :: Mul a -> Mul a #signum :: Mul a -> Mul a # Ord a => Ord (Mul a) Source # Methodscompare :: Mul a -> Mul a -> Ordering #(<) :: Mul a -> Mul a -> Bool #(<=) :: Mul a -> Mul a -> Bool #(>) :: Mul a -> Mul a -> Bool #(>=) :: Mul a -> Mul a -> Bool #max :: Mul a -> Mul a -> Mul a #min :: Mul a -> Mul a -> Mul a # Read a => Read (Mul a) Source # MethodsreadsPrec :: Int -> ReadS (Mul a) #readList :: ReadS [Mul a] #readPrec :: ReadPrec (Mul a) # Real a => Real (Mul a) Source # MethodstoRational :: Mul a -> Rational # RealFrac a => RealFrac (Mul a) Source # MethodsproperFraction :: Integral b => Mul a -> (b, Mul a) #truncate :: Integral b => Mul a -> b #round :: Integral b => Mul a -> b #ceiling :: Integral b => Mul a -> b #floor :: Integral b => Mul a -> b # Show a => Show (Mul a) Source # MethodsshowsPrec :: Int -> Mul a -> ShowS #show :: Mul a -> String #showList :: [Mul a] -> ShowS # Generic (Mul a) Source # Associated Typestype Rep (Mul a) :: * -> * # Methodsfrom :: Mul a -> Rep (Mul a) x #to :: Rep (Mul a) x -> Mul a # Semiring a => Semigroup (Mul a) Source # Methods(<>) :: Mul a -> Mul a -> Mul a #sconcat :: NonEmpty (Mul a) -> Mul a #stimes :: Integral b => b -> Mul a -> Mul a # Semiring a => Monoid (Mul a) Source # Methodsmempty :: Mul a #mappend :: Mul a -> Mul a -> Mul a #mconcat :: [Mul a] -> Mul a # Storable a => Storable (Mul a) Source # MethodssizeOf :: Mul a -> Int #alignment :: Mul a -> Int #peekElemOff :: Ptr (Mul a) -> Int -> IO (Mul a) #pokeElemOff :: Ptr (Mul a) -> Int -> Mul a -> IO () #peekByteOff :: Ptr b -> Int -> IO (Mul a) #pokeByteOff :: Ptr b -> Int -> Mul a -> IO () #peek :: Ptr (Mul a) -> IO (Mul a) #poke :: Ptr (Mul a) -> Mul a -> IO () # Source # MethodsisZero :: Mul a -> Bool Source # StarSemiring a => StarSemiring (Mul a) Source # Methodsstar :: Mul a -> Mul a Source #plus :: Mul a -> Mul a Source # Semiring a => Semiring (Mul a) Source # Methods(<.>) :: Mul a -> Mul a -> Mul a Source #(<+>) :: Mul a -> Mul a -> Mul a Source #add :: [Mul a] -> Mul a Source #mul :: [Mul a] -> Mul a Source # type Rep1 Mul Source # type Rep1 Mul = D1 (MetaData "Mul" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Mul" PrefixI True) (S1 (MetaSel (Just Symbol "getMul") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1)) type Rep (Mul a) Source # type Rep (Mul a) = D1 (MetaData "Mul" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Mul" PrefixI True) (S1 (MetaSel (Just Symbol "getMul") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

# Ordering wrappers

newtype Max a Source #

The "Arctic" or max-plus semiring. It is a semiring where:

<+>  = max
zero = -∞
<.>  = <+>
one  = zero

Note that we can't use Max from Semigroup because annihilation needs to hold:

-∞ <+> x = x <+> -∞ = -∞

Taking -∞ to be minBound would break the above law. Using negativeInfinity to represent it follows the law.

Constructors

 Max FieldsgetMax :: a

Instances

 Source # Methodsfmap :: (a -> b) -> Max a -> Max b #(<) :: a -> Max b -> Max a # Source # Methodsfold :: Monoid m => Max m -> m #foldMap :: Monoid m => (a -> m) -> Max a -> m #foldr :: (a -> b -> b) -> b -> Max a -> b #foldr' :: (a -> b -> b) -> b -> Max a -> b #foldl :: (b -> a -> b) -> b -> Max a -> b #foldl' :: (b -> a -> b) -> b -> Max a -> b #foldr1 :: (a -> a -> a) -> Max a -> a #foldl1 :: (a -> a -> a) -> Max a -> a #toList :: Max a -> [a] #null :: Max a -> Bool #length :: Max a -> Int #elem :: Eq a => a -> Max a -> Bool #maximum :: Ord a => Max a -> a #minimum :: Ord a => Max a -> a #sum :: Num a => Max a -> a #product :: Num a => Max a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Max a -> f (Max b) #sequenceA :: Applicative f => Max (f a) -> f (Max a) #mapM :: Monad m => (a -> m b) -> Max a -> m (Max b) #sequence :: Monad m => Max (m a) -> m (Max a) # Source # Associated Typestype Rep1 (Max :: * -> *) :: * -> * # Methodsfrom1 :: Max a -> Rep1 Max a #to1 :: Rep1 Max a -> Max a # Source # MethodsliftEq :: (a -> b -> Bool) -> Max a -> Max b -> Bool # Source # MethodsliftCompare :: (a -> b -> Ordering) -> Max a -> Max b -> Ordering # Source # MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Max a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Max a] # Source # MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Max a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Max a] -> ShowS # Bounded a => Bounded (Max a) Source # MethodsminBound :: Max a #maxBound :: Max a # Enum a => Enum (Max a) Source # Methodssucc :: Max a -> Max a #pred :: Max a -> Max a #toEnum :: Int -> Max a #fromEnum :: Max a -> Int #enumFrom :: Max a -> [Max a] #enumFromThen :: Max a -> Max a -> [Max a] #enumFromTo :: Max a -> Max a -> [Max a] #enumFromThenTo :: Max a -> Max a -> Max a -> [Max a] # Eq a => Eq (Max a) Source # Methods(==) :: Max a -> Max a -> Bool #(/=) :: Max a -> Max a -> Bool # Fractional a => Fractional (Max a) Source # Methods(/) :: Max a -> Max a -> Max a #recip :: Max a -> Max a # Num a => Num (Max a) Source # Methods(+) :: Max a -> Max a -> Max a #(-) :: Max a -> Max a -> Max a #(*) :: Max a -> Max a -> Max a #negate :: Max a -> Max a #abs :: Max a -> Max a #signum :: Max a -> Max a # Ord a => Ord (Max a) Source # Methodscompare :: Max a -> Max a -> Ordering #(<) :: Max a -> Max a -> Bool #(<=) :: Max a -> Max a -> Bool #(>) :: Max a -> Max a -> Bool #(>=) :: Max a -> Max a -> Bool #max :: Max a -> Max a -> Max a #min :: Max a -> Max a -> Max a # Read a => Read (Max a) Source # MethodsreadsPrec :: Int -> ReadS (Max a) #readList :: ReadS [Max a] #readPrec :: ReadPrec (Max a) # Real a => Real (Max a) Source # MethodstoRational :: Max a -> Rational # RealFrac a => RealFrac (Max a) Source # MethodsproperFraction :: Integral b => Max a -> (b, Max a) #truncate :: Integral b => Max a -> b #round :: Integral b => Max a -> b #ceiling :: Integral b => Max a -> b #floor :: Integral b => Max a -> b # Show a => Show (Max a) Source # MethodsshowsPrec :: Int -> Max a -> ShowS #show :: Max a -> String #showList :: [Max a] -> ShowS # Generic (Max a) Source # Associated Typestype Rep (Max a) :: * -> * # Methodsfrom :: Max a -> Rep (Max a) x #to :: Rep (Max a) x -> Max a # Ord a => Semigroup (Max a) Source # Methods(<>) :: Max a -> Max a -> Max a #sconcat :: NonEmpty (Max a) -> Max a #stimes :: Integral b => b -> Max a -> Max a # (Ord a, HasNegativeInfinity a) => Monoid (Max a) Source # >>> (getMax . foldMap Max) [1..10] 10.0  Methodsmempty :: Max a #mappend :: Max a -> Max a -> Max a #mconcat :: [Max a] -> Max a # Storable a => Storable (Max a) Source # MethodssizeOf :: Max a -> Int #alignment :: Max a -> Int #peekElemOff :: Ptr (Max a) -> Int -> IO (Max a) #pokeElemOff :: Ptr (Max a) -> Int -> Max a -> IO () #peekByteOff :: Ptr b -> Int -> IO (Max a) #pokeByteOff :: Ptr b -> Int -> Max a -> IO () #peek :: Ptr (Max a) -> IO (Max a) #poke :: Ptr (Max a) -> Max a -> IO () # (Semiring a, Ord a, HasNegativeInfinity a) => DetectableZero (Max a) Source # MethodsisZero :: Max a -> Bool Source # Source # Methodsstar :: Max a -> Max a Source #plus :: Max a -> Max a Source # (Semiring a, Ord a, HasNegativeInfinity a) => Semiring (Max a) Source # Methods(<.>) :: Max a -> Max a -> Max a Source #(<+>) :: Max a -> Max a -> Max a Source #add :: [Max a] -> Max a Source #mul :: [Max a] -> Max a Source # type Rep1 Max Source # type Rep1 Max = D1 (MetaData "Max" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Max" PrefixI True) (S1 (MetaSel (Just Symbol "getMax") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1)) type Rep (Max a) Source # type Rep (Max a) = D1 (MetaData "Max" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Max" PrefixI True) (S1 (MetaSel (Just Symbol "getMax") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) newtype Min a Source # The "Tropical" or min-plus semiring. It is a semiring where: <+> = min zero = ∞ <.> = <+> one = zero Note that we can't use Min from Semigroup because annihilation needs to hold: ∞ <+> x = x <+> ∞ = ∞ Taking ∞ to be maxBound would break the above law. Using positiveInfinity to represent it follows the law. Constructors  Min FieldsgetMin :: a Instances  Source # Methodsfmap :: (a -> b) -> Min a -> Min b #(<) :: a -> Min b -> Min a # Source # Methodsfold :: Monoid m => Min m -> m #foldMap :: Monoid m => (a -> m) -> Min a -> m #foldr :: (a -> b -> b) -> b -> Min a -> b #foldr' :: (a -> b -> b) -> b -> Min a -> b #foldl :: (b -> a -> b) -> b -> Min a -> b #foldl' :: (b -> a -> b) -> b -> Min a -> b #foldr1 :: (a -> a -> a) -> Min a -> a #foldl1 :: (a -> a -> a) -> Min a -> a #toList :: Min a -> [a] #null :: Min a -> Bool #length :: Min a -> Int #elem :: Eq a => a -> Min a -> Bool #maximum :: Ord a => Min a -> a #minimum :: Ord a => Min a -> a #sum :: Num a => Min a -> a #product :: Num a => Min a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Min a -> f (Min b) #sequenceA :: Applicative f => Min (f a) -> f (Min a) #mapM :: Monad m => (a -> m b) -> Min a -> m (Min b) #sequence :: Monad m => Min (m a) -> m (Min a) # Source # Associated Typestype Rep1 (Min :: * -> *) :: * -> * # Methodsfrom1 :: Min a -> Rep1 Min a #to1 :: Rep1 Min a -> Min a # Source # MethodsliftEq :: (a -> b -> Bool) -> Min a -> Min b -> Bool # Source # MethodsliftCompare :: (a -> b -> Ordering) -> Min a -> Min b -> Ordering # Source # MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Min a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Min a] # Source # MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Min a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Min a] -> ShowS # Bounded a => Bounded (Min a) Source # MethodsminBound :: Min a #maxBound :: Min a # Enum a => Enum (Min a) Source # Methodssucc :: Min a -> Min a #pred :: Min a -> Min a #toEnum :: Int -> Min a #fromEnum :: Min a -> Int #enumFrom :: Min a -> [Min a] #enumFromThen :: Min a -> Min a -> [Min a] #enumFromTo :: Min a -> Min a -> [Min a] #enumFromThenTo :: Min a -> Min a -> Min a -> [Min a] # Eq a => Eq (Min a) Source # Methods(==) :: Min a -> Min a -> Bool #(/=) :: Min a -> Min a -> Bool # Fractional a => Fractional (Min a) Source # Methods(/) :: Min a -> Min a -> Min a #recip :: Min a -> Min a # Num a => Num (Min a) Source # Methods(+) :: Min a -> Min a -> Min a #(-) :: Min a -> Min a -> Min a #(*) :: Min a -> Min a -> Min a #negate :: Min a -> Min a #abs :: Min a -> Min a #signum :: Min a -> Min a # Ord a => Ord (Min a) Source # Methodscompare :: Min a -> Min a -> Ordering #(<) :: Min a -> Min a -> Bool #(<=) :: Min a -> Min a -> Bool #(>) :: Min a -> Min a -> Bool #(>=) :: Min a -> Min a -> Bool #max :: Min a -> Min a -> Min a #min :: Min a -> Min a -> Min a # Read a => Read (Min a) Source # MethodsreadsPrec :: Int -> ReadS (Min a) #readList :: ReadS [Min a] #readPrec :: ReadPrec (Min a) # Real a => Real (Min a) Source # MethodstoRational :: Min a -> Rational # RealFrac a => RealFrac (Min a) Source # MethodsproperFraction :: Integral b => Min a -> (b, Min a) #truncate :: Integral b => Min a -> b #round :: Integral b => Min a -> b #ceiling :: Integral b => Min a -> b #floor :: Integral b => Min a -> b # Show a => Show (Min a) Source # MethodsshowsPrec :: Int -> Min a -> ShowS #show :: Min a -> String #showList :: [Min a] -> ShowS # Generic (Min a) Source # Associated Typestype Rep (Min a) :: * -> * # Methodsfrom :: Min a -> Rep (Min a) x #to :: Rep (Min a) x -> Min a # Ord a => Semigroup (Min a) Source # Methods(<>) :: Min a -> Min a -> Min a #sconcat :: NonEmpty (Min a) -> Min a #stimes :: Integral b => b -> Min a -> Min a # (Ord a, HasPositiveInfinity a) => Monoid (Min a) Source # >>> (getMin . foldMap Min) [1..10] 1.0  Methodsmempty :: Min a #mappend :: Min a -> Min a -> Min a #mconcat :: [Min a] -> Min a # Storable a => Storable (Min a) Source # MethodssizeOf :: Min a -> Int #alignment :: Min a -> Int #peekElemOff :: Ptr (Min a) -> Int -> IO (Min a) #pokeElemOff :: Ptr (Min a) -> Int -> Min a -> IO () #peekByteOff :: Ptr b -> Int -> IO (Min a) #pokeByteOff :: Ptr b -> Int -> Min a -> IO () #peek :: Ptr (Min a) -> IO (Min a) #poke :: Ptr (Min a) -> Min a -> IO () # (Semiring a, Ord a, HasPositiveInfinity a) => DetectableZero (Min a) Source # MethodsisZero :: Min a -> Bool Source # Source # Methodsstar :: Min a -> Min a Source #plus :: Min a -> Min a Source # (Semiring a, Ord a, HasPositiveInfinity a) => Semiring (Min a) Source # Methods(<.>) :: Min a -> Min a -> Min a Source #(<+>) :: Min a -> Min a -> Min a Source #add :: [Min a] -> Min a Source #mul :: [Min a] -> Min a Source # type Rep1 Min Source # type Rep1 Min = D1 (MetaData "Min" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Min" PrefixI True) (S1 (MetaSel (Just Symbol "getMin") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1)) type Rep (Min a) Source # type Rep (Min a) = D1 (MetaData "Min" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Min" PrefixI True) (S1 (MetaSel (Just Symbol "getMin") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

# Matrix wrapper

newtype Matrix f g a Source #

A suitable definition of a square matrix for certain types which are both Applicative and Traversable. For instance, given a type like so:

>>> :{
data Quad a = Quad a a a a deriving Show
fmap f (Quad w x y z) = Quad (f w) (f x) (f y) (f z)
pure x = Quad x x x x
Quad fw fx fy fz <*> Quad xw xx xy xz =
Quad (fw xw) (fx xx) (fy xy) (fz xz)
traverse f (Quad w x y z) = Quad <$> f w <*> f x <*> f y <*> f z :}  The newtype performs as you would expect: >>> getMatrix one :: Quad (Quad Integer) Quad (Quad 1 0 0 0) (Quad 0 1 0 0) (Quad 0 0 1 0) (Quad 0 0 0 1)  ZipLists are another type which works with this newtype: >>> :{ let xs = (Matrix . ZipList . map ZipList) [[1,2],[3,4]] ys = (Matrix . ZipList . map ZipList) [[5,6],[7,8]] in (map getZipList . getZipList . getMatrix) (xs <.> ys) :} [[19,22],[43,50]]  Constructors  Matrix FieldsgetMatrix :: f (g a) Instances  (Functor g, Functor f) => Functor (Matrix f g) Source # Methodsfmap :: (a -> b) -> Matrix f g a -> Matrix f g b #(<$) :: a -> Matrix f g b -> Matrix f g a # (Applicative f, Applicative g) => Applicative (Matrix f g) Source # Methodspure :: a -> Matrix f g a #(<*>) :: Matrix f g (a -> b) -> Matrix f g a -> Matrix f g b #(*>) :: Matrix f g a -> Matrix f g b -> Matrix f g b #(<*) :: Matrix f g a -> Matrix f g b -> Matrix f g a # (Foldable g, Foldable f) => Foldable (Matrix f g) Source # Methodsfold :: Monoid m => Matrix f g m -> m #foldMap :: Monoid m => (a -> m) -> Matrix f g a -> m #foldr :: (a -> b -> b) -> b -> Matrix f g a -> b #foldr' :: (a -> b -> b) -> b -> Matrix f g a -> b #foldl :: (b -> a -> b) -> b -> Matrix f g a -> b #foldl' :: (b -> a -> b) -> b -> Matrix f g a -> b #foldr1 :: (a -> a -> a) -> Matrix f g a -> a #foldl1 :: (a -> a -> a) -> Matrix f g a -> a #toList :: Matrix f g a -> [a] #null :: Matrix f g a -> Bool #length :: Matrix f g a -> Int #elem :: Eq a => a -> Matrix f g a -> Bool #maximum :: Ord a => Matrix f g a -> a #minimum :: Ord a => Matrix f g a -> a #sum :: Num a => Matrix f g a -> a #product :: Num a => Matrix f g a -> a # (Traversable g, Traversable f) => Traversable (Matrix f g) Source # Methodstraverse :: Applicative f => (a -> f b) -> Matrix f g a -> f (Matrix f g b) #sequenceA :: Applicative f => Matrix f g (f a) -> f (Matrix f g a) #mapM :: Monad m => (a -> m b) -> Matrix f g a -> m (Matrix f g b) #sequence :: Monad m => Matrix f g (m a) -> m (Matrix f g a) # Functor f => Generic1 (Matrix f g) Source # Associated Typestype Rep1 (Matrix f g :: * -> *) :: * -> * # Methodsfrom1 :: Matrix f g a -> Rep1 (Matrix f g) a #to1 :: Rep1 (Matrix f g) a -> Matrix f g a # (Eq1 f, Eq1 g) => Eq1 (Matrix f g) Source # MethodsliftEq :: (a -> b -> Bool) -> Matrix f g a -> Matrix f g b -> Bool # (Ord1 f, Ord1 g) => Ord1 (Matrix f g) Source # MethodsliftCompare :: (a -> b -> Ordering) -> Matrix f g a -> Matrix f g b -> Ordering # (Read1 f, Read1 g) => Read1 (Matrix f g) Source # MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Matrix f g a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Matrix f g a] # (Show1 f, Show1 g) => Show1 (Matrix f g) Source # MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Matrix f g a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Matrix f g a] -> ShowS # (Eq1 f, Eq1 g, Eq a) => Eq (Matrix f g a) Source # Methods(==) :: Matrix f g a -> Matrix f g a -> Bool #(/=) :: Matrix f g a -> Matrix f g a -> Bool # (Ord1 f, Ord1 g, Ord a) => Ord (Matrix f g a) Source # Methodscompare :: Matrix f g a -> Matrix f g a -> Ordering #(<) :: Matrix f g a -> Matrix f g a -> Bool #(<=) :: Matrix f g a -> Matrix f g a -> Bool #(>) :: Matrix f g a -> Matrix f g a -> Bool #(>=) :: Matrix f g a -> Matrix f g a -> Bool #max :: Matrix f g a -> Matrix f g a -> Matrix f g a #min :: Matrix f g a -> Matrix f g a -> Matrix f g a # (Read1 f, Read1 g, Read a) => Read (Matrix f g a) Source # MethodsreadsPrec :: Int -> ReadS (Matrix f g a) #readList :: ReadS [Matrix f g a] #readPrec :: ReadPrec (Matrix f g a) #readListPrec :: ReadPrec [Matrix f g a] # (Show1 f, Show1 g, Show a) => Show (Matrix f g a) Source # MethodsshowsPrec :: Int -> Matrix f g a -> ShowS #show :: Matrix f g a -> String #showList :: [Matrix f g a] -> ShowS # Generic (Matrix f g a) Source # Associated Typestype Rep (Matrix f g a) :: * -> * # Methodsfrom :: Matrix f g a -> Rep (Matrix f g a) x #to :: Rep (Matrix f g a) x -> Matrix f g a # (Traversable f, Applicative f, DetectableZero a, (~) (* -> *) f g) => DetectableZero (Matrix f g a) Source # MethodsisZero :: Matrix f g a -> Bool Source # (Traversable f, Applicative f, Semiring a, (~) (* -> *) f g) => Semiring (Matrix f g a) Source # Methodszero :: Matrix f g a Source #one :: Matrix f g a Source #(<.>) :: Matrix f g a -> Matrix f g a -> Matrix f g a Source #(<+>) :: Matrix f g a -> Matrix f g a -> Matrix f g a Source #add :: [Matrix f g a] -> Matrix f g a Source #mul :: [Matrix f g a] -> Matrix f g a Source # type Rep1 (Matrix f g) Source # type Rep1 (Matrix f g) = D1 (MetaData "Matrix" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Matrix" PrefixI True) (S1 (MetaSel (Just Symbol "getMatrix") NoSourceUnpackedness NoSourceStrictness DecidedLazy) ((:.:) f (Rec1 g)))) type Rep (Matrix f g a) Source # type Rep (Matrix f g a) = D1 (MetaData "Matrix" "Data.Semiring" "semiring-num-1.5.0.0-7WC5M2HPXUuCt66nvPVZ1R" True) (C1 (MetaCons "Matrix" PrefixI True) (S1 (MetaSel (Just Symbol "getMatrix") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f (g a)))))