Robin Morisset | 26 Jul 12:20 2012

Making extra GMP bindings


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 

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 
- 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 ?

Robin Morisset & Florian Bourse