Split maybeOfferCreate from makeTransactions
[rootstock.git] / Util / ApproxEq.hs
blobb328d97a8f48b12acf400bac8d23bcaacd009406
1 module Util.ApproxEq where
2 import Data.Eq.Approximate
3 import Data.Function (on)
4 import TypeLevel.NaturalNumber
6 type RelApproxDouble =
7 RelativelyApproximateValue (Digits Twelve) (Digits Eight) Double
8 wrapRelAD :: Double -> RelApproxDouble
9 wrapRelAD = RelativelyApproximateValue
10 unwrapRelAD :: RelApproxDouble -> Double
11 unwrapRelAD = unwrapRelativelyApproximateValue
13 infix 4 ~~=
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
23 _ ~~= _ = False