0

I've been using the hmpfr package for arbitrary precision numbers in haskell.

For efficiency i would like to use Storable Vectors instead of Boxed. There is a Storable instance for MPFR. However, whenever i use MPFR type numbers with Storable Vectors i get an exception:

   > singleton (one) :: Data.Vector.Storable.Vector MPFR
[*** Exception: MPFR.peek: Not needed and not applicable
CallStack (from HasCallStack):
  error, called at src/Data/Number/MPFR/FFIhelper.hsc:68:12 in hmpfr-0.4.4-8t6iOJHeIVcBH2uWEACcJE:Data.Number.MPFR.FFIhelper

Anyone have any ideas on how i can resolve this?

Anon
  • 375
  • 1
  • 7
  • 2
    I don't know for sure, but I suspect you're a bit out of luck here. Those numbers have finalizers that are supposed to deallocate the associated C memory when GC collects the Haskell value, and I can't think of an obvious way to "store" those finalizers in the vector, nor to prevent them from running before the vector is collected. – Daniel Wagner Sep 29 '22 at 02:37

0 Answers0