HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulemonoid-extras-0.6.2Haskell2010

Data.Monoid.Inf

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

  • 5 types
  • 6 values
datadata Inf p a
#

Inf p a represents the type a extended with a new "infinite" value, which is treated as either positive or negative infinity depending on the type index p. This type exists mostly for its Ord, Semigroup, and Monoid instances.

Constructors

Instances17Bounded, Monad, Functor, Applicative, Foldable, Traversable, …
  • Bounded a => Bounded (NegInf a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Bounded a => Bounded (PosInf a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Monad (Inf p)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Functor (Inf p)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Applicative (Inf p)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Foldable (Inf p)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Traversable (Inf p)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Eq a => Eq (Inf p a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • (Data p, Data a) => Data (Inf p a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Ord a => Ord (Inf Neg a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    Negative infinity is less than any finite value.

  • Ord a => Ord (Inf Pos a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    Positive infinity is greater than any finite value.

  • Read a => Read (Inf p a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Show a => Show (Inf p a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Ord a => Semigroup (Inf Neg a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    An ordered type extended with negative infinity is a semigroup under max.

  • Ord a => Semigroup (Inf Pos a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    An ordered type extended with positive infinity is a semigroup under min.

  • Ord a => Monoid (Inf Neg a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    An ordered type extended with negative infinity is a monoid under max, with negative infinity as the identity element.

  • Ord a => Monoid (Inf Pos a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    An ordered type extended with positive infinity is a monoid under min, with positive infinity as the identity element.

datadata Pos
#

Type index indicating positive infinity.

Instances4Bounded, Ord, Semigroup, Monoid
  • Bounded a => Bounded (PosInf a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Ord a => Ord (Inf Pos a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    Positive infinity is greater than any finite value.

  • Ord a => Semigroup (Inf Pos a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    An ordered type extended with positive infinity is a semigroup under min.

  • Ord a => Monoid (Inf Pos a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    An ordered type extended with positive infinity is a monoid under min, with positive infinity as the identity element.

datadata Neg
#

Type index indicating negative infinity.

Instances4Bounded, Ord, Semigroup, Monoid
  • Bounded a => Bounded (NegInf a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf
  • Ord a => Ord (Inf Neg a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    Negative infinity is less than any finite value.

  • Ord a => Semigroup (Inf Neg a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    An ordered type extended with negative infinity is a semigroup under max.

  • Ord a => Monoid (Inf Neg a)Defined in monoid-extras-0.6.2 · Data.Monoid.Inf

    An ordered type extended with negative infinity is a monoid under max, with negative infinity as the identity element.

typetype PosInf a = Inf Pos a
#

The type a extended with positive infinity.

typetype NegInf a = Inf Neg a
#

The type a extended with negative infinity.

valueminimum :: Ord a => [a] -> PosInf a
#

Find the minimum of a list of values. Returns positive infinity iff the list is empty.

valuemaximum :: Ord a => [a] -> NegInf a
#

Find the maximum of a list of values. Returns negative infinity iff the list is empty.

Type-restricted constructors

4 declarations
valueposFinite :: a -> PosInf a
#

Embed a finite value into the space of such values extended with positive infinity.

valuenegFinite :: a -> NegInf a
#

Embed a finite value into the space of such values extended with negative infinity.