Subject: Re: [Haskell-cafe] ANN: hmpfr-0.3.2 (requires integer-simple, supports mpfr 3.0.0)
From: Michal Konečný <[email-masked]>
To: Daniel Peebles <[email-masked]>
Date: Fri, 4 Mar 2011 21:49:13 +0000

Hello Dan,

Thank your for your suggestions.  

I implemented the dependency on integer-simple because I need hmpfr to work in 
the short term.  In the long term, I would like to adopt a better approach.  
At the moment I do not know enough about ghc internals to be able to determine 
the approach, so I welcome your pointers.  I know that Aleš, who knows more 
about the ghc internals, has tried various things but could not make hmpfr 
work with the current integer-gmp.

I did not file a bug because there was a similar ghc ticket open for quite 
some time (#601) and it has been closed when it became possible to use 
integer-simple instead of integer-gmp.  That is why I felt that the best 
solution to the problem at present is to use integer-simple.

I am not an expert but based on what I read experts say on the topic I 
concluded that it is close-to-impossible to make ghc+integer-gmp work with 
libraries such as mpfr that heavily use gmp.

Of the suggested solutions we are aware of, the one that seems to me and Aleš 
most promising is to create a clone of gmp that differs from the original only 
in the names of all exported symbols and distribute it as a part of ghc to be 
dynamically linked with all executables produced by ghc.  The clone could be 
produced using a script to allow easy updates with new versions of gmp.  I 
would be interested whether someone has been trying or has plans to try to 
implement this approach.  The reason why I like this approach than writing cmm 
wrappers around MPFR and prim importing them is that it is more maintainable 
and also opens the way for other libraries that depend on gmp to work with 
ghc.

Michal

On Friday 04 Mar 2011 20:27:10 you wrote:
> According to Duncan Coutts (whom I asked about this issue in #ghc), the
> solution here is to use the new foreign import prim machinery to talk to
> MPFR. This prevents GC from occurring during the MPFR calls and will make
> everything work nicely without reimplementing GMP.
> 
> Dan
> 
> On Fri, Mar 4, 2011 at 3:09 PM, Daniel Peebles <[email-masked]>
> wrote: Have you submitted a bug report to GHC of why it can't work with
> the current integer-gmp binding? I know that GHC's collector is collecting
> MPFR's temporary data, but maybe it'd be good to get a discussion going on
> what can be done to stop it from doing this even in the context of the
> existing integer-gmp + GHC's allocator (even if this needs to be a patch
> to MPFR to talk to GHC a bit here and there). Might it help to go through
> CMM like the GMP binding does, for example?
> 
> I'd really like to see libraries that use GMP work nicely with GHC, without
> going and reimplementing GMP more slowly and so on.

-- 
|o| Michal Konecny <[email-masked]>
|o|    http://www-users.aston.ac.uk/~konecnym/
|o|    office: (+42) (0)121 204 3462 
|o| PGP key http://www-users.aston.ac.uk/~konecnym/ki.aston