hs-ats icon indicating copy to clipboard operation
hs-ats copied to clipboard

Why not use hgmp?

Open claudeha opened this issue 7 years ago • 6 comments

I wrote https://hackage.haskell.org/package/hgmp which seems to cover the same ground as gmpint.

Maybe it is useful for you?

claudeha avatar Apr 03 '18 03:04 claudeha

The main difference I see is:

  1. The function mpz_clear is not imported as a FunPtr. This might be something that can b worked around, I don't know.

  2. I'd like to be able to convert to Haskell's Integer type, for benchmarking purposes (in particular, for the purpose of benchmarking against existing Haskell implementations). I could probably make gmpint depend on hgmp if needed, but that depends on the answer to 1) :)

vmchale avatar Apr 16 '18 14:04 vmchale

  1. You could use hgmp's types together with your own foreign import declaration (this is an intended use case of the package, especially with 3rd-party libraries that also use GMP types). Going forward I can add a FunPtr for mpz_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!

  2. For conversion to/from Integer there are a few functions here: https://hackage.haskell.org/package/hgmp-0.1.1/docs/Numeric-GMP-Utils.html for example peekInteger :: Ptr MPZ -> IO Integer (Note: these depend on the internals of the integer-gmp library for GHC, if you need a portable version let me know and I can work on it soon.)

claudeha avatar Apr 16 '18 16:04 claudeha

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.

vmchale avatar Sep 03 '18 06:09 vmchale

Could you let me know how to go about testing so I can diagnose and fix the issue?

claudeha avatar Sep 03 '18 13:09 claudeha

Nevermind. I think the bug was on my end. I will be using hgmp for performance reasons :)

vmchale avatar Nov 07 '18 23:11 vmchale

I can't figure out how to use this without a space leak so this won't be uploaded to Hackage quite yet.

vmchale avatar Nov 08 '18 00:11 vmchale