Opened 4 years ago

Last modified 4 years ago

#9835 new feature request

Add bindings for marshaling to/from mpz_t

Reported by: dfranke Owned by:
Priority: normal Milestone:
Component: libraries (other) Version: 7.8.3
Keywords: integer-gmp Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #3489,#7860 Differential Rev(s):
Wiki Page:

Description

Please add bindings to allow efficient marshaling between Haskell Integer and C mpz_t's, e.g.:

  -- Wraps a (struct __mpz_struct*).
  type Mpz = Ptr ()

  toMpz :: Integer -> IO Mpz
  fromMpz :: Mpz -> IO Integer

This would be useful for efficiently interfacing with foreign code that uses GMP.

Change History (4)

comment:1 Changed 4 years ago by hvr

For one, integer-gmp has been completely rewritten, see #9281. Otoh, things like this should easily be implementable outside of integer-gmp in a 3rd party package.

Alas, conversions between Integer and a Mpz pointer will involve allocations and memcpys

comment:2 Changed 4 years ago by dfranke

Things like this should easily be implementable outside of integer-gmp in a 3rd party package.

I wrote it this morning :-). But since it relies on internals of both integer-gmp (treating Integer non-opaquely) and libgmp (treating struct __mpz_struct non-opaquely), I think having it merged into integer-gmp would create fewer maintenance headaches.

comment:3 Changed 4 years ago by thomie

comment:4 Changed 4 years ago by thomie

Note: See TracTickets for help on using tickets.