hgmp: Haskell interface to GMP

[ bsd3, library, numeric ] [ Propose Tags ]

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).

Supports only GHC with integer-gmp, this might change if there's any demand.


[Skip to Readme]
Versions [RSS] [faq] 0.1.0.0, 0.1.0.1, 0.1.1, 0.1.2
Change log CHANGELOG.md
Dependencies base (>=4.8 && <4.17), ghc-bignum (==1.0.*), ghc-prim (>=0.4 && <0.8), integer-gmp (==1.0.*) [details]
License BSD-3-Clause
Copyright 2016,2017 Claude Heiland-Allen
Author Claude Heiland-Allen
Maintainer claude@mathr.co.uk
Category Numeric
Home page https://code.mathr.co.uk/hgmp
Source repo head: git clone https://code.mathr.co.uk/hgmp.git
this: git clone https://code.mathr.co.uk/hgmp.git(tag v0.1.2)
Uploaded by ClaudeHeilandAllen at 2021-01-16T18:48:47Z
Distributions NixOS:0.1.2
Downloads 2912 total (58 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-01-16 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates


Readme for hgmp-0.1.2

[back to package description]

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