Reimplement im/export primitives for integer-gmp2

Authored by hvr.


Reimplement im/export primitives for integer-gmp2

The import/export operations were available in integer-gmp-0.5.1
already, but need to be reimplemented from scratch for the
integer-gmp-1.0.0 rewrite.

This also adds a few more operations than were previously available for
use w/ the BigNat type (which will be useful for implementing
serialisation for the upcoming Natural type)

Specifically, the following operations are (re)added (albeit with
slightly different type-signatures):

  • sizeInBaseBigNat
  • sizeInBaseInteger
  • sizeInBaseWord#
  • exportBigNatToAddr
  • exportIntegerToAddr
  • exportWordToAddr
  • exportBigNatToMutableByteArray
  • exportIntegerToMutableByteArray
  • exportWordToMutableByteArray
  • importBigNatFromAddr
  • importIntegerFromAddr
  • importBigNatFromByteArray
  • importIntegerFromByteArray
NOTE: The integerGmpInternals test-case is updated but not yet re-enabled as it contains tests for other primitives which aren't yet reimplemented.

This addresses Trac #9281

Reviewed By: austin, duncan

Differential Revision: