hgmp

Haskell interface to GMP https://code.mathr.co.uk/hgmp

Latest on Hackage:0.1.1

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Claude Heiland-Allen
Maintained by claude@mathr.co.uk

hgmp

Haskell interface to GMP. Types and instances, and marshalling between Integer and Rational and the corresponding GMP types, along with raw foreign imports of GMP functions. Allows FFI to GMP code (whether in GMP itself or in third-party code that uses GMP).

A simple example illustrating binding to GMP's next probable-prime function:

{-# LANGUAGE ForeignFunctionInterface #-}

import Foreign.Ptr (Ptr(..))
import Numeric.GMP.Types (MPZ)
import Numeric.GMP.Utils (withInInteger, withOutInteger_)
import Numeric.GMP.Raw.Safe (mpz_nextprime)
import System.IO.Unsafe (unsafePerformIO)

nextPrime :: Integer -> Integer
nextPrime n =
  unsafePerformIO $
    withOutInteger_ $ \rop ->
      withInInteger n $ \op ->
        mpz_nextprime rop op

Changes

0.1.1

  • raw function foreign import bindings
  • define hsc2hs #alignment macro for older GHC versions

0.1.0.1

  • use hsc2hs's #alignment macro in Storable instances

0.1.0.0

  • initial release
Used by 1 package:
comments powered byDisqus