<div dir="ltr"><div dir="ltr">some specializations / optimized instances might be found in <a href="http://hackage.haskell.org/package/arithmoi">http://hackage.haskell.org/package/arithmoi</a></div><div dir="ltr"><br></div><div>cheers</div><div>-Carter</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 1, 2018 at 1:24 PM David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We currently have<br>
<br>
  (^) :: (Num a, Integral b) => a -> b -> a<br>
  (^^) :: (Fractional a, Integral b) => a -> b -> a<br>
  stimes :: (Semigroup a, Integral b) => b -> a -> a<br>
<br>
These are very general, but the ergonomics are terrible. The trouble<br>
is that in each case, the `b` type variable is a (constrained) type<br>
that appears only in one argument and not in the result. In the<br>
extremely common case where the exponent is a literal, we rely on<br>
defaulting to fix `b ~ Integer`. When the exponent is very small, it<br>
will then be rewritten to a simple multiplication. Otherwise, it will<br>
pay the price of bignum arithmetic, whether that's required or not.<br>
<br>
Is there a canonical package providing versions of these functions<br>
with the exponent specialized to `Int` and/or `Word`? If not, where<br>
might such fit well?<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>