bytebuild 0.3.5.0 → 0.3.6.0
raw patch · 4 files changed
+24/−3 lines, 4 filesdep ~primitivePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: primitive
API changes (from Hackage documentation)
+ Data.Bytes.Builder: replicate :: Int -> Word8 -> Builder
Files
- CHANGELOG.md +5/−0
- bytebuild.cabal +1/−1
- src/Data/Bytes/Builder.hs +15/−0
- src/Data/Bytes/Builder/Bounded.hs +3/−2
CHANGELOG.md view
@@ -5,6 +5,11 @@ `small-bytearray-builder` is now just a compatibility shim to ease the migration process. +## 0.3.6.0 -- 2020-06-30++* Add `replicate`.+* Fix compatibility with `primitive-0.7.1.0`.+ ## 0.3.5.0 -- 2020-05-01 * Add `wordLEB128` and `word64LEB128`.
bytebuild.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: bytebuild-version: 0.3.5.0+version: 0.3.6.0 synopsis: Serialize to a small byte arrays description: This is similar to the builder facilities provided by
src/Data/Bytes/Builder.hs view
@@ -118,10 +118,14 @@ -- * Encode Floating-Point Types -- ** Human-Readable , doubleDec+ -- * Replication+ , replicate -- * Control , flush ) where +import Prelude hiding (replicate)+ import Control.Exception (SomeException,toException) import Control.Monad.ST (ST,runST) import Control.Monad.IO.Class (MonadIO,liftIO)@@ -1129,6 +1133,17 @@ PM.writeByteArray arr off (fromIntegral (z + 0x30) :: Word8) go (off + 1) y else pure off++-- | Replicate a byte the given number of times.+replicate ::+ Int -- ^ Number of times to replicate the byte+ -> Word8 -- ^ Byte to replicate+ -> Builder+replicate !len !w = fromEffect len+ (\marr off -> do+ PM.setByteArray marr off len w+ pure (off + len)+ ) -- Based on C code from https://stackoverflow.com/a/5558614 -- For numbers less than 1073741829, this gives a correct answer.
src/Data/Bytes/Builder/Bounded.hs view
@@ -99,13 +99,14 @@ ) where import Arithmetic.Types (type (<=), type (:=:))-import Control.Monad.Primitive+import Control.Monad.Primitive (primitive_) import Control.Monad.ST (ST) import Control.Monad.ST.Run (runByteArrayST) import Data.Bits import Data.Bytes.Builder.Bounded.Unsafe (Builder(..)) import Data.Char (ord)-import Data.Primitive+import Data.Primitive (MutableByteArray(..),ByteArray,writeByteArray)+import Data.Primitive (readByteArray,newByteArray,unsafeFreezeByteArray) import Data.Primitive.ByteArray.Offset (MutableByteArrayOffset(..)) import Data.WideWord (Word128(Word128),Word256(Word256)) import GHC.Exts