<p dir="ltr">Please delete me. Thank you</p>
</br></br><div class="device_aol_et_org_dt_dd_quote"></div><hr style="border:0;height:1px;color:#999;background-color:#999;width:100%;margin:0 0 9px 0;padding:0;"></hr><span style="font-size:14px; color:#999999;">On Friday, February 8, 2019 Vanessa McHale <<span style="color:#0000A0">vanessa.mchale@iohk.io</span>> wrote:</span><br></br><div id="yiv6813920482"><html><head></head><div>
    <p>Most of the arguments for making them rings feel kind of
      pedantic, in any case. I can't think of a time I've ever used
      actual ring theory to reason about Ints/Words. <br clear="none">
    </p>
    <div class="yiv6813920482yqt0650986518" id="yiv6813920482yqtfd32821"><div class="yiv6813920482moz-cite-prefix">On 2/8/19 1:27 PM, Carter Schonwald
      wrote:<br clear="none">
    </div>
    <blockquote type="cite">
      </blockquote></div></div><div class="yiv6813920482yqt0650986518" id="yiv6813920482yqtfd65250"><head></head><div><div>
        <div>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. </div>
      </div>
      <div><br clear="none">
      </div>
      <div>Simple example where all the finite signed ints
        work wrong today : </div>
      <div><br clear="none">
      </div>
      <div>There’s no proper additive inverse for minBound ::
        int </div>
      <div><br clear="none">
      </div>
      <div>Likewise , what’s our current definition of negate
        on finite word types?</div>
      <div><br clear="none">
        <div class="yiv6813920482gmail_quote">
          <div dir="ltr">On Fri, Feb 8, 2019 at 2:12 PM David Feuer <<a rel="nofollow" shape="rect" ymailto="mailto:david.feuer@gmail.com" target="_blank" href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>>
            wrote:<br clear="none">
          </div>
          <blockquote class="yiv6813920482gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
            <div>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!</div>
            <br clear="none">
            <div class="yiv6813920482gmail_quote">
              <div dir="ltr">On Fri, Feb 8, 2019, 2:07 PM Lennart
                Augustsson <<a rel="nofollow" shape="rect" ymailto="mailto:lennart@augustsson.net" target="_blank" href="mailto:lennart@augustsson.net">lennart@augustsson.net</a>
                wrote:<br clear="none">
              </div>
              <blockquote class="yiv6813920482gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
                <div>
                  <div>I would *hate* to lose quiet NaNs. 
                    They can be very useful.  But I’d be fine having
                    them as a separate type.</div>
                </div>
                <div><br clear="none">
                </div>
                <div>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. </div>
                <div><br clear="none">
                </div>
                <div><br clear="none">
                  <div class="yiv6813920482gmail_quote">
                    <div dir="ltr">On Fri, Feb 8, 2019 at 08:34 Carter
                      Schonwald <<a rel="nofollow" shape="rect" ymailto="mailto:carter.schonwald@gmail.com" target="_blank" href="mailto:carter.schonwald@gmail.com">carter.schonwald@gmail.com</a>>
                      wrote:<br clear="none">
                    </div>
                    <blockquote class="yiv6813920482gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
                      <div>
                        <div>Thanks for eloquently
                          summarizing , better than I would , what I
                          thought I had laid out. </div>
                      </div>
                      <div><br clear="none">
                      </div>
                      <div>Ieee floating point has fantastic
                        hardware support .  May as well be the first
                        real language to actually use it correctly. :)</div>
                      <div><br clear="none">
                        <div class="yiv6813920482gmail_quote">
                          <div dir="ltr">On Fri, Feb 8, 2019 at 5:21 AM
                            Merijn Verstraaten <<a rel="nofollow" shape="rect" ymailto="mailto:merijn@inconsistent.nl" target="_blank" href="mailto:merijn@inconsistent.nl">merijn@inconsistent.nl</a>>
                            wrote:<br clear="none">
                          </div>
                          <blockquote class="yiv6813920482gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br clear="none">
                            <br clear="none">
                            > On 8 Feb 2019, at 10:57, Sven Panne
                            <<a rel="nofollow" shape="rect" ymailto="mailto:svenpanne@gmail.com" target="_blank" href="mailto:svenpanne@gmail.com">svenpanne@gmail.com</a>>
                            wrote:<br clear="none">
                            > <br clear="none">
                            > Am Do., 7. Feb. 2019 um 23:31 Uhr
                            schrieb Merijn Verstraaten <<a rel="nofollow" shape="rect" ymailto="mailto:merijn@inconsistent.nl" target="_blank" href="mailto:merijn@inconsistent.nl">merijn@inconsistent.nl</a>>:<br clear="none">
                            > Our goal is to make "compare NaN n"
                            impossible to happen. [...]<br clear="none">
                            > <br clear="none">
                            > Well, what is supposed to happen then
                            when you *do* see a NaN, e.g. one produced
                            from a foreign call? You *will* see NaNs in
                            Haskell if you interact with other
                            languages, most of them take a far less
                            religious approach to floating points
                            calculations.<br clear="none">
                            <br clear="none">
                            This is not true. As Carter pointed out we
                            can setup the CPU to trap NaNs *even in
                            foreign calls*. So, in theory we CAN rule
                            this out safely. Doing this we can simply
                            convert the trap into an exception at the
                            FFI boundary.<br clear="none">
                            <br clear="none">
                            Now, there are cases were this is
                            problematic, so as said before we will
                            probably need to allow people to optionally
                            switch on 'value NaNs', because the foreign
                            code isn't exception safe or for other
                            reasons, but this is manageable. Via, for
                            example having an annotation on foreign
                            imports whether you want to trap or not.<br clear="none">
                            <br clear="none">
                            In the scenario where someone switches to
                            value NaNs, we are *still* not worse off
                            than we are now. The things you suggest
                            already happen *now*, so the only thing
                            we're advocating is making it possible to
                            have more sane behaviour in the future.<br clear="none">
                            <br clear="none">
                            Any IEEE-754 compliant implementation of
                            Double that doesn't use trapping NaN can, by
                            definition, never ever be a sane
                            implementation of Ord. As IEEE-754
                            *requires* "NaN /= NaN", so equality
                            symmetry doesn't apply to NaNs and there is
                            *no* safe way to sort/order data containing
                            NaNs.<br clear="none">
                            <br clear="none">
                            I've run into several nasty issues of trying
                            to sort lists containing NaNs (not just
                            Haskell, also Python and C) and it's *not*
                            just the NaNs that are affected, entire
                            subsequences end up getting sorted wrong
                            based on the comparison with NaN and you end
                            up with completely garbled and unsorted
                            data.<br clear="none">
                            <br clear="none">
                            In other words, there are only two ways to
                            get sane behaviour from Double with regards
                            to ordering:<br clear="none">
                            <br clear="none">
                            1. Trapping NaN represenation<br clear="none">
                            2. Deviate from IEEE-754 semantics<br clear="none">
                            <br clear="none">
                            To me, option 2 is out of the question, it's
                            the one consistent thing across language we
                            have when it comes to floating point. I
                            understand that *always* using trap
                            representation isn't feasible, but allowing
                            people to optionally switch to value NaNs
                            leaves us no worse off than we are *right
                            now*, and per above, there is literally no
                            way to improve the situation wrt value NaNs
                            without sacrificing IEEE-754 compliance.<br clear="none">
                            <br clear="none">
                            Cheers,<br clear="none">
                            Merijn<br clear="none">
