Why not use hgmp?
I wrote https://hackage.haskell.org/package/hgmp which seems to cover the same ground as gmpint.
Maybe it is useful for you?
The main difference I see is:
-
The function
mpz_clearis not imported as aFunPtr. This might be something that can b worked around, I don't know. -
I'd like to be able to convert to Haskell's
Integertype, for benchmarking purposes (in particular, for the purpose of benchmarking against existing Haskell implementations). I could probably makegmpintdepend onhgmpif needed, but that depends on the answer to 1) :)
-
You could use
hgmp's types together with your ownforeign importdeclaration (this is an intended use case of the package, especially with 3rd-party libraries that also use GMP types). Going forward I can add aFunPtrformpz_clear, this function in particular is useful for adding a finalizer I suppose? If other functions would be needed I could wrap the whole API too, let me know! -
For conversion to/from
Integerthere are a few functions here: https://hackage.haskell.org/package/hgmp-0.1.1/docs/Numeric-GMP-Utils.html for examplepeekInteger :: Ptr MPZ -> IO Integer(Note: these depend on the internals of theinteger-gmplibrary for GHC, if you need a portable version let me know and I can work on it soon.)
It looks like hgmp has a bug that causes the test suite to fail.
Thus, while it is definitely a superior approach in terms of efficiency, I will be using gmpint until that is fixed.
Could you let me know how to go about testing so I can diagnose and fix the issue?
Nevermind. I think the bug was on my end. I will be using hgmp for performance reasons :)
I can't figure out how to use this without a space leak so this won't be uploaded to Hackage quite yet.