Data.AEq

ieee754-0.8.0: Utilities for dealing with IEEE floating point numbers

Copyright | Copyright (c) 2010 Patrick Perry <patperry@gmail.com>
License | BSD3
Maintainer | Patrick Perry <patperry@gmail.com>
Stability | experimental
Safe Haskell | None
Language | Haskell98

Data.AEq

Description

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

Synopsis

- class Eq a => AEq a where
  - (===) :: a -> a -> Bool
  - (~==) :: a -> a -> Bool

# Documentation

class Eq a => AEq a where #

Types with approximate and exact equality comparisons.

Minimal complete definition

Nothing

Methods

(===) :: a -> a -> Bool infix 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 -> Bool infix 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.

#### Instances

Instances details

AEq CChar # |
Instance details Defined in Data.AEq Methods (===) :: CChar -> CChar -> Bool # (~==) :: CChar -> CChar -> Bool #
AEq CClock # |
Instance details Defined in Data.AEq Methods (===) :: CClock -> CClock -> Bool # (~==) :: CClock -> CClock -> Bool #
AEq CDouble # |
Instance details Defined in Data.AEq Methods (===) :: CDouble -> CDouble -> Bool # (~==) :: CDouble -> CDouble -> Bool #
AEq CFloat # |
Instance details Defined in Data.AEq Methods (===) :: CFloat -> CFloat -> Bool # (~==) :: CFloat -> CFloat -> Bool #
AEq CInt # |
Instance details Defined in Data.AEq Methods (===) :: CInt -> CInt -> Bool # (~==) :: CInt -> CInt -> Bool #
AEq CIntMax # |
Instance details Defined in Data.AEq Methods (===) :: CIntMax -> CIntMax -> Bool # (~==) :: CIntMax -> CIntMax -> Bool #
AEq CIntPtr # |
Instance details Defined in Data.AEq Methods (===) :: CIntPtr -> CIntPtr -> Bool # (~==) :: CIntPtr -> CIntPtr -> Bool #
AEq CLLong # |
Instance details Defined in Data.AEq Methods (===) :: CLLong -> CLLong -> Bool # (~==) :: CLLong -> CLLong -> Bool #
AEq CLong # |
Instance details Defined in Data.AEq Methods (===) :: CLong -> CLong -> Bool # (~==) :: CLong -> CLong -> Bool #
AEq CPtrdiff # |
Instance details Defined in Data.AEq Methods (===) :: CPtrdiff -> CPtrdiff -> Bool # (~==) :: CPtrdiff -> CPtrdiff -> Bool #
AEq CSChar # |
Instance details Defined in Data.AEq Methods (===) :: CSChar -> CSChar -> Bool # (~==) :: CSChar -> CSChar -> Bool #
AEq CShort # |
Instance details Defined in Data.AEq Methods (===) :: CShort -> CShort -> Bool # (~==) :: CShort -> CShort -> Bool #
AEq CSigAtomic # |
Instance details Defined in Data.AEq Methods (===) :: CSigAtomic -> CSigAtomic -> Bool # (~==) :: CSigAtomic -> CSigAtomic -> Bool #
AEq CSize # |
Instance details Defined in Data.AEq Methods (===) :: CSize -> CSize -> Bool # (~==) :: CSize -> CSize -> Bool #
AEq CTime # |
Instance details Defined in Data.AEq Methods (===) :: CTime -> CTime -> Bool # (~==) :: CTime -> CTime -> Bool #
AEq CUChar # |
Instance details Defined in Data.AEq Methods (===) :: CUChar -> CUChar -> Bool # (~==) :: CUChar -> CUChar -> Bool #
AEq CUInt # |
Instance details Defined in Data.AEq Methods (===) :: CUInt -> CUInt -> Bool # (~==) :: CUInt -> CUInt -> Bool #
AEq CUIntMax # |
Instance details Defined in Data.AEq Methods (===) :: CUIntMax -> CUIntMax -> Bool # (~==) :: CUIntMax -> CUIntMax -> Bool #
AEq CUIntPtr # |
Instance details Defined in Data.AEq Methods (===) :: CUIntPtr -> CUIntPtr -> Bool # (~==) :: CUIntPtr -> CUIntPtr -> Bool #
AEq CULLong # |
Instance details Defined in Data.AEq Methods (===) :: CULLong -> CULLong -> Bool # (~==) :: CULLong -> CULLong -> Bool #
AEq CULong # |
Instance details Defined in Data.AEq Methods (===) :: CULong -> CULong -> Bool # (~==) :: CULong -> CULong -> Bool #
AEq CUShort # |
Instance details Defined in Data.AEq Methods (===) :: CUShort -> CUShort -> Bool # (~==) :: CUShort -> CUShort -> Bool #
AEq CWchar # |
Instance details Defined in Data.AEq Methods (===) :: CWchar -> CWchar -> Bool # (~==) :: CWchar -> CWchar -> Bool #
AEq IntPtr # |
Instance details Defined in Data.AEq Methods (===) :: IntPtr -> IntPtr -> Bool # (~==) :: IntPtr -> IntPtr -> Bool #
AEq WordPtr # |
Instance details Defined in Data.AEq Methods (===) :: WordPtr -> WordPtr -> Bool # (~==) :: WordPtr -> WordPtr -> Bool #
AEq Int16 # |
Instance details Defined in Data.AEq Methods (===) :: Int16 -> Int16 -> Bool # (~==) :: Int16 -> Int16 -> Bool #
AEq Int32 # |
Instance details Defined in Data.AEq Methods (===) :: Int32 -> Int32 -> Bool # (~==) :: Int32 -> Int32 -> Bool #
AEq Int64 # |
Instance details Defined in Data.AEq Methods (===) :: Int64 -> Int64 -> Bool # (~==) :: Int64 -> Int64 -> Bool #
AEq Int8 # |
Instance details Defined in Data.AEq Methods (===) :: Int8 -> Int8 -> Bool # (~==) :: Int8 -> Int8 -> Bool #
AEq Word16 # |
Instance details Defined in Data.AEq Methods (===) :: Word16 -> Word16 -> Bool # (~==) :: Word16 -> Word16 -> Bool #
AEq Word32 # |
Instance details Defined in Data.AEq Methods (===) :: Word32 -> Word32 -> Bool # (~==) :: Word32 -> Word32 -> Bool #
AEq Word64 # |
Instance details Defined in Data.AEq Methods (===) :: Word64 -> Word64 -> Bool # (~==) :: Word64 -> Word64 -> Bool #
AEq Word8 # |
Instance details Defined in Data.AEq Methods (===) :: Word8 -> Word8 -> Bool # (~==) :: Word8 -> Word8 -> Bool #
AEq Ordering # |
Instance details Defined in Data.AEq Methods (===) :: Ordering -> Ordering -> Bool # (~==) :: Ordering -> Ordering -> Bool #
AEq Integer # |
Instance details Defined in Data.AEq Methods (===) :: Integer -> Integer -> Bool # (~==) :: Integer -> Integer -> Bool #
AEq () # |
Instance details Defined in Data.AEq Methods (===) :: () -> () -> Bool # (~==) :: () -> () -> Bool #
AEq Bool # |
Instance details Defined in Data.AEq Methods (===) :: Bool -> Bool -> Bool # (~==) :: Bool -> Bool -> Bool #
AEq Char # |
Instance details Defined in Data.AEq Methods (===) :: Char -> Char -> Bool # (~==) :: Char -> Char -> Bool #
AEq Double # |
Instance details Defined in Data.AEq Methods (===) :: Double -> Double -> Bool # (~==) :: Double -> Double -> Bool #
AEq Float # |
Instance details Defined in Data.AEq Methods (===) :: Float -> Float -> Bool # (~==) :: Float -> Float -> Bool #
AEq Int # |
Instance details Defined in Data.AEq Methods (===) :: Int -> Int -> Bool # (~==) :: Int -> Int -> Bool #
AEq Word # |
Instance details Defined in Data.AEq Methods (===) :: Word -> Word -> Bool # (~==) :: Word -> Word -> Bool #
AEq (Complex CDouble) # |
Instance details Defined in Data.AEq Methods (===) :: Complex CDouble -> Complex CDouble -> Bool # (~==) :: Complex CDouble -> Complex CDouble -> Bool #
AEq (Complex CFloat) # |
Instance details Defined in Data.AEq Methods (===) :: Complex CFloat -> Complex CFloat -> Bool # (~==) :: Complex CFloat -> Complex CFloat -> Bool #
AEq (Complex Double) # |
Instance details Defined in Data.AEq Methods (===) :: Complex Double -> Complex Double -> Bool # (~==) :: Complex Double -> Complex Double -> Bool #
AEq (Complex Float) # |
Instance details Defined in Data.AEq Methods (===) :: Complex Float -> Complex Float -> Bool # (~==) :: Complex Float -> Complex Float -> Bool #
AEq (ForeignPtr a) # |
Instance details Defined in Data.AEq Methods (===) :: ForeignPtr a -> ForeignPtr a -> Bool # (~==) :: ForeignPtr a -> ForeignPtr a -> Bool #
AEq (FunPtr a) # |
Instance details Defined in Data.AEq Methods (===) :: FunPtr a -> FunPtr a -> Bool # (~==) :: FunPtr a -> FunPtr a -> Bool #
AEq (Ptr a) # |
Instance details Defined in Data.AEq Methods (===) :: Ptr a -> Ptr a -> Bool # (~==) :: Ptr a -> Ptr a -> Bool #
AEq (StablePtr a) # |
Instance details Defined in Data.AEq Methods (===) :: StablePtr a -> StablePtr a -> Bool # (~==) :: StablePtr a -> StablePtr a -> Bool #
AEq a => AEq (Maybe a) # |
Instance details Defined in Data.AEq Methods (===) :: Maybe a -> Maybe a -> Bool # (~==) :: Maybe a -> Maybe a -> Bool #
AEq a => AEq [a] # |
Instance details Defined in Data.AEq Methods (===) :: [a] -> [a] -> Bool # (~==) :: [a] -> [a] -> Bool #
(AEq a, AEq b) => AEq (Either a b) # |
Instance details Defined in Data.AEq Methods (===) :: Either a b -> Either a b -> Bool # (~==) :: Either a b -> Either a b -> Bool #
(AEq a, AEq b) => AEq (a, b) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b) -> (a, b) -> Bool # (~==) :: (a, b) -> (a, b) -> Bool #
(AEq a, AEq b, AEq c) => AEq (a, b, c) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c) -> (a, b, c) -> Bool # (~==) :: (a, b, c) -> (a, b, c) -> Bool #
(AEq a, AEq b, AEq c, AEq d) => AEq (a, b, c, d) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d) -> (a, b, c, d) -> Bool # (~==) :: (a, b, c, d) -> (a, b, c, d) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e) => AEq (a, b, c, d, e) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool # (~==) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f) => AEq (a, b, c, d, e, f) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool # (~==) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g) => AEq (a, b, c, d, e, f, g) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool # (~==) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h) => AEq (a, b, c, d, e, f, g, h) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool # (~==) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i) => AEq (a, b, c, d, e, f, g, h, i) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool # (~==) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j) => AEq (a, b, c, d, e, f, g, h, i, j) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool # (~==) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k) => AEq (a, b, c, d, e, f, g, h, i, j, k) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool # (~==) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k, AEq l) => AEq (a, b, c, d, e, f, g, h, i, j, k, l) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool # (~==) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k, AEq l, AEq m) => AEq (a, b, c, d, e, f, g, h, i, j, k, l, m) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool # (~==) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k, AEq l, AEq m, AEq n) => AEq (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool # (~==) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool #
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k, AEq l, AEq m, AEq n, AEq o) => AEq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) # |
Instance details Defined in Data.AEq Methods (===) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool # (~==) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool #