HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleextended-reals-0.2.7.0Haskell2010

Data.ExtendedReal

Extension of real numbers with positive/negative infinities (±∞). It is useful for describing various limiting behaviors in mathematics.

Remarks:

  • ∞ - ∞ is left undefined as usual, but we define 0 × ∞ = 0 × -∞ = 0 by following the convention of probability or measure theory.

References:

  • 1 type
  • 5 values
datadata Extended r
#

Extended r is an extension of r with positive/negative infinity (±∞).

Constructors

Instances16Functor, Foldable, Traversable, Lift, Bounded, Eq, …
valuefromRealFloat :: RealFloat r => r -> Extended r
#

Helper to convert Double and Float to Extended, taking care of infinite values automatically.

Example3 expressions
fromRealFloat (1 / 0)PosInffromRealFloat (-1 / 0)NegInffromRealFloat (0 / 0)*** Exception: fromRealFloat: argument should not be NaN

Beware that an ordinal infinity might not be equal to an arithmetic infinity. PosInf / NegInf stand for infinite elements with regards to ordering, so:

Example2 expressions
fromRealFloat (Down (1 / 0))NegInffromRealFloat (Down (-1 / 0))PosInf
valuetoRealFloat :: RealFloat r => Extended r -> r
#

Helper to convert Extended to Double or Float, taking care of infinite values automatically.

Example4 expressions
toRealFloat PosInf :: DoubleInfinitytoRealFloat NegInf :: Double-InfinitytoRealFloat PosInf :: Down DoubleDown (-Infinity)toRealFloat NegInf :: Down DoubleDown Infinity