_______________________________________________<br clear="none">
                            Libraries mailing list<br clear="none">
                            <a rel="nofollow" shape="rect" ymailto="mailto:Libraries@haskell.org" target="_blank" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br clear="none">
                            <a rel="nofollow" shape="rect" target="_blank" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br clear="none">
                          </blockquote>
                        </div>
                      </div>
                      _______________________________________________<br clear="none">
                      Libraries mailing list<br clear="none">
                      <a rel="nofollow" shape="rect" ymailto="mailto:Libraries@haskell.org" target="_blank" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br clear="none">
                      <a rel="nofollow" shape="rect" target="_blank" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br clear="none">
                    </blockquote>
                  </div>
                </div>
                _______________________________________________<br clear="none">
                Libraries mailing list<br clear="none">
                <a rel="nofollow" shape="rect" ymailto="mailto:Libraries@haskell.org" target="_blank" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br clear="none">
                <a rel="nofollow" shape="rect" target="_blank" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br clear="none">
              </blockquote>
            </div>
          </blockquote>
        </div>
      </div>
      <br clear="none">
      <fieldset class="yiv6813920482mimeAttachmentHeader"></fieldset>
      <pre class="yiv6813920482moz-quote-pre">_______________________________________________
Libraries mailing list
<a rel="nofollow" shape="rect" class="yiv6813920482moz-txt-link-abbreviated" ymailto="mailto:Libraries@haskell.org" target="_blank" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>
<a rel="nofollow" shape="rect" class="yiv6813920482moz-txt-link-freetext" target="_blank" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>
</pre>
    
  </div></div></html></div><html><div class="yqt0650986518" id="yqtfd56102"><body>_______________________________________________<br clear="none">Libraries mailing list<br clear="none"><a shape="rect" ymailto="mailto:Libraries@haskell.org" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br clear="none"><a shape="rect" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br clear="none"></body></div></html>