<div dir="ltr">Yes, it would.<div><br></div><div>The use of bitSizeMaybe is deliberate. </div><div><br></div><div>That way it doesn't have to bound itself when converting an infinite type.</div><div><br></div><div>The whole point of this is that it works for infinite cases.</div><div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 20, 2014 at 6:08 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That bitSizeMaybe makes me a bit nervous. Would it actually hurt anyone to make this thing a subclass of FiniteBits?<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Nov 20, 2014 at 4:46 PM, Sean Leather <span dir="ltr"><<a href="mailto:sean.leather@gmail.com" target="_blank">sean.leather@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="gmail_quote"><div class="gmail_quote">On Wed, Nov 12, 2014 at 9:14 AM, Sean Leather wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span>Inspired by conversations recent [1] and not-so-recent [2] and by my own past wish for this, I propose adding the following function to base:<div><br></div></span><span><div><div><font face="courier new, monospace">toBoundedIntegral :: (Integral a, Integral b, Bounded b) => a -> Maybe b</font></div><div></div></div></span></div></blockquote></div><br></div><div class="gmail_quote">[...]</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Discussion period: ~10 days if there is a strong desire to get it in GHC 7.10. (I would certainly like to see it get in.)</blockquote></div><br></div><div class="gmail_quote">Almost over. Here are some follow-ups on Trac and Phab.</div><div class="gmail_quote"><br></div><div class="gmail_quote"><div class="gmail_quote">GHC Trac: <a href="https://ghc.haskell.org/trac/ghc/ticket/9816" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/9816</a></div><div class="gmail_quote">Phab Diff: <a href="https://phabricator.haskell.org/D512" target="_blank">https://phabricator.haskell.org/D512</a></div></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Mon, Nov 17, 2014 at 11:10 AM, Sean Leather wrote:<span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>So is there any reason not to settle on 'toIntegralBounded' and 'toIntegralSized'?<br></div></div></div></div></blockquote><div><br></div></span><div>I decided to drop 'toIntegralBounded' go with only 'toIntegralSized' in my proposal. I realized that the former was not handling Int<->Word-like cases optimally and would require special attention to them while the latter provides them for free.</div><div><br></div><div>Herbert: It was nice that 'intCastMaybe' was an easy copy-paste into another module. I did a bit of rewriting the comments and code formatting. Hope you don't mind, or bash me on Phab if you prefer. ;) Also, it would be nice to have your tests in the library. Any thoughts on how to do that? I haven't looked into it, yet.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">about the RULEs... do we really need them for `toBoundedIntegral`? If<br>
you make `toBoundedIntegral` INLINEABLE, shouldn't you be able to<br>
inherit the ones from 'fromIntegral' (which is what `intCastMaybe`<br>
exploits)?<br></blockquote><div><br></div></span><div>I didn't try that. I'll give it a shot.</div></div></div></div></blockquote><div><br></div></span><div>I did try it, and I'm not sure how to make that work. 'toBoundedIntegral' splits the 'toInteger' and 'fromInteger' and puts the bounds check in the middle, so 'fromIntegral' is not used. If it were used, then I believe there would be redundant 'toInteger' conversions for types that weren't covered by RULEs.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>
> Where should the functions go? intCastMaybe/toSizedIntegral could go in<br>
> Data.Bits. What about toBoundedIntegral?<br>
<br>
</span>There's also<br>
<br>
  <a href="http://hackage.haskell.org/package/base-4.7.0.1/docs/Numeric.html" target="_blank">http://hackage.haskell.org/package/base-4.7.0.1/docs/Numeric.html</a><br>
<br>
as a candidate<br>
</blockquote></span></div><br></div><div class="gmail_extra">Works for me. We could rename the section “Miscellaneous” to “Conversion” and put both functions there. Also, we should probably revise the module description since there is already a lot more than “functions for reading and showing RealFloat-like kind of values.”</div></div></blockquote><div></div></span></div><br></div><div class="gmail_extra">I decided on Data.Bits since it seemed to be the most obvious place for 'toIntegralSized' alone. Also, I think there might be an import cycle if I put it into Numeric. But if others have a preference and want to make it work somewhere else, that's fine with me.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,</div><div class="gmail_extra">Sean</div></div>
<br></div></div><span class="">_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></span></blockquote></div><br></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>