SciBaseTypes-0.0.0.1: 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

The SemiRing type class.

class SemiRing a where Source #

The semiring operations and neutral elements.

Methods

srplus :: a -> a -> a infixl 6 Source #

srmul :: a -> a -> a infixl 7 Source #

srzero :: a Source #

srone :: a Source #

Instances
(Ord x, Num 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

(Ord x, Num x, NumericLimits x) => SemiRing (MinPlus 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

(Ord x, Num 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

Num r => SemiRing (Prob n r) Source # 
Instance details

Defined in Statistics.Probability

Methods

srplus :: Prob n r -> Prob n r -> Prob n r Source #

srmul :: Prob n r -> Prob n r -> Prob n r Source #

srzero :: Prob n r Source #

srone :: Prob n r Source #

(Semigroup (zeroMonoid x), Monoid (zeroMonoid x), Semigroup (oneMonoid x), Monoid (oneMonoid x)) => SemiRing (GSemiRing zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.SemiRing

Methods

srplus :: GSemiRing zeroMonoid oneMonoid x -> GSemiRing zeroMonoid oneMonoid x -> GSemiRing zeroMonoid oneMonoid x Source #

srmul :: GSemiRing zeroMonoid oneMonoid x -> GSemiRing zeroMonoid oneMonoid x -> GSemiRing zeroMonoid oneMonoid x Source #

srzero :: GSemiRing zeroMonoid oneMonoid x Source #

srone :: GSemiRing zeroMonoid oneMonoid x Source #

(⊕) :: 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 wrappers for SemiRing that make the semiring to use explicit.

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, Num 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

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 #

data MVector s (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.SemiRing

data 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.0.0.1-MnwemAw82XA41vuhv62aH" True) (C1 (MetaCons "Viterbi" PrefixI True) (S1 (MetaSel (Just "getViterbi") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))
data Vector (Viterbi x) Source # 
Instance details

Defined in Algebra.Structure.SemiRing

type Rep1 Viterbi Source # 
Instance details

Defined in Algebra.Structure.SemiRing

type Rep1 Viterbi = D1 (MetaData "Viterbi" "Algebra.Structure.SemiRing" "SciBaseTypes-0.0.0.1-MnwemAw82XA41vuhv62aH" True) (C1 (MetaCons "Viterbi" PrefixI True) (S1 (MetaSel (Just "getViterbi") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

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, Num x, NumericLimits x) => SemiRing (MinPlus 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

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 #

data MVector s (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.SemiRing

data 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.0.0.1-MnwemAw82XA41vuhv62aH" True) (C1 (MetaCons "MinPlus" PrefixI True) (S1 (MetaSel (Just "getMinPlus") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))
data Vector (MinPlus x) Source # 
Instance details

Defined in Algebra.Structure.SemiRing

type Rep1 MinPlus Source # 
Instance details

Defined in Algebra.Structure.SemiRing

type Rep1 MinPlus = D1 (MetaData "MinPlus" "Algebra.Structure.SemiRing" "SciBaseTypes-0.0.0.1-MnwemAw82XA41vuhv62aH" 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

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

Defined in Algebra.Structure.SemiRing

(Ord x, Num 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

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 #

data MVector s (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.SemiRing

data 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.0.0.1-MnwemAw82XA41vuhv62aH" True) (C1 (MetaCons "MaxPlus" PrefixI True) (S1 (MetaSel (Just "getMaxPlus") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))
data Vector (MaxPlus x) Source # 
Instance details

Defined in Algebra.Structure.SemiRing

type Rep1 MaxPlus Source # 
Instance details

Defined in Algebra.Structure.SemiRing

type Rep1 MaxPlus = D1 (MetaData "MaxPlus" "Algebra.Structure.SemiRing" "SciBaseTypes-0.0.0.1-MnwemAw82XA41vuhv62aH" True) (C1 (MetaCons "MaxPlus" PrefixI True) (S1 (MetaSel (Just "getMaxPlus") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

Generic semiring structure encoding.

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

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

It can be used like this: srzero ∷ GSemiRing Min Sum Int == maxBound srone ∷ 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)) => SemiRing (GSemiRing zeroMonoid oneMonoid x) Source # 
Instance details

Defined in Algebra.Structure.SemiRing

Methods

srplus :: GSemiRing zeroMonoid oneMonoid x -> GSemiRing zeroMonoid oneMonoid x -> GSemiRing zeroMonoid oneMonoid x Source #

srmul :: GSemiRing zeroMonoid oneMonoid x -> GSemiRing zeroMonoid oneMonoid x -> GSemiRing zeroMonoid oneMonoid x Source #

srzero :: GSemiRing zeroMonoid oneMonoid x Source #

srone :: GSemiRing zeroMonoid oneMonoid x Source #

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.0.0.1-MnwemAw82XA41vuhv62aH" True) (C1 (MetaCons "GSemiRing" PrefixI True) (S1 (MetaSel (Just "getSemiRing") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))

Variants of Semigroup structures, that use NumericLimits instead of