SciBaseTypes-0.1.0.0: Base types and classes for statistics, sciences and humanities

Safe HaskellNone
LanguageHaskell2010

Algebra.Structure.Semiring

Contents

Description

A set with two binary operations, one for addition (srplus), one for multiplication (srmul). Together with a neutral element for srplus, named srzero, and one for srmul, named srone.

Synopsis

Documentation

pattern V_Viterbi :: (Vector x) -> Vector (Viterbi x) Source #

pattern V_MinPlus :: (Vector x) -> Vector (MinPlus x) Source #

pattern V_MaxPlus :: (Vector x) -> Vector (MaxPlus x) Source #

pattern MV_Viterbi :: (MVector s x) -> MVector s (Viterbi x) Source #

pattern MV_MinPlus :: (MVector s x) -> MVector s (MinPlus x) Source #

pattern MV_MaxPlus :: (MVector s x) -> MVector s (MaxPlus x) Source #

newtype Viterbi x Source #

The Viterbi SemiRing. It maximizes over the product.

Constructors

Viterbi 

Fields

Instances
Unbox x => Vector Vector (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Unbox x => MVector MVector (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Bounded x => Bounded (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Eq x => Eq (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

(==) :: Viterbi x -> Viterbi x -> Bool #

(/=) :: Viterbi x -> Viterbi x -> Bool #

Num x => Num (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

(+) :: Viterbi x -> Viterbi x -> Viterbi x #

(-) :: Viterbi x -> Viterbi x -> Viterbi x #

(*) :: Viterbi x -> Viterbi x -> Viterbi x #

negate :: Viterbi x -> Viterbi x #

abs :: Viterbi x -> Viterbi x #

signum :: Viterbi x -> Viterbi x #

fromInteger :: Integer -> Viterbi x #

Ord x => Ord (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

compare :: Viterbi x -> Viterbi x -> Ordering #

(<) :: Viterbi x -> Viterbi x -> Bool #

(<=) :: Viterbi x -> Viterbi x -> Bool #

(>) :: Viterbi x -> Viterbi x -> Bool #

(>=) :: Viterbi x -> Viterbi x -> Bool #

max :: Viterbi x -> Viterbi x -> Viterbi x #

min :: Viterbi x -> Viterbi x -> Viterbi x #

Read x => Read (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Show x => Show (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

showsPrec :: Int -> Viterbi x -> ShowS #

show :: Viterbi x -> String #

showList :: [Viterbi x] -> ShowS #

Generic (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Associated Types

type Rep (Viterbi x) :: Type -> Type #

Methods

from :: Viterbi x -> Rep (Viterbi x) x0 #

to :: Rep (Viterbi x) x0 -> Viterbi x #

NFData x => NFData (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

rnf :: Viterbi x -> () #

Unbox x => Unbox (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

(Ord x, Semiring x) => Semiring (Viterbi x) Source #

TODO Shall we have generic instances, or specific ones like SemiRing (Viterbi Prob)?

TODO Consider either a constraint ProbLike x or the above.

Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: Viterbi x -> Viterbi x -> Viterbi x #

zero :: Viterbi x #

times :: Viterbi x -> Viterbi x -> Viterbi x #

one :: Viterbi x #

Generic1 Viterbi Source # 
Instance details

Defined in Algebra.Structure.Semiring

Associated Types

type Rep1 Viterbi :: k -> Type #

Methods

from1 :: Viterbi a -> Rep1 Viterbi a #

to1 :: Rep1 Viterbi a -> Viterbi a #

newtype MVector s (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

newtype MVector s (Viterbi x) = MV_Viterbi (MVector s x)
type Rep (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

type Rep (Viterbi x) = D1 (MetaData "Viterbi" "Algebra.Structure.Semiring" "SciBaseTypes-0.1.0.0-8v1Wd4dQxf86ztFKnvLSrc" True) (C1 (MetaCons "Viterbi" PrefixI True) (S1 (MetaSel (Just "getViterbi") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))
newtype Vector (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

newtype Vector (Viterbi x) = V_Viterbi (Vector x)
type Rep1 Viterbi Source # 
Instance details

Defined in Algebra.Structure.Semiring

type Rep1 Viterbi = D1 (MetaData "Viterbi" "Algebra.Structure.Semiring" "SciBaseTypes-0.1.0.0-8v1Wd4dQxf86ztFKnvLSrc" True) (C1 (MetaCons "Viterbi" PrefixI True) (S1 (MetaSel (Just "getViterbi") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

(⊕) :: Semiring a => a -> a -> a infixl 6 Source #

Unicode variant of srplus.

(⊗) :: Semiring a => a -> a -> a infixl 7 Source #

Unicode variant of srmul.

newtype MinPlus x Source #

The tropical MinPlus SemiRing. It minimizes over the sum.

Constructors

MinPlus 

Fields

Instances
Unbox x => Vector Vector (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Unbox x => MVector MVector (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Bounded x => Bounded (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Eq x => Eq (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

(==) :: MinPlus x -> MinPlus x -> Bool #

(/=) :: MinPlus x -> MinPlus x -> Bool #

Num x => Num (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

(+) :: MinPlus x -> MinPlus x -> MinPlus x #

(-) :: MinPlus x -> MinPlus x -> MinPlus x #

(*) :: MinPlus x -> MinPlus x -> MinPlus x #

negate :: MinPlus x -> MinPlus x #

abs :: MinPlus x -> MinPlus x #

signum :: MinPlus x -> MinPlus x #

fromInteger :: Integer -> MinPlus x #

Ord x => Ord (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

compare :: MinPlus x -> MinPlus x -> Ordering #

(<) :: MinPlus x -> MinPlus x -> Bool #

(<=) :: MinPlus x -> MinPlus x -> Bool #

(>) :: MinPlus x -> MinPlus x -> Bool #

(>=) :: MinPlus x -> MinPlus x -> Bool #

max :: MinPlus x -> MinPlus x -> MinPlus x #

min :: MinPlus x -> MinPlus x -> MinPlus x #

Read x => Read (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Show x => Show (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

showsPrec :: Int -> MinPlus x -> ShowS #

show :: MinPlus x -> String #

showList :: [MinPlus x] -> ShowS #

Generic (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Associated Types

type Rep (MinPlus x) :: Type -> Type #

Methods

from :: MinPlus x -> Rep (MinPlus x) x0 #

to :: Rep (MinPlus x) x0 -> MinPlus x #

NFData x => NFData (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

rnf :: MinPlus x -> () #

Unbox x => Unbox (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

(Ord x, Semiring x, NumericLimits x) => Semiring (MinPlus x) Source #

Be careful, if the numeric limits are hits, underflows, etc will happen.

Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: MinPlus x -> MinPlus x -> MinPlus x #

zero :: MinPlus x #

times :: MinPlus x -> MinPlus x -> MinPlus x #

one :: MinPlus x #

NumericLimits x => NumericLimits (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Generic1 MinPlus Source # 
Instance details

Defined in Algebra.Structure.Semiring

Associated Types

type Rep1 MinPlus :: k -> Type #

Methods

from1 :: MinPlus a -> Rep1 MinPlus a #

to1 :: Rep1 MinPlus a -> MinPlus a #

newtype MVector s (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

newtype MVector s (MinPlus x) = MV_MinPlus (MVector s x)
type Rep (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

type Rep (MinPlus x) = D1 (MetaData "MinPlus" "Algebra.Structure.Semiring" "SciBaseTypes-0.1.0.0-8v1Wd4dQxf86ztFKnvLSrc" True) (C1 (MetaCons "MinPlus" PrefixI True) (S1 (MetaSel (Just "getMinPlus") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))
newtype Vector (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

newtype Vector (MinPlus x) = V_MinPlus (Vector x)
type Rep1 MinPlus Source # 
Instance details

Defined in Algebra.Structure.Semiring

type Rep1 MinPlus = D1 (MetaData "MinPlus" "Algebra.Structure.Semiring" "SciBaseTypes-0.1.0.0-8v1Wd4dQxf86ztFKnvLSrc" True) (C1 (MetaCons "MinPlus" PrefixI True) (S1 (MetaSel (Just "getMinPlus") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

newtype MaxPlus x Source #

The tropical MaxPlus SemiRing. It maximizes over the sum.

Constructors

MaxPlus 

Fields

Instances
Unbox x => Vector Vector (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Unbox x => MVector MVector (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Bounded x => Bounded (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Eq x => Eq (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

(==) :: MaxPlus x -> MaxPlus x -> Bool #

(/=) :: MaxPlus x -> MaxPlus x -> Bool #

Num x => Num (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

(+) :: MaxPlus x -> MaxPlus x -> MaxPlus x #

(-) :: MaxPlus x -> MaxPlus x -> MaxPlus x #

(*) :: MaxPlus x -> MaxPlus x -> MaxPlus x #

negate :: MaxPlus x -> MaxPlus x #

abs :: MaxPlus x -> MaxPlus x #

signum :: MaxPlus x -> MaxPlus x #

fromInteger :: Integer -> MaxPlus x #

Ord x => Ord (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

compare :: MaxPlus x -> MaxPlus x -> Ordering #

(<) :: MaxPlus x -> MaxPlus x -> Bool #

(<=) :: MaxPlus x -> MaxPlus x -> Bool #

(>) :: MaxPlus x -> MaxPlus x -> Bool #

(>=) :: MaxPlus x -> MaxPlus x -> Bool #

max :: MaxPlus x -> MaxPlus x -> MaxPlus x #

min :: MaxPlus x -> MaxPlus x -> MaxPlus x #

Read x => Read (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Show x => Show (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

showsPrec :: Int -> MaxPlus x -> ShowS #

show :: MaxPlus x -> String #

showList :: [MaxPlus x] -> ShowS #

Generic (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Associated Types

type Rep (MaxPlus x) :: Type -> Type #

Methods

from :: MaxPlus x -> Rep (MaxPlus x) x0 #

to :: Rep (MaxPlus x) x0 -> MaxPlus x #

NFData x => NFData (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

rnf :: MaxPlus x -> () #

Unbox x => Unbox (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

(Ord x, Semiring x, NumericLimits x) => Semiring (MaxPlus x) Source #

TODO Shall we have generic instances, or specific ones like SemiRing (Viterbi Prob)?

TODO Consider either a constraint ProbLike x or the above.

Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: MaxPlus x -> MaxPlus x -> MaxPlus x #

zero :: MaxPlus x #

times :: MaxPlus x -> MaxPlus x -> MaxPlus x #

one :: MaxPlus x #

NumericLimits x => NumericLimits (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Generic1 MaxPlus Source # 
Instance details

Defined in Algebra.Structure.Semiring

Associated Types

type Rep1 MaxPlus :: k -> Type #

Methods

from1 :: MaxPlus a -> Rep1 MaxPlus a #

to1 :: Rep1 MaxPlus a -> MaxPlus a #

newtype MVector s (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

newtype MVector s (MaxPlus x) = MV_MaxPlus (MVector s x)
type Rep (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

type Rep (MaxPlus x) = D1 (MetaData "MaxPlus" "Algebra.Structure.Semiring" "SciBaseTypes-0.1.0.0-8v1Wd4dQxf86ztFKnvLSrc" True) (C1 (MetaCons "MaxPlus" PrefixI True) (S1 (MetaSel (Just "getMaxPlus") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))
newtype Vector (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

newtype Vector (MaxPlus x) = V_MaxPlus (Vector x)
type Rep1 MaxPlus Source # 
Instance details

Defined in Algebra.Structure.Semiring

type Rep1 MaxPlus = D1 (MetaData "MaxPlus" "Algebra.Structure.Semiring" "SciBaseTypes-0.1.0.0-8v1Wd4dQxf86ztFKnvLSrc" True) (C1 (MetaCons "MaxPlus" PrefixI True) (S1 (MetaSel (Just "getMaxPlus") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

newtype GSemiring (zeroMonoid :: * -> *) (oneMonoid :: * -> *) (x :: *) Source #

The generic semiring, defined over two Semigroup and Monoid constructions.

It can be used like this: zero ∷ GSemiring Min Sum Int == maxBound one ∷ GSemiring Min Sum Int == 0

It is generally useful to still provide explicit instances, since Min requires a Bounded instance.

Constructors

GSemiring 

Fields

Instances
Eq x => Eq (GSemiring zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

(==) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool #

(/=) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool #

Ord x => Ord (GSemiring zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

compare :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Ordering #

(<) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool #

(<=) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool #

(>) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool #

(>=) :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> Bool #

max :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x #

min :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x #

Read x => Read (GSemiring zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

readsPrec :: Int -> ReadS (GSemiring zeroMonoid oneMonoid x) #

readList :: ReadS [GSemiring zeroMonoid oneMonoid x] #

readPrec :: ReadPrec (GSemiring zeroMonoid oneMonoid x) #

readListPrec :: ReadPrec [GSemiring zeroMonoid oneMonoid x] #

Show x => Show (GSemiring zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

showsPrec :: Int -> GSemiring zeroMonoid oneMonoid x -> ShowS #

show :: GSemiring zeroMonoid oneMonoid x -> String #

showList :: [GSemiring zeroMonoid oneMonoid x] -> ShowS #

Generic (GSemiring zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Associated Types

type Rep (GSemiring zeroMonoid oneMonoid x) :: Type -> Type #

Methods

from :: GSemiring zeroMonoid oneMonoid x -> Rep (GSemiring zeroMonoid oneMonoid x) x0 #

to :: Rep (GSemiring zeroMonoid oneMonoid x) x0 -> GSemiring zeroMonoid oneMonoid x #

(Semigroup (zeroMonoid x), Monoid (zeroMonoid x), Semigroup (oneMonoid x), Monoid (oneMonoid x), Coercible (zeroMonoid x) (GSemiring zeroMonoid oneMonoid x), Coercible (oneMonoid x) (GSemiring zeroMonoid oneMonoid x)) => Semiring (GSemiring zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x #

zero :: GSemiring zeroMonoid oneMonoid x #

times :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x #

one :: GSemiring zeroMonoid oneMonoid x #

type Rep (GSemiring zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

type Rep (GSemiring zeroMonoid oneMonoid x) = D1 (MetaData "GSemiring" "Algebra.Structure.Semiring" "SciBaseTypes-0.1.0.0-8v1Wd4dQxf86ztFKnvLSrc" True) (C1 (MetaCons "GSemiring" PrefixI True) (S1 (MetaSel (Just "getSemiring") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))

class Semiring a where #

The class of semirings (types with two binary operations and two respective identities). One can think of a semiring as two monoids of the same underlying type, with the first being commutative. In the documentation, you will often see the first monoid being referred to as additive, and the second monoid being referred to as multiplicative, a typical convention when talking about semirings.

For any type R with a Num instance, the additive monoid is (R, '(Prelude.+)', 0) and the multiplicative monoid is (R, '(Prelude.*)', 1).

For Bool, the additive monoid is (Bool, ||, False) and the multiplicative monoid is (Bool, &&, True).

Instances should satisfy the following laws:

additive identity
x + zero = zero + x = x
additive associativity
x + (y + z) = (x + y) + z
additive commutativity
x + y = y + x
multiplicative identity
x * one = one * x = x
multiplicative associativity
x * (y * z) = (x * y) * z
left- and right-distributivity of * over +
x * (y + z) = (x * y) + (x * z) (x + y) * z = (x * z) + (y * z)
annihilation
zero * x = x * zero = zero

Methods

plus infixl 6 #

Arguments

:: a 
-> a 
-> a

Commutative Operation

zero #

Arguments

:: a

Commutative Unit

times infixl 7 #

Arguments

:: a 
-> a 
-> a

Associative Operation

one #

Arguments

:: a

Associative Unit

Instances
Semiring Bool 
Instance details

Defined in Data.Semiring

Methods

plus :: Bool -> Bool -> Bool #

zero :: Bool #

times :: Bool -> Bool -> Bool #

one :: Bool #

Semiring Double 
Instance details

Defined in Data.Semiring

Semiring Float 
Instance details

Defined in Data.Semiring

Methods

plus :: Float -> Float -> Float #

zero :: Float #

times :: Float -> Float -> Float #

one :: Float #

Semiring Int 
Instance details

Defined in Data.Semiring

Methods

plus :: Int -> Int -> Int #

zero :: Int #

times :: Int -> Int -> Int #

one :: Int #

Semiring Int8 
Instance details

Defined in Data.Semiring

Methods

plus :: Int8 -> Int8 -> Int8 #

zero :: Int8 #

times :: Int8 -> Int8 -> Int8 #

one :: Int8 #

Semiring Int16 
Instance details

Defined in Data.Semiring

Methods

plus :: Int16 -> Int16 -> Int16 #

zero :: Int16 #

times :: Int16 -> Int16 -> Int16 #

one :: Int16 #

Semiring Int32 
Instance details

Defined in Data.Semiring

Methods

plus :: Int32 -> Int32 -> Int32 #

zero :: Int32 #

times :: Int32 -> Int32 -> Int32 #

one :: Int32 #

Semiring Int64 
Instance details

Defined in Data.Semiring

Methods

plus :: Int64 -> Int64 -> Int64 #

zero :: Int64 #

times :: Int64 -> Int64 -> Int64 #

one :: Int64 #

Semiring Integer 
Instance details

Defined in Data.Semiring

Semiring Natural 
Instance details

Defined in Data.Semiring

Semiring Word 
Instance details

Defined in Data.Semiring

Methods

plus :: Word -> Word -> Word #

zero :: Word #

times :: Word -> Word -> Word #

one :: Word #

Semiring Word8 
Instance details

Defined in Data.Semiring

Methods

plus :: Word8 -> Word8 -> Word8 #

zero :: Word8 #

times :: Word8 -> Word8 -> Word8 #

one :: Word8 #

Semiring Word16 
Instance details

Defined in Data.Semiring

Semiring Word32 
Instance details

Defined in Data.Semiring

Semiring Word64 
Instance details

Defined in Data.Semiring

Semiring () 
Instance details

Defined in Data.Semiring

Methods

plus :: () -> () -> () #

zero :: () #

times :: () -> () -> () #

one :: () #

Semiring CDev 
Instance details

Defined in Data.Semiring

Methods

plus :: CDev -> CDev -> CDev #

zero :: CDev #

times :: CDev -> CDev -> CDev #

one :: CDev #

Semiring CIno 
Instance details

Defined in Data.Semiring

Methods

plus :: CIno -> CIno -> CIno #

zero :: CIno #

times :: CIno -> CIno -> CIno #

one :: CIno #

Semiring CMode 
Instance details

Defined in Data.Semiring

Methods

plus :: CMode -> CMode -> CMode #

zero :: CMode #

times :: CMode -> CMode -> CMode #

one :: CMode #

Semiring COff 
Instance details

Defined in Data.Semiring

Methods

plus :: COff -> COff -> COff #

zero :: COff #

times :: COff -> COff -> COff #

one :: COff #

Semiring CPid 
Instance details

Defined in Data.Semiring

Methods

plus :: CPid -> CPid -> CPid #

zero :: CPid #

times :: CPid -> CPid -> CPid #

one :: CPid #

Semiring CSsize 
Instance details

Defined in Data.Semiring

Semiring CGid 
Instance details

Defined in Data.Semiring

Methods

plus :: CGid -> CGid -> CGid #

zero :: CGid #

times :: CGid -> CGid -> CGid #

one :: CGid #

Semiring CNlink 
Instance details

Defined in Data.Semiring

Semiring CUid 
Instance details

Defined in Data.Semiring

Methods

plus :: CUid -> CUid -> CUid #

zero :: CUid #

times :: CUid -> CUid -> CUid #

one :: CUid #

Semiring CCc 
Instance details

Defined in Data.Semiring

Methods

plus :: CCc -> CCc -> CCc #

zero :: CCc #

times :: CCc -> CCc -> CCc #

one :: CCc #

Semiring CSpeed 
Instance details

Defined in Data.Semiring

Semiring CTcflag 
Instance details

Defined in Data.Semiring

Semiring CRLim 
Instance details

Defined in Data.Semiring

Methods

plus :: CRLim -> CRLim -> CRLim #

zero :: CRLim #

times :: CRLim -> CRLim -> CRLim #

one :: CRLim #

Semiring Fd 
Instance details

Defined in Data.Semiring

Methods

plus :: Fd -> Fd -> Fd #

zero :: Fd #

times :: Fd -> Fd -> Fd #

one :: Fd #

Semiring CChar 
Instance details

Defined in Data.Semiring

Methods

plus :: CChar -> CChar -> CChar #

zero :: CChar #

times :: CChar -> CChar -> CChar #

one :: CChar #

Semiring CSChar 
Instance details

Defined in Data.Semiring

Semiring CUChar 
Instance details

Defined in Data.Semiring

Semiring CShort 
Instance details

Defined in Data.Semiring

Semiring CUShort 
Instance details

Defined in Data.Semiring

Semiring CInt 
Instance details

Defined in Data.Semiring

Methods

plus :: CInt -> CInt -> CInt #

zero :: CInt #

times :: CInt -> CInt -> CInt #

one :: CInt #

Semiring CUInt 
Instance details

Defined in Data.Semiring

Methods

plus :: CUInt -> CUInt -> CUInt #

zero :: CUInt #

times :: CUInt -> CUInt -> CUInt #

one :: CUInt #

Semiring CLong 
Instance details

Defined in Data.Semiring

Methods

plus :: CLong -> CLong -> CLong #

zero :: CLong #

times :: CLong -> CLong -> CLong #

one :: CLong #

Semiring CULong 
Instance details

Defined in Data.Semiring

Semiring CLLong 
Instance details

Defined in Data.Semiring

Semiring CULLong 
Instance details

Defined in Data.Semiring

Semiring CFloat 
Instance details

Defined in Data.Semiring

Semiring CDouble 
Instance details

Defined in Data.Semiring

Semiring CPtrdiff 
Instance details

Defined in Data.Semiring

Semiring CSize 
Instance details

Defined in Data.Semiring

Methods

plus :: CSize -> CSize -> CSize #

zero :: CSize #

times :: CSize -> CSize -> CSize #

one :: CSize #

Semiring CWchar 
Instance details

Defined in Data.Semiring

Semiring CSigAtomic 
Instance details

Defined in Data.Semiring

Semiring CClock 
Instance details

Defined in Data.Semiring

Semiring CTime 
Instance details

Defined in Data.Semiring

Methods

plus :: CTime -> CTime -> CTime #

zero :: CTime #

times :: CTime -> CTime -> CTime #

one :: CTime #

Semiring CUSeconds 
Instance details

Defined in Data.Semiring

Semiring CSUSeconds 
Instance details

Defined in Data.Semiring

Semiring CIntPtr 
Instance details

Defined in Data.Semiring

Semiring CUIntPtr 
Instance details

Defined in Data.Semiring

Semiring CIntMax 
Instance details

Defined in Data.Semiring

Semiring CUIntMax 
Instance details

Defined in Data.Semiring

Semiring WordPtr 
Instance details

Defined in Data.Semiring

Semiring IntPtr 
Instance details

Defined in Data.Semiring

Semiring Odds Source # 
Instance details

Defined in Statistics.Odds

Methods

plus :: Odds -> Odds -> Odds #

zero :: Odds #

times :: Odds -> Odds -> Odds #

one :: Odds #

Semiring a => Semiring [a]

The Semiring instance for '[a]' can be interpreted as treating each element of the list as coefficients to a polynomial in one variable.

Examples

Expand

poly1 = [1,2,3] :: [Int] poly2 = [ 2,1] :: [Int] poly1 * poly2 = [2,5,8,3] fromList [2,5,8,3]

Instance details

Defined in Data.Semiring

Methods

plus :: [a] -> [a] -> [a] #

zero :: [a] #

times :: [a] -> [a] -> [a] #

one :: [a] #

Semiring a => Semiring (Maybe a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Maybe a -> Maybe a -> Maybe a #

zero :: Maybe a #

times :: Maybe a -> Maybe a -> Maybe a #

one :: Maybe a #

Integral a => Semiring (Ratio a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Ratio a -> Ratio a -> Ratio a #

zero :: Ratio a #

times :: Ratio a -> Ratio a -> Ratio a #

one :: Ratio a #

Semiring a => Semiring (IO a) 
Instance details

Defined in Data.Semiring

Methods

plus :: IO a -> IO a -> IO a #

zero :: IO a #

times :: IO a -> IO a -> IO a #

one :: IO a #

Ring a => Semiring (Complex a)

This instance can suffer due to floating point arithmetic.

Instance details

Defined in Data.Semiring

Methods

plus :: Complex a -> Complex a -> Complex a #

zero :: Complex a #

times :: Complex a -> Complex a -> Complex a #

one :: Complex a #

HasResolution a => Semiring (Fixed a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Fixed a -> Fixed a -> Fixed a #

zero :: Fixed a #

times :: Fixed a -> Fixed a -> Fixed a #

one :: Fixed a #

Semiring (Predicate a) 
Instance details

Defined in Data.Semiring

Semiring a => Semiring (Equivalence a) 
Instance details

Defined in Data.Semiring

Semiring a => Semiring (Identity a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Identity a -> Identity a -> Identity a #

zero :: Identity a #

times :: Identity a -> Identity a -> Identity a #

one :: Identity a #

Semiring a => Semiring (Dual a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Dual a -> Dual a -> Dual a #

zero :: Dual a #

times :: Dual a -> Dual a -> Dual a #

one :: Dual a #

Semiring a => Semiring (Down a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Down a -> Down a -> Down a #

zero :: Down a #

times :: Down a -> Down a -> Down a #

one :: Down a #

(Ord a, Monoid a) => Semiring (Set a)

The multiplication laws are satisfied for any underlying Monoid, so we require a Monoid constraint instead of a Semiring constraint since times can use the context of either.

Instance details

Defined in Data.Semiring

Methods

plus :: Set a -> Set a -> Set a #

zero :: Set a #

times :: Set a -> Set a -> Set a #

one :: Set a #

(Storable a, Semiring a) => Semiring (Vector a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Vector a -> Vector a -> Vector a #

zero :: Vector a #

times :: Vector a -> Vector a -> Vector a #

one :: Vector a #

(Unbox a, Semiring a) => Semiring (Vector a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Vector a -> Vector a -> Vector a #

zero :: Vector a #

times :: Vector a -> Vector a -> Vector a #

one :: Vector a #

(Eq a, Hashable a, Monoid a) => Semiring (HashSet a)

The multiplication laws are satisfied for any underlying Monoid, so we require a Monoid constraint instead of a Semiring constraint since times can use the context of either.

Instance details

Defined in Data.Semiring

Methods

plus :: HashSet a -> HashSet a -> HashSet a #

zero :: HashSet a #

times :: HashSet a -> HashSet a -> HashSet a #

one :: HashSet a #

Semiring a => Semiring (Vector a)

The Semiring instance for 'Vector a' can be interpreted as treating each element of the list as coefficients to a polynomial in one variable.

Examples

Expand

poly1 = Vector.fromList [1,2,3 :: Int] poly2 = Vector.fromList [ 2,1 :: Int] poly1 * poly2 fromList [2,5,8,3]

Instance details

Defined in Data.Semiring

Methods

plus :: Vector a -> Vector a -> Vector a #

zero :: Vector a #

times :: Vector a -> Vector a -> Vector a #

one :: Vector a #

(Precise a, RealFloat a) => Semiring (Log a) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: Log a -> Log a -> Log a #

zero :: Log a #

times :: Log a -> Log a -> Log a #

one :: Log a #

Num a => Semiring (WrappedNum a) 
Instance details

Defined in Data.Semiring

(Coercible Int a, Monoid a) => Semiring (IntSetOf a) 
Instance details

Defined in Data.Semiring

Methods

plus :: IntSetOf a -> IntSetOf a -> IntSetOf a #

zero :: IntSetOf a #

times :: IntSetOf a -> IntSetOf a -> IntSetOf a #

one :: IntSetOf a #

(Ord x, Semiring x) => Semiring (Viterbi x) Source #

TODO Shall we have generic instances, or specific ones like SemiRing (Viterbi Prob)?

TODO Consider either a constraint ProbLike x or the above.

Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: Viterbi x -> Viterbi x -> Viterbi x #

zero :: Viterbi x #

times :: Viterbi x -> Viterbi x -> Viterbi x #

one :: Viterbi x #

(Ord x, Semiring x, NumericLimits x) => Semiring (MinPlus x) Source #

Be careful, if the numeric limits are hits, underflows, etc will happen.

Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: MinPlus x -> MinPlus x -> MinPlus x #

zero :: MinPlus x #

times :: MinPlus x -> MinPlus x -> MinPlus x #

one :: MinPlus x #

(Ord x, Semiring x, NumericLimits x) => Semiring (MaxPlus x) Source #

TODO Shall we have generic instances, or specific ones like SemiRing (Viterbi Prob)?

TODO Consider either a constraint ProbLike x or the above.

Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: MaxPlus x -> MaxPlus x -> MaxPlus x #

zero :: MaxPlus x #

times :: MaxPlus x -> MaxPlus x -> MaxPlus x #

one :: MaxPlus x #

Semiring b => Semiring (a -> b) 
Instance details

Defined in Data.Semiring

Methods

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

zero :: a -> b #

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

one :: a -> b #

Semiring a => Semiring (Op a b) 
Instance details

Defined in Data.Semiring

Methods

plus :: Op a b -> Op a b -> Op a b #

zero :: Op a b #

times :: Op a b -> Op a b -> Op a b #

one :: Op a b #

(Eq k, Hashable k, Monoid k, Semiring v) => Semiring (HashMap k v)

The multiplication laws are satisfied for any underlying Monoid as the key type, so we require a Monoid constraint instead of a Semiring constraint since times can use the context of either.

Instance details

Defined in Data.Semiring

Methods

plus :: HashMap k v -> HashMap k v -> HashMap k v #

zero :: HashMap k v #

times :: HashMap k v -> HashMap k v -> HashMap k v #

one :: HashMap k v #

(Ord k, Monoid k, Semiring v) => Semiring (Map k v)

The multiplication laws are satisfied for any underlying Monoid as the key type, so we require a Monoid constraint instead of a Semiring constraint since times can use the context of either.

Instance details

Defined in Data.Semiring

Methods

plus :: Map k v -> Map k v -> Map k v #

zero :: Map k v #

times :: Map k v -> Map k v -> Map k v #

one :: Map k v #

Semiring (Proxy a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Proxy a -> Proxy a -> Proxy a #

zero :: Proxy a #

times :: Proxy a -> Proxy a -> Proxy a #

one :: Proxy a #

(Coercible Int k, Monoid k, Semiring v) => Semiring (IntMapOf k v) 
Instance details

Defined in Data.Semiring

Methods

plus :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v #

zero :: IntMapOf k v #

times :: IntMapOf k v -> IntMapOf k v -> IntMapOf k v #

one :: IntMapOf k v #

Num (Discretized k2) => Semiring (Discretized k2) Source # 
Instance details

Defined in Numeric.Discretized

Semiring (Discretized t) => Semiring (DiscLogOdds t) Source # 
Instance details

Defined in Statistics.Odds

Num r => Semiring (Probability n r) Source # 
Instance details

Defined in Statistics.Probability

Methods

plus :: Probability n r -> Probability n r -> Probability n r #

zero :: Probability n r #

times :: Probability n r -> Probability n r -> Probability n r #

one :: Probability n r #

Semiring a => Semiring (Const a b) 
Instance details

Defined in Data.Semiring

Methods

plus :: Const a b -> Const a b -> Const a b #

zero :: Const a b #

times :: Const a b -> Const a b -> Const a b #

one :: Const a b #

(Semiring a, Applicative f) => Semiring (Ap f a) 
Instance details

Defined in Data.Semiring

Methods

plus :: Ap f a -> Ap f a -> Ap f a #

zero :: Ap f a #

times :: Ap f a -> Ap f a -> Ap f a #

one :: Ap f a #

(Semigroup (zeroMonoid x), Monoid (zeroMonoid x), Semigroup (oneMonoid x), Monoid (oneMonoid x), Coercible (zeroMonoid x) (GSemiring zeroMonoid oneMonoid x), Coercible (oneMonoid x) (GSemiring zeroMonoid oneMonoid x)) => Semiring (GSemiring zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.Semiring

Methods

plus :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x #

zero :: GSemiring zeroMonoid oneMonoid x #

times :: GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x -> GSemiring zeroMonoid oneMonoid x #

one :: GSemiring zeroMonoid oneMonoid x #

Orphan instances

(Precise a, RealFloat a) => Semiring (Log a) Source # 
Instance details

Methods

plus :: Log a -> Log a -> Log a #

zero :: Log a #

times :: Log a -> Log a -> Log a #

one :: Log a #