monus-weighted-search-0.2.0.0: Efficient search weighted by an ordered monoid with monus.
Copyright(c) Donnacha Oisín Kidney 2021
Maintainermail@doisinkidney.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Monus

Description

A class for Monoids with an order and a pseudo-subtraction operator.

Synopsis

Documentation

class (Ord a, Monoid a) => Monus a where Source #

A class for (constructive) totally-ordered commutative monoids. These are monoids such that their ordering respects the <> operator, meaning they obey the following law:

  x <= x <> y

These monoids must also have a pseudo-subtraction operator (|-|), which behaves like an absolute difference function. This operator must obey the following law:

  x <= y ==> x <> (y |-| x) == y

Methods

(|-|) :: a -> a -> a infixl 6 Source #

An absolute difference operator.

Instances

Instances details
Monus Any Source #
>>> let bools = [Any False, Any True]
>>> and [ x <> (y |-| x) == y | x <- bools, y <- bools, x <= y ]
True
Instance details

Defined in Data.Monus

Methods

(|-|) :: Any -> Any -> Any Source #

Monus Dist Source # 
Instance details

Defined in Data.Monus.Dist

Methods

(|-|) :: Dist -> Dist -> Dist Source #

Monus Prob Source # 
Instance details

Defined in Data.Monus.Prob

Methods

(|-|) :: Prob -> Prob -> Prob Source #

(Bounded a, Ord a) => Monus (Max a) Source # 
Instance details

Defined in Data.Monus

Methods

(|-|) :: Max a -> Max a -> Max a Source #

(Num a, Ord a) => Monus (Sum a) Source # 
Instance details

Defined in Data.Monus

Methods

(|-|) :: Sum a -> Sum a -> Sum a Source #

Ord a => Monus (Max a) Source # 
Instance details

Defined in Data.Monus.Max

Methods

(|-|) :: Max a -> Max a -> Max a Source #