Robin Morisset | 26 Jul 12:20 2012
Picon
Picon

Making extra GMP bindings

Hello,

We haven't found mpz_nextprime in the list of gmp functions that have 
bindings in integer-gmp, and we would like to call it from a Haskell 
project.

We have first looked at a few simple examples of using the FFI but found 
several difficulties:
- The mapping between Integer and the C data types isn't explicited 
anywhere
- The gmp function gives its result by writing it in its second 
argument, instead of returning it.
   Building a wrapper for it that allocates the resulting Integer 
wouldn't be trivial because of how it could interact with the GC

Then we looked at how integer-gmp itself does it, it seems to be writing 
lots of cmm wrappers that call inside of the GHC runtime.

Is there an easier way to build a binding for a gmp function than to 
hack integer-gmp and recompile ghc ?

Thanks,
Robin Morisset & Florian Bourse

Gmane