
On 14-11-11 04:35 AM, Herbert Valerio Riedel wrote:
Hello CLC et al.,
I hereby suggest to add a type for encoding term-level naturals
data Natural =
deriving (...the usual standard classes...)
+1 from me. Regarding the partial vs. saturated negation, I'm in favour of the former. However, there is another option nobody mentioned so far: NaN. I.e., 1 - 2 = NaN 3 + 1 - 2 = 2 3 + (1 - 2) = NaN Could a GMP-based implementation provide such semantics without too much performance loss? If so, this would be my preference.
to `base:Data.Word` module
Motivation ==========
- GHC 7.10 is planned to ship with integer-gmp2[2] as its default `Integer` lib, whose low-level primitives are based on *unsigned* BigNums. And 'Natural' type for integer-gmp2 can be implemented directly w/o the overhead of wrapping an `Integer` via
data Natural = NatS# Word# | NatJ# !PrimBigNat#
as well as having a twice as large domain handled via the small-word constructor and thus avoiding FFI calls into GMP.
- GHC/`base` already provides type-level naturals, but no term-level naturals
- Remove the asymmetry of having an unbounded signed `Integer` but no unbounded /unsigned/ integral type.
Also, `Data.Word` has been carrying the following note[1] for some time now:
> It would be very natural to add a type Natural providing an > unbounded size unsigned integer, just as Integer provides unbounded > size signed integers. We do not do that yet since there is no > demand for it.
Discussion period: ~10 days (GHC 7.10 RC freeze is scheduled for Nov 21st)
Cheers, hvr
[1]: http://hackage.haskell.org/package/base-4.7.0.1/docs/Data-Word.html#g:3
[2]: https://phabricator.haskell.org/D82 https://ghc.haskell.org/trac/ghc/wiki/Design/IntegerGmp2 _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries