3 ms·
> In practice because the `Int` type is a signed, fixed-size integer it would break the laws for all integers. No. `Sum Int` (unlike, pedantically, `Sum Intege
by a1369209993 4y ago
> In practice because the `Int` type is a signed, fixed-size integer it would break the laws for all integers.
No. `Sum Int` (unlike, pedantically, `Sum Integer` or `[a]`) is a valid (non-leaky-abstraction) monoid. It adds `Int`s, which is a monoidal operation that satisfies `(a<>b)<>c==a<>(b<>c)` for all (2^(3*MACHINE_BIT_WIDTH) distinct triplets (a,b,c) of) Ints, due to 2s-complement truncation on overflow.
> your `Int` will wrap around for large values
Yes, that's what `Int` means.
> `Integer`
will fail to terminate when adding sufficiently large values (in theory with a out of memory error, although in practice operations just get slower and slower until you abort them with ^C or a timeout), a property not shared by addition of `Int`.