packages feed

fast-combinatorics 0.1.0.1 → 0.1.0.2

raw patch · 5 files changed

+43/−43 lines, 5 files

Files

bench/Bench.hs view
@@ -1,7 +1,7 @@ module Main where  import           Criterion.Main-import           Lib+import           Numeric.Combinatorics import qualified Math.Combinatorics.Binomial as Ext import qualified Math.Combinatorics.Factorial as Ext 
fast-combinatorics.cabal view
@@ -1,5 +1,5 @@ name:                fast-combinatorics-version:             0.1.0.1+version:             0.1.0.2 synopsis:            Fast combinatorics. description:         Fast combinatorics code with a high level of safety guaranteed by writing it in ATS. homepage:            https://github.com//fast-combinatorics#readme@@ -23,7 +23,7 @@ library   c-sources:           cbits/fast-combinatorics.c   hs-source-dirs:      src-  exposed-modules:     Lib+  exposed-modules:     Numeric.Combinatorics   build-depends:       base >= 4.7 && < 5                      , composition-prelude   default-language:    Haskell2010
− src/Lib.hs
@@ -1,39 +0,0 @@-{-# LANGUAGE ForeignFunctionInterface #-}--module Lib-    ( factorial-    , choose-    , doubleFactorial-    , isPrime-    ) where--import Control.Composition-import           Foreign.C-import Data.Word--foreign import ccall unsafe factorial_ats :: CInt -> CInt-foreign import ccall unsafe choose_ats :: CInt -> CInt -> CInt-foreign import ccall unsafe double_factorial :: CInt -> CInt-foreign import ccall unsafe is_prime_ats :: CInt -> CBool--convertBool :: CBool -> Bool-convertBool = go . fromIntegral-    where-        go :: Word8 -> Bool-        go 0 = False-        go 1 = True-        go _ = False--isPrime :: Int -> Bool-isPrime = convertBool . is_prime_ats . fromIntegral--{-@ choose :: { n : Nat | n >= 0 } -> { k : Nat | k >= 0 && k <= n } -> Int @-}-choose :: Int -> Int -> Int-choose = fromIntegral .* on choose_ats fromIntegral--doubleFactorial :: Int -> Int-doubleFactorial = fromIntegral . double_factorial . fromIntegral--{-@ factorial :: { n : Nat | n <= 0 } -> Int @-}-factorial :: Int -> Int-factorial = fromIntegral . factorial_ats . fromIntegral
+ src/Numeric/Combinatorics.hs view
@@ -0,0 +1,39 @@+{-# LANGUAGE ForeignFunctionInterface #-}++module Numeric.Combinatorics+    ( factorial+    , choose+    , doubleFactorial+    , isPrime+    ) where++import           Control.Composition+import           Data.Word+import           Foreign.C++foreign import ccall unsafe factorial_ats :: CInt -> CInt+foreign import ccall unsafe choose_ats :: CInt -> CInt -> CInt+foreign import ccall unsafe double_factorial :: CInt -> CInt+foreign import ccall unsafe is_prime_ats :: CInt -> CBool++convertBool :: CBool -> Bool+convertBool = go . fromIntegral+    where+        go :: Word8 -> Bool+        go 0 = False+        go 1 = True+        go _ = False++isPrime :: Int -> Bool+isPrime = convertBool . is_prime_ats . fromIntegral++{-@ choose :: { n : Nat | n >= 0 } -> { k : Nat | k >= 0 && k <= n } -> Int @-}+choose :: Int -> Int -> Int+choose = fromIntegral .* on choose_ats fromIntegral++doubleFactorial :: Int -> Int+doubleFactorial = fromIntegral . double_factorial . fromIntegral++{-@ factorial :: { n : Nat | n <= 0 } -> Int @-}+factorial :: Int -> Int+factorial = fromIntegral . factorial_ats . fromIntegral
test/Spec.hs view
@@ -1,4 +1,4 @@-import           Lib+import           Numeric.Combinatorics import           Test.Hspec import           Test.Hspec.QuickCheck import qualified Math.Combinatorics.Binomial as Ext