[Haskell-cafe] attoparsec double precision, quickCheck and aeson
johan.tibell at gmail.com
Tue Jun 5 18:57:15 CEST 2012
On Tue, Jun 5, 2012 at 9:51 AM, Warren Harris <warrensomebody at gmail.com> wrote:
> On Jun 5, 2012, at 9:38 AM, Johan Tibell wrote:
>> You want to perform your test as
>> d1 - d2 < epsilon
> What's the best way to do this though, since aeson's Value type already provides instance Eq? I guess I can write my own suite of equality comparisons, but these aeson values are the leaves of an extensive grammar and it seems a shame to mimic everything that Eq does (without the benefits of deriving) just to compare doubles differently.
I don't think applying == to something that contains floating point
values at the leaves makes much sense. You want some approxEq function
that uses approximate equality on floating point value or you want to
equality function that ignores the floating point values. Probably not
the answer you like, but I don't know how to define Eq in a robust way
for types that include floating point values.
More information about the Haskell-Cafe