
@chess, @Zemyla
I would argue there is no "sensible" implementation of Eq and Ord for floating point. Better to have PartialEq [1] /PartialOrd [2].
[1]: https://doc.rust-lang.org/std/cmp/trait.PartialEq.html
[2]: https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html
On Sat, Nov 30, 2019, 11:21 AM Zemyla
wrote: There should be a newtype wrapper that wraps a RealFloat, keeps the Enum/Num/Fractional/so on instances, but gives it sensible ones for Eq and Ord, with the following order:
NaN < -Inf < negative < -0 < +0 < positive < +Inf
It may not belong in base, but if nothing else it definitely belongs in containers, because Set and Map depend critically on sensible instances of Ord.
(Also, it should newtype derive Read and Show, so that people using them with GHCi see "fromList [(NaN, yadda), (-1.5, yadda), (2.7, blah), (+Inf, blah)]" instead of "fromList [(FloatOrd { unwrapFloat :: NaN }, yadda), ...".) _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries