precursor-0.1.0.0: Prelude replacement

Safe HaskellSafe
LanguageHaskell2010

Precursor.Algebra.Semiring

Synopsis

Documentation

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

Commutativity of +

  • a + b = b + a

Distribution of * over +

  • a*(b + c) = (a*b) + (a*c)
  • (a + b)*c = (a*c) + (b*c)

Another useful law, annihilation, may be deduced from the axioms above:

Methods

one :: a Source #

The identity of *.

zero :: 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.

one :: Num a => a Source #

The identity of *.

zero :: Num a => a Source #

The identity of +.

(+) :: Num a => a -> a -> a infixl 6 Source #

An associative, commutative binary operation.

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

An associative binary operation, which distributes over +.

Instances

Semiring Bool Source # 
Semiring Double Source # 
Semiring Float Source # 
Semiring Int Source # 

Methods

one :: Int Source #

zero :: Int Source #

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

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

Semiring Int8 Source # 
Semiring Int16 Source # 
Semiring Int32 Source # 
Semiring Int64 Source # 
Semiring Integer Source # 
Semiring b => Semiring (a -> b) Source # 

Methods

one :: a -> b Source #

zero :: a -> b Source #

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

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