bits 0.2.1 → 0.3
raw patch · 3 files changed
+19/−6 lines, 3 filesdep ~bytesPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: bytes
API changes (from Hackage documentation)
Files
- CHANGELOG.markdown +4/−0
- bits.cabal +1/−1
- src/Data/Bits/Coding.hs +14/−5
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+0.3+---+* Support for `bytes` 0.8+ 0.2.1 ----- * Claim to be Trustworthy
bits.cabal view
@@ -1,6 +1,6 @@ name: bits category: Data, Serialization-version: 0.2.1+version: 0.3 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE
src/Data/Bits/Coding.hs view
@@ -122,16 +122,25 @@ {-# INLINE getBit #-} instance MonadGet m => MonadGet (Coding m) where- type Unchecked (Coding m) = Unchecked m+ type Remaining (Coding m) = Remaining m type Bytes (Coding m) = Bytes m skip = getAligned . skip {-# INLINE skip #-}- uncheckedSkip = getAligned . uncheckedSkip- {-# INLINE uncheckedSkip #-} lookAhead (Coding m) = Coding $ \k i b -> lookAhead (m k i b) {-# INLINE lookAhead #-}- uncheckedLookAhead = getAligned . uncheckedLookAhead- {-# INLINE uncheckedLookAhead #-}+ lookAheadM (Coding m) = Coding $ \k i b -> lookAheadE (m (distribute k) i b) >>= factor+ where+ distribute k Nothing i' b' = return $ Left $ k (Nothing) i' b'+ distribute k (Just a) i' b' = return $ Right $ k (Just a) i' b'+ factor = either id id+ {-# INLINE lookAheadM #-}+ lookAheadE (Coding m) = Coding $ \k i b -> lookAheadE (m (distribute k) i b) >>= factor+ where+ distribute k (Left e) i' b' = return $ Left $ k (Left e) i' b'+ distribute k (Right a) i' b' = return $ Right $ k (Right a) i' b'+ factor = either id id+ {-# INLINE lookAheadE #-}+ getBytes = getAligned . getBytes {-# INLINE getBytes #-} remaining = lift remaining