
Yes, but a ring is sufficient for lots of very basic and important
manipulations. When I'm writing code with Int and Word, I don't even think
about whether the associative and distributive laws apply--I just use them
to simplify my definitions. With trapping overflow, I need to watch for
ranges every time I apply one. Horrible!
On Fri, Feb 8, 2019, 3:05 PM Carter Schonwald I think the algebraic property we usually want for nice integer ish things
is intergral domain. Which is a stronger property than ring. Pardon the
confusion On Fri, Feb 8, 2019 at 3:03 PM Carter Schonwald <
carter.schonwald@gmail.com> wrote: No. A ring can’t have 2x=0 for x not zero. Thus int can’t be And by ring I mean an algebraic structure where you have a multiplicative
group that doesn’t generate zero from products of nonzero elements ... Phrased differently: Int doesn’t have a multiplicative group structure on
the nonzero elements. That makes it a pretty nasty ring. Negate on minBound
should be an overflow exception so you can have actual sane semantics.
This is an old dead horse with lots of blood written about it. https://ghc.haskell.org/trac/ghc/ticket/8695 has some related
discussions On Fri, Feb 8, 2019 at 2:53 PM Jens Blanck minBound + minBound :: Int
0
negate minBound == (minBound :: Int)
True
42 + negate 17 :: Word
25 Int and Word are currently rings. What proportion actually uses them as
such would be interesting to know but I guess it is very small. I wouldn't
dare to reason about Int and Word as rings as there is no guarantee on
which ring they are. Int64 and Word64 and so on; yes, those can be reasoned
about. I'd be very happy to see a separate type for signalling integral types.
Personally, I'd make them the default choice. On Fri, 8 Feb 2019 at 19:27, Carter Schonwald <
carter.schonwald@gmail.com> wrote: I’m not sure if they currently have full ring structure , but I do
agree that trapping and non trapping int and word are useful. Simple example where all the finite signed ints work wrong today : There’s no proper additive inverse for minBound :: int Likewise , what’s our current definition of negate on finite word types? On Fri, Feb 8, 2019 at 2:12 PM David Feuer No, no, no. Int and Word are *rings*, which let's us apply a ton of
mathematical reasoning to their arithmetic. Trapping overflow would throw
all that completely out the window. If you want to trap overflow, please
use different types! On Fri, Feb 8, 2019, 2:07 PM Lennart Augustsson <
lennart@augustsson.net wrote: I would *hate* to lose quiet NaNs. They can be very useful. But I’d
be fine having them as a separate type. And while we’re at it, why not make Int overflow and underflow cause
a trap as well? With a different type if you want to wrap. On Fri, Feb 8, 2019 at 08:34 Carter Schonwald <
carter.schonwald@gmail.com> wrote: > Thanks for eloquently summarizing , better than I would , what I
> thought I had laid out.
>
> Ieee floating point has fantastic hardware support . May as well be
> the first real language to actually use it correctly. :)
>
> On Fri, Feb 8, 2019 at 5:21 AM Merijn Verstraaten <
> merijn@inconsistent.nl> wrote:
>
>>
>>
>> > On 8 Feb 2019, at 10:57, Sven Panne _______________________________________________
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