marshal-contt 0.1.2.0 → 0.1.2.1
raw patch · 3 files changed
+15/−9 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Foreign.Marshal.ContT: allocaArrayWith0Of :: Storable a => Fold s a -> s -> ContT r IO (Ptr a)
+ Foreign.Marshal.ContT: allocaArrayWith0Of :: Storable a => Fold s a -> s -> a -> ContT r IO (Ptr a)
- Foreign.Marshal.ContT: allocaBytes :: Int -> ContT r IO (Ptr a)
+ Foreign.Marshal.ContT: allocaBytes :: forall a r. Int -> ContT r IO (Ptr a)
- Foreign.Marshal.ContT: allocaBytesAligned :: Int -> Int -> ContT r IO (Ptr a)
+ Foreign.Marshal.ContT: allocaBytesAligned :: forall a r. Int -> Int -> ContT r IO (Ptr a)
- Foreign.Marshal.ContT: callocBytes :: Int -> ContT r IO (Ptr a)
+ Foreign.Marshal.ContT: callocBytes :: forall a r. Int -> ContT r IO (Ptr a)
Files
- CHANGELOG.md +4/−0
- marshal-contt.cabal +1/−1
- src/Foreign/Marshal/ContT.hs +10/−8
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for marshal-contt +## 0.1.2.1 -- 2019-09-14++* Fix documentation bugs.+ ## 0.1.2.0 -- 2019-09-14 * Reimplement `calloc` and friends in terms of `alloca` to make them
marshal-contt.cabal view
@@ -1,5 +1,5 @@ name: marshal-contt-version: 0.1.2.0+version: 0.1.2.1 synopsis: A ContT-based wrapper for Haskell-to-C marshalling functions. description: See <https://github.com/typedrat/marshal-contt/blob/master/README.md>. homepage: https://github.com/typedrat/marshal-contt
src/Foreign/Marshal/ContT.hs view
@@ -50,6 +50,8 @@ import Control.Lens.Fold import Control.Lens.Getter import Control.Lens.Indexed+-- For documentation:+import Control.Lens.Type ( IndexedTraversal, IndexedLens ) import Control.Monad.Cont import qualified Data.ByteString as BS import qualified Data.ByteString.Short as SBS@@ -65,7 +67,7 @@ import Foreign.Ptr import Foreign.Storable --- | 'alloca' is a continuation that provides access to a pointer into a+-- | 'alloca' @\@a@ is a continuation that provides access to a pointer into a -- temporary block of memory sufficient to hold values of type @a@. alloca :: Storable a => ContT r IO (Ptr a) alloca = ContT C.alloca@@ -82,14 +84,14 @@ -- | 'allocaBytes' @n@ is a continuation that provides access to a pointer into -- a temporary block of memory sufficient to hold @n@ bytes, with -- machine-standard alignment.-allocaBytes :: Int -> ContT r IO (Ptr a)+allocaBytes :: forall a r. Int -> ContT r IO (Ptr a) allocaBytes size = ContT $ C.allocaBytes size {-# INLINE allocaBytes #-} -- | 'allocaBytesAligned' @n@ @a@ is a continuation that provides access to a -- pointer into a temporary block of memory sufficient to hold @n@ bytes, -- with @a@-byte alignment.-allocaBytesAligned :: Int -> Int -> ContT r IO (Ptr a)+allocaBytesAligned :: forall a r. Int -> Int -> ContT r IO (Ptr a) allocaBytesAligned size align = ContT $ C.allocaBytesAligned size align {-# INLINE allocaBytesAligned #-} @@ -105,7 +107,7 @@ -- --- | 'calloc' is a continuation that provides access to a pointer into a+-- | 'calloc' @\@a@ is a continuation that provides access to a pointer into a -- temporary block of zeroed memory sufficient to hold values of type @a@. calloc :: forall a r. Storable a => ContT r IO (Ptr a) calloc = do@@ -118,7 +120,7 @@ -- | 'callocBytes' @n@ is a continuation that provides access to a pointer into -- a temporary block of zeroed memory sufficient to hold @n@ bytes, with -- machine-standard alignment.-callocBytes :: Int -> ContT r IO (Ptr a)+callocBytes :: forall a r. Int -> ContT r IO (Ptr a) callocBytes size = do ptr <- allocaBytes size liftIO $ fillBytes ptr 0 size@@ -140,7 +142,7 @@ allocaArrayWith = allocaArrayWith' return {-# INLINE allocaArrayWith #-} --- Why isn't this defined as `allocaArrayWithOf' traversed`? I don't want to+-- Why isn't this defined as `allocaArrayWithOf' folded`? I don't want to -- lose the potential performance benefits of a specialized `length`. allocaArrayWith' :: (Foldable f, Storable b) => (a -> ContT r IO b) @@ -247,8 +249,8 @@ -- | 'allocaArrayWith0Of' @t@ works in the same way as 'allocaArrayWith0', but -- using the 'Fold' @t@ rather than any 'Foldable' instance.-allocaArrayWith0Of :: (Storable a) => Fold s a -> s -> ContT r IO (Ptr a)-allocaArrayWith0Of fold = allocaArrayWithOf' fold return +allocaArrayWith0Of :: (Storable a) => Fold s a -> s -> a -> ContT r IO (Ptr a)+allocaArrayWith0Of fold = allocaArrayWith0Of' fold return {-# INLINE allocaArrayWith0Of #-} allocaArrayWith0Of' :: (Storable b)