I am +1 on having Natural in base, I don't really mind the place
(although I also admit that Data.Word seems odd to me).
About subtraction. For the Num instance of Natural, I'd
prefer (x - y) where (y > x) to fail with an error call. This
is
consistent with the behavior we already have for division.
The type `(-) :: Natural -> Natural
-> Natural` forces us to return
a value for any pair of naturals. However, subtraction is not
defined for every pair, so it makes sense to me for the function
to be partial.
That being said, I consider myself an enemy of partial functions
(head, tail, and family), and I'd probably prefer to use
subtraction
with the following type:
safeSubtract :: Natural -> Natural -> Maybe Natural
With this type, we are not forced to return a value for every
pair, returning Nothing instead for those cases where subtraction
does not make
sense. This is, IMHO, the best way to subtract naturals.
Best regards,
Daniel Díaz.
On 11/13/2014 01:03 AM, Sean Leather
wrote:
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries