cartazio / numbers

Other
29 stars 13 forks source link

Questionable Eq and Ord instances for CReal #17

Open expipiplus1 opened 8 years ago

expipiplus1 commented 8 years ago

I think functions to compare equality should be exposed (with a digits-to-compare parameter), but exposing CReal as an instance of Eq and Ord is a little fishy, as this can break a whole bunch of the informal laws surrounding Haskell's Eq and Ord classes.

Although other types such as Float and Double break the laws of Eq, I think it would be appropriate to hold "exact" real arithmetic to a higher standard.

Data.Number.CReal> 2e-42 == (1e-42 :: CReal)
True
 Data.Number.CReal> 2e-42 > (1e-42 :: CReal)
False
cartazio commented 7 years ago

yeah ... Eq and Ord for CReal style numbers needs to have an "epsilon" or "digit" argument

expipiplus1 commented 7 years ago

@cartazio you might be interested in my 'exact-real' package!