bytestring-strict-builder 0.4.3 → 0.4.5
raw patch · 2 files changed
+20/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ ByteString.StrictBuilder: builderPtrFiller :: Builder -> (Int -> (Ptr Word8 -> IO ()) -> result) -> result
+ ByteString.StrictBuilder: instance GHC.Show.Show ByteString.StrictBuilder.Builder
Files
bytestring-strict-builder.cabal view
@@ -1,7 +1,7 @@ name: bytestring-strict-builder version:- 0.4.3+ 0.4.5 category: Text, ByteString, Builders, Serialization synopsis:
library/ByteString/StrictBuilder.hs view
@@ -4,6 +4,7 @@ builderBytes, builderChunksBuilder, builderLength,+ builderPtrFiller, bytes, lazyBytes, asciiIntegral,@@ -55,13 +56,18 @@ fromString = bytes . fromString +instance Show Builder where+ show =+ show . builderBytes + -- * ------------------------- {-| Efficiently constructs a strict bytestring. -}+{-# INLINE builderBytes #-} builderBytes :: Builder -> ByteString builderBytes (Builder size population) = C.unsafeCreate size $ \ptr -> A.populationPtrUpdate population ptr $> ()@@ -71,6 +77,7 @@ Does so efficiently using the internal APIs of \"bytestring\", without producing any intermediate representation. -}+{-# INLINE builderChunksBuilder #-} builderChunksBuilder :: Builder -> G.Builder builderChunksBuilder (Builder size population) = G.ensureFree size <> A.populationChunksBuilder population@@ -78,9 +85,21 @@ {-| /O(1)/. Gets the size of the bytestring that is to be produced. -}+{-# INLINE builderLength #-} builderLength :: Builder -> Int builderLength (Builder size population) = size++{-|+Use the builder to populate a buffer.+It is your responsibility to ensure that the bounds are not exceeded.+-}+{-# INLINE builderPtrFiller #-}+builderPtrFiller ::+ Builder -> + (Int -> (Ptr Word8 -> IO ()) -> result) {-^ A continuation on the amount of bytes to be written and the action populating the pointer. -} -> result+builderPtrFiller (Builder size (A.Population ptrUpdate)) cont =+ cont size (void . ptrUpdate) -- * Primitives