monoid-extras-0.4.2: Various extra monoid-related definitions and utilities

Data.Monoid.Inf

Contents

Description

Make semigroups under min or max into monoids by adjoining an element corresponding to infinity (positive or negative, respectively). These types are similar to Option (Min a) and Option (Max a) respectively, except that the Ord instance matches the Monoid instance.

Synopsis

# Documentation

data Inf p a Source #

Constructors

 Infinity Finite a

Instances

data Pos Source #

Instances

 Ord a => Ord (Inf Pos a) Source # Methodscompare :: Inf Pos a -> Inf Pos a -> Ordering #(<) :: Inf Pos a -> Inf Pos a -> Bool #(<=) :: Inf Pos a -> Inf Pos a -> Bool #(>) :: Inf Pos a -> Inf Pos a -> Bool #(>=) :: Inf Pos a -> Inf Pos a -> Bool #max :: Inf Pos a -> Inf Pos a -> Inf Pos a #min :: Inf Pos a -> Inf Pos a -> Inf Pos a # Ord a => Semigroup (Inf Pos a) Source # Methods(<>) :: Inf Pos a -> Inf Pos a -> Inf Pos a #sconcat :: NonEmpty (Inf Pos a) -> Inf Pos a #stimes :: Integral b => b -> Inf Pos a -> Inf Pos a # Ord a => Monoid (Inf Pos a) Source # Methodsmappend :: Inf Pos a -> Inf Pos a -> Inf Pos a #mconcat :: [Inf Pos a] -> Inf Pos a #

data Neg Source #

Instances

 Ord a => Ord (Inf Neg a) Source # Methodscompare :: Inf Neg a -> Inf Neg a -> Ordering #(<) :: Inf Neg a -> Inf Neg a -> Bool #(<=) :: Inf Neg a -> Inf Neg a -> Bool #(>) :: Inf Neg a -> Inf Neg a -> Bool #(>=) :: Inf Neg a -> Inf Neg a -> Bool #max :: Inf Neg a -> Inf Neg a -> Inf Neg a #min :: Inf Neg a -> Inf Neg a -> Inf Neg a # Ord a => Semigroup (Inf Neg a) Source # Methods(<>) :: Inf Neg a -> Inf Neg a -> Inf Neg a #sconcat :: NonEmpty (Inf Neg a) -> Inf Neg a #stimes :: Integral b => b -> Inf Neg a -> Inf Neg a # Ord a => Monoid (Inf Neg a) Source # Methodsmappend :: Inf Neg a -> Inf Neg a -> Inf Neg a #mconcat :: [Inf Neg a] -> Inf Neg a #

type PosInf a = Inf Pos a Source #

type NegInf a = Inf Neg a Source #

minimum :: Ord a => [a] -> PosInf a Source #

maximum :: Ord a => [a] -> NegInf a Source #