Specialized exponentiation operators

Carter Schonwald carter.schonwald at gmail.com
Thu Nov 1 17:58:56 UTC 2018


some specializations / optimized instances might be found in
http://hackage.haskell.org/package/arithmoi

cheers
-Carter

On Thu, Nov 1, 2018 at 1:24 PM David Feuer <david.feuer at gmail.com> wrote:

> We currently have
>
>   (^) :: (Num a, Integral b) => a -> b -> a
>   (^^) :: (Fractional a, Integral b) => a -> b -> a
>   stimes :: (Semigroup a, Integral b) => b -> a -> a
>
> These are very general, but the ergonomics are terrible. The trouble
> is that in each case, the `b` type variable is a (constrained) type
> that appears only in one argument and not in the result. In the
> extremely common case where the exponent is a literal, we rely on
> defaulting to fix `b ~ Integer`. When the exponent is very small, it
> will then be rewritten to a simple multiplication. Otherwise, it will
> pay the price of bignum arithmetic, whether that's required or not.
>
> Is there a canonical package providing versions of these functions
> with the exponent specialized to `Int` and/or `Word`? If not, where
> might such fit well?
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20181101/4345a1be/attachment.html>


More information about the Libraries mailing list