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

Moduleieee754-0.8.0Haskell98

Data.AEq

A type class for approximate and exact equalilty comparisons and instances for common data types.

  • 1 class
  • Packageieee754-0.8.0
  • Exports1
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceAEq.hs
classclass Eq a => AEq a where
#

Types with approximate and exact equality comparisons.

Methods

  • (===) :: a -> a -> Boolinfix 4

    An exact equality comparison.

    For real IEEE types, two values are equivalent in the following cases:

    • both values are +0;

    • both values are -0;

    • both values are nonzero and equal to each other (according to ==);

    • both values are NaN with the same payload and sign.

    For complex IEEE types, two values are equivalent if their real and imaginary parts are equivalent.

  • (~==) :: a -> a -> Boolinfix 4

    An approximate equality comparison operator.

    For real IEEE types, two values are approximately equal in the following cases:

    • at least half of their significand bits agree;

    • both values are less than epsilon;

    • both values are NaN.

    For complex IEEE types, two values are approximately equal in the followiing cases:

    • their magnitudes are approximately equal and the angle between them is less than 32*epsilon;

    • both magnitudes are less than epsilon;

    • both have a NaN real or imaginary part.

    Admitedly, the 32 is a bit of a hack. Future versions of the library may switch to a more principled test of the angle.

Instances67AEq, …