1 module Util
.ApproxEq
where
2 import Data
.Eq
.Approximate
3 import Data
.Function
(on
)
4 import TypeLevel
.NaturalNumber
7 RelativelyApproximateValue
(Digits Twelve
) (Digits Eight
) Double
8 wrapRelAD
:: Double -> RelApproxDouble
9 wrapRelAD
= RelativelyApproximateValue
10 unwrapRelAD
:: RelApproxDouble
-> Double
11 unwrapRelAD
= unwrapRelativelyApproximateValue
14 class RelApproxEq a
where
15 (~~
=) :: a
-> a
-> Bool
17 instance RelApproxEq
Double where
18 (~~
=) = (==) `on` wrapRelAD
20 instance RelApproxEq a
=> RelApproxEq
(Maybe a
) where
21 Nothing ~~
= Nothing
= True
22 Just x ~~
= Just y
= x ~~
= y