ocaml-ppx / ppx_deriving

Type-driven code generation for OCaml
MIT License
466 stars 89 forks source link

Should the "eq" deriver return false on Float.nan ? #251

Closed chetmurthy closed 3 years ago

chetmurthy commented 3 years ago

That is to say,

- # Float.(nan = nan) ;;
- : bool = false

but even so, it seems like, for the purpose to which the eq-deriver gets put (typically debugging), it might be the case that this should be true ?

chetmurthy commented 3 years ago

Or maybe it should be driven by an option? E.g., nan_self_equal ?

thierry-martinez commented 3 years ago

I think I would prefer to define a type float' with a custom equality in this situation. Wouldn't this solution be enough for your use case?

chetmurthy commented 3 years ago

It is, and someone over at the OCaml discussion forum pointed out that I could just supply my own equality function for floats. So it's not an actual problem, and I should have closed this issue ages ago (sorry).