Natural uses strutural equality, not numeric value equality
Summary
The Natural
type, exported from GHC.Natural
has a derived Eq
instance which reports structural equality. However, We would expect numeric value equality to be reported instead. Structural and numeric value equality are not isomorphic, as there are two ways to construct each numeric value of type Natural
in the range [0.. (maxbound :: Word)]
. This is because there are two constructors NatS#
and NatJ#
.
For any given (W# v)
the following numerically equivalent constructions will result in False
when checking equality:
(NatS# v) == (NatJ# (wordToBigNat v))
Given that Natural
is a number, users do not care if the numbers are structurally equal only that they are numerically equal.
Steps to reproduce
Self evident
Expected behavior
Provide numeric value equality, not structural equality.
Environment
- GHC version used: ghc-8.6.5
Optional:
- Operating System: Ubuntu 16.04
- System Architecture: x86