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

Module documentation for 0.1.1

There are no documented modules for this package.

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
Depends on 3 packages:
Used by 2 packages:
comments powered byDisqus