poset: Remove IncoherentInstances and define our own Ord class.
[altfloat.git] / Data / Floating / Instances.hs
blob57ee29bea9268a267210383f33245d4d3b27ec46
1 {-# LANGUAGE ForeignFunctionInterface, MagicHash #-}
2 module Data.Floating.Instances () where
4 import Prelude hiding (Ord(..), Double)
5 import Foreign.C
7 import Data.Floating.Classes
8 import Data.Floating.Double
9 import Data.Floating.Types
10 import Data.Floating.CMath
12 import Data.Poset
13 import GHC.Prim
15 foreign import ccall unsafe "double_compare"
16 double_compare :: CDouble -> CDouble -> CInt
18 instance Poset Double where
19 compare a b = toEnum . fromIntegral $ double_compare a' b' where
20 a' = toFloating a
21 b' = toFloating b
22 D# x < D# y = x <## y
23 D# x <= D# y = x <=## y
24 D# x >= D# y = x >=## y
25 D# x > D# y = x >## y
27 instance Sortable Double where
28 isSignificant = not . ((== FPNaN) . classify)
29 max = libmDouble2 c_fmax
30 min = libmDouble2 c_fmin