packages feed

inline-c 0.5.5.2 → 0.5.5.3

raw patch · 5 files changed

+17/−11 lines, 5 filesdep ~basedep ~template-haskellPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, template-haskell

API changes (from Hackage documentation)

+ Language.C.Inline: type family WithPtrsPtrs a :: *;
+ Language.C.Inline: }
+ Language.C.Inline.Context: type family VecCtxScalar a :: *;
+ Language.C.Inline.Context: }
- Language.C.Inline: class WithPtrs a where type family WithPtrsPtrs a :: * withPtrs_ f = do { (x, _) <- withPtrs f; return x }
+ Language.C.Inline: class WithPtrs a where type WithPtrsPtrs a :: * withPtrs_ f = do { (x, _) <- withPtrs f; return x } where {
- Language.C.Inline.Context: class VecCtx a where type family VecCtxScalar a :: *
+ Language.C.Inline.Context: class VecCtx a where type VecCtxScalar a :: * where {
- Language.C.Inline.HaskellIdentifier: parseHaskellIdentifier :: CParser i m => m HaskellIdentifier
+ Language.C.Inline.HaskellIdentifier: parseHaskellIdentifier :: forall i m. CParser i m => m HaskellIdentifier
- Language.C.Inline.Internal: parseTypedC :: CParser HaskellIdentifier m => AntiQuoters -> m ParseTypedC
+ Language.C.Inline.Internal: parseTypedC :: forall m. CParser HaskellIdentifier m => AntiQuoters -> m ParseTypedC
- Language.C.Types: tangleParameterDeclaration :: ParameterDeclaration i -> ParameterDeclaration i
+ Language.C.Types: tangleParameterDeclaration :: forall i. ParameterDeclaration i -> ParameterDeclaration i

Files

README.md view
@@ -85,7 +85,7 @@       // Read and sum 5 integers       int i, sum = 0, tmp;       for (i = 0; i < 5; i++) {-        scanf("%d ", &tmp);+        scanf("%d", &tmp);         sum += tmp;       }       return sum;@@ -121,7 +121,7 @@     // Read and sum n integers     int i, sum = 0, tmp;     for (i = 0; i < $(int n); i++) {-      scanf("%d ", &tmp);+      scanf("%d", &tmp);       sum += tmp;     }     return sum;@@ -197,7 +197,8 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} import qualified Language.C.Inline as C-import qualified Data.Vector.Storable.Mutable as V+import qualified Data.Vector.Storable as V+import qualified Data.Vector.Storable.Mutable as VM import           Data.Monoid ((<>)) import           Foreign.C.Types @@ -205,19 +206,19 @@ -- 'C.baseCtx'. C.context (C.baseCtx <> C.vecCtx) -sumVec :: V.IOVector CDouble -> IO CDouble+sumVec :: VM.IOVector CDouble -> IO CDouble sumVec vec = [C.block| double {     double sum = 0;     int i;     for (i = 0; i < $vec-len:vec; i++) {       sum += $vec-ptr:(double *vec)[i];     }-    return sum+    return sum;   } |]  main :: IO () main = do-  x <- sumVec =<< V.fromList [1,2,3]+  x <- sumVec =<< V.thaw (V.fromList [1,2,3])   print x ``` @@ -232,7 +233,7 @@ exactly the same as the `vec-len` and `vec-ptr` counterparts, but with strict `ByteString`s.  The only difference is that it is no necessary to specify the type of the pointer from C -- it is always going to be-`unsigned char *`:+`char *`:  ``` {-# LANGUAGE TemplateHaskell #-}@@ -250,7 +251,7 @@     int {       int i, bits = 0;       for (i = 0; i < $bs-len:bs; i++) {-        unsigned char ch = $bs-ptr:bs[i];+        char ch = $bs-ptr:bs[i];         bits += (ch * 01001001001ULL & 042104210421ULL) % 017;       }       return bits;
changelog.md view
@@ -1,4 +1,4 @@-- 0.5.5.1: Add docs regarding internals. See issue #41.+- 0.5.5.2: Add docs regarding internals. See issue #41. - 0.5.5.1: Add support for Interruptible calls. The version skip is   simply because I forgot to update the changelog for 0.5.5.0. - 0.5.4.3: Fix haddock docs.
inline-c.cabal view
@@ -1,5 +1,5 @@ name:                inline-c-version:             0.5.5.2+version:             0.5.5.3 synopsis:            Write Haskell source files including C code inline. No FFI required. description:         See <https://github.com/fpco/inline-c/blob/master/README.md>. license:             MIT
src/Language/C/Inline/Context.hs view
@@ -422,7 +422,7 @@           hsExp' <- [| \cont -> BS.unsafeUseAsCString $(return hsExp) $ \ptr -> cont ptr  |]           return (hsTy, hsExp')         _ ->-          fail "impossible: got type different from `unsigned char' (bsCtx)"+          fail "impossible: got type different from `char *' (bsCtx)"   }  bsLenAntiQuoter :: AntiQuoter HaskellIdentifier
src/Language/C/Inline/FunPtr.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} @@ -37,7 +38,11 @@ mkFunPtrFromName name = do   i <- TH.reify name   case i of+#if MIN_VERSION_template_haskell(2,11,0)+    TH.VarI _ ty _ -> [| $(mkFunPtr (return ty)) $(TH.varE name) |]+#else     TH.VarI _ ty _ _ -> [| $(mkFunPtr (return ty)) $(TH.varE name) |]+#endif     _ -> fail "mkFunPtrFromName: expecting a variable as argument."  -- | @$('peekFunPtr' [t| 'CDouble' -> 'IO' 'CDouble' |])@ generates a foreign import