Implement `GHC.Natural.powModNatural` (#9818)
authorHerbert Valerio Riedel <hvr@gnu.org>
Sat, 29 Nov 2014 12:02:42 +0000 (13:02 +0100)
committerHerbert Valerio Riedel <hvr@gnu.org>
Sat, 29 Nov 2014 17:39:07 +0000 (18:39 +0100)
commit859680f6fe952ecbef3395fa4f299530d0f10c58
tree702c161581f1f2be6d7b619509e50ab57a62c150
parentd0d4674281a80e4148a82f833948c2b4c3051eab
Implement `GHC.Natural.powModNatural` (#9818)

This makes use of the `powMod*` primitives provided by
`integer-gmp-1.0.0`. This is the `Natural`-version of the related
`GHC.Integer.GMP.Internals.powModInteger` operation.

The fallback implementation uses a square and multiply algorithm,
compared to which the optimized GMP-based implementation needs much less
allocations due to in-place mutation during the computation.
libraries/base/GHC/Natural.hs