I’m writing some code that parses floats, and one of the things it can parse, is nan
. In writing unit-tests for this code, I have need to write a value that contains Float.nan
and compare it to the result of this parser. Obviously, since Float.nan
is not equal to itself, the built-in equality won’t work. I have the equivalent of ppx_deriving.eq
[which today just uses equality for floats, hence also returns false
] and can modify it so that it checks if the first argument satisfies Float.is_nan
and if so then check if the second argument is also Float.is_nan
. Here’s my question:
-
Should I make this modification to the semantics of equality in
pa_ppx.deriving_plugins.eq
? It seems like the purpose of these deriving plugins is for debugging, so that might be a good thing. -
Maybe this special case should be driven by an option ? But lots of options is confusing, etc, etc.
So I’m looking for “advice about what the proper requirements for deriving.eq should be” really.
P.S. The code I’m writing is a YAML parser, and YAML can parse nan
, hence the need to write unit-tests to test this capability.