packages feed

bytes 0.6 → 0.7

raw patch · 3 files changed

+15/−94 lines, 3 filesdep +textdep ~binaryPVP ok

version bump matches the API change (PVP)

Dependencies added: text

Dependency ranges changed: binary

API changes (from Hackage documentation)

- Data.Bytes.Get: lookAheadE :: MonadGet m => m (Either a b) -> m (Either a b)
- Data.Bytes.Get: lookAheadM :: MonadGet m => m (Maybe a) -> m (Maybe a)
+ Data.Bytes.Serial: instance Serial Text

Files

bytes.cabal view
@@ -1,6 +1,6 @@ name:          bytes category:      Data, Serialization-version:       0.6+version:       0.7 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE@@ -42,11 +42,12 @@ library   build-depends:     base                      >= 4.3      && < 5,-    binary                    >= 0.5      && < 0.6,+    binary                    >= 0.5      && < 0.8,     bytestring                >= 0.9      && < 0.11,     cereal                    >= 0.3.5    && < 0.4,     ghc-prim,     mtl                       >= 2.0      && < 2.2,+    text                      >= 0.2      && < 1,     transformers              >= 0.2      && < 0.4,     transformers-compat       >= 0.1      && < 1,     void                      >= 0.6      && < 0.7
src/Data/Bytes/Get.hs view
@@ -69,14 +69,6 @@   -- Fails if @ga@ fails.   lookAhead :: m a -> m a -  -- | Like 'lookAhead', but consume the input if @gma@ returns 'Just _'.-  -- Fails if @gma@ fails.-  lookAheadM :: m (Maybe a) -> m (Maybe a)--  -- | Like 'lookAhead', but consume the input if @gea@ returns 'Right _'.-  -- Fails if @gea@ fails.-  lookAheadE :: m (Either a b) -> m (Either a b)-   -- | Get the next up to @n@ bytes as a lazy ByteString, without consuming them.   uncheckedLookAhead :: Unchecked m -> m (Bytes m) #ifndef HLINT@@ -213,10 +205,6 @@   {-# INLINE uncheckedSkip #-}   lookAhead = B.lookAhead   {-# INLINE lookAhead #-}-  lookAheadM = B.lookAheadM-  {-# INLINE lookAheadM #-}-  lookAheadE = B.lookAheadE-  {-# INLINE lookAheadE #-}   uncheckedLookAhead = B.uncheckedLookAhead   {-# INLINE uncheckedLookAhead #-}   ensure n = do@@ -266,10 +254,6 @@   {-# INLINE uncheckedSkip #-}   lookAhead = S.lookAhead   {-# INLINE lookAhead #-}-  lookAheadM = S.lookAheadM-  {-# INLINE lookAheadM #-}-  lookAheadE = S.lookAheadE-  {-# INLINE lookAheadE #-}   uncheckedLookAhead = S.uncheckedLookAhead   {-# INLINE uncheckedLookAhead #-}   getBytes = S.getBytes@@ -312,115 +296,39 @@   type Bytes (Lazy.StateT s m) = Bytes m   lookAhead (Lazy.StateT m) = Lazy.StateT (lookAhead . m)   {-# INLINE lookAhead #-}-  lookAheadM (Lazy.StateT m) = Lazy.StateT (liftM factor . lookAheadE . liftM distribute . m)-    where-    distribute (Nothing, s') = Left (Nothing, s')-    distribute (Just a, s') = Right (Just a, s')-    factor = either id id-  {-# INLINE lookAheadM #-}-  lookAheadE (Lazy.StateT m) = Lazy.StateT (liftM factor . lookAheadE . liftM distribute . m)-    where-    distribute (Left a, s') = Left (Left a, s')-    distribute (Right b, s') = Right (Right b, s')-    factor = either id id-  {-# INLINE lookAheadE #-}  instance MonadGet m => MonadGet (Strict.StateT s m) where   type Unchecked (Strict.StateT s m) = Unchecked m   type Bytes (Strict.StateT s m) = Bytes m   lookAhead (Strict.StateT m) = Strict.StateT (lookAhead . m)   {-# INLINE lookAhead #-}-  lookAheadM (Strict.StateT m) = Strict.StateT (liftM factor . lookAheadE . liftM distribute . m)-    where-    distribute (Nothing, s') = Left (Nothing, s')-    distribute (Just a, s') = Right (Just a, s')-    factor = either id id-  {-# INLINE lookAheadM #-}-  lookAheadE (Strict.StateT m) = Strict.StateT (liftM factor . lookAheadE . liftM distribute . m)-    where-    distribute (Left a, s') = Left (Left a, s')-    distribute (Right b, s') = Right (Right b, s')-    factor = either id id-  {-# INLINE lookAheadE #-}  instance MonadGet m => MonadGet (ReaderT e m) where   type Unchecked (ReaderT e m) = Unchecked m   type Bytes (ReaderT e m) = Bytes m   lookAhead (ReaderT m) = ReaderT (lookAhead . m)   {-# INLINE lookAhead #-}-  lookAheadM (ReaderT m) = ReaderT (lookAheadM . m)-  {-# INLINE lookAheadM #-}-  lookAheadE (ReaderT m) = ReaderT (lookAheadE . m)-  {-# INLINE lookAheadE #-}  instance (MonadGet m, Monoid w) => MonadGet (Lazy.WriterT w m) where   type Unchecked (Lazy.WriterT w m) = Unchecked m   type Bytes (Lazy.WriterT w m) = Bytes m   lookAhead (Lazy.WriterT m) = Lazy.WriterT (lookAhead m)   {-# INLINE lookAhead #-}-  lookAheadM (Lazy.WriterT m) = Lazy.WriterT (liftM factor $ lookAheadE $ liftM distribute m)-    where-    distribute (Nothing, s') = Left (Nothing, s')-    distribute (Just a, s') = Right (Just a, s')-    factor = either id id-  {-# INLINE lookAheadM #-}-  lookAheadE (Lazy.WriterT m) = Lazy.WriterT (liftM factor $ lookAheadE $ liftM distribute m)-    where-    distribute (Left a, s') = Left (Left a, s')-    distribute (Right b, s') = Right (Right b, s')-    factor = either id id-  {-# INLINE lookAheadE #-}  instance (MonadGet m, Monoid w) => MonadGet (Strict.WriterT w m) where   type Unchecked (Strict.WriterT w m) = Unchecked m   type Bytes (Strict.WriterT w m) = Bytes m   lookAhead (Strict.WriterT m) = Strict.WriterT (lookAhead m)   {-# INLINE lookAhead #-}-  lookAheadM (Strict.WriterT m) = Strict.WriterT (liftM factor $ lookAheadE $ liftM distribute m)-    where-    distribute (Nothing, s') = Left (Nothing, s')-    distribute (Just a, s') = Right (Just a, s')-    factor = either id id-  {-# INLINE lookAheadM #-}-  lookAheadE (Strict.WriterT m) = Strict.WriterT (liftM factor $ lookAheadE $ liftM distribute m)-    where-    distribute (Left a, s') = Left (Left a, s')-    distribute (Right b, s') = Right (Right b, s')-    factor = either id id-  {-# INLINE lookAheadE #-}  instance (MonadGet m, Monoid w) => MonadGet (Strict.RWST r w s m) where   type Unchecked (Strict.RWST r w s m) = Unchecked m   type Bytes (Strict.RWST r w s m) = Bytes m   lookAhead (Strict.RWST m) = Strict.RWST $ \r s -> lookAhead (m r s)   {-# INLINE lookAhead #-}-  lookAheadM (Strict.RWST m) = Strict.RWST (\r s -> liftM factor $ lookAheadE $ liftM distribute $ m r s )-    where-    distribute (Nothing, s',w') = Left (Nothing, s', w')-    distribute (Just a, s',w') = Right (Just a, s', w')-    factor = either id id-  {-# INLINE lookAheadM #-}-  lookAheadE (Strict.RWST m) = Strict.RWST (\r s -> liftM factor $ lookAheadE $ liftM distribute $ m r s)-    where-    distribute (Left a, s', w') = Left (Left a, s', w')-    distribute (Right b, s', w') = Right (Right b, s', w')-    factor = either id id-  {-# INLINE lookAheadE #-}  instance (MonadGet m, Monoid w) => MonadGet (Lazy.RWST r w s m) where   type Unchecked (Lazy.RWST r w s m) = Unchecked m   type Bytes (Lazy.RWST r w s m) = Bytes m   lookAhead (Lazy.RWST m) = Lazy.RWST $ \r s -> lookAhead (m r s)   {-# INLINE lookAhead #-}-  lookAheadM (Lazy.RWST m) = Lazy.RWST (\r s -> liftM factor $ lookAheadE $ liftM distribute $ m r s )-    where-    distribute (Nothing, s',w') = Left (Nothing, s', w')-    distribute (Just a, s',w') = Right (Just a, s', w')-    factor = either id id-  {-# INLINE lookAheadM #-}-  lookAheadE (Lazy.RWST m) = Lazy.RWST (\r s -> liftM factor $ lookAheadE $ liftM distribute $ m r s)-    where-    distribute (Left a, s', w') = Left (Left a, s', w')-    distribute (Right b, s', w') = Right (Right b, s', w')-    factor = either id id-  {-# INLINE lookAheadE #-}
src/Data/Bytes/Serial.hs view
@@ -40,6 +40,10 @@ import Data.ByteString.Lazy as Lazy import Data.ByteString as Strict import Data.Int+import Data.Text as SText+import Data.Text.Encoding as SText+import Data.Text.Lazy as LText+import Data.Text.Lazy.Encoding as LText import Data.Void import Data.Word import Foreign.ForeignPtr@@ -76,6 +80,14 @@   deserialize = do     n <- getWord64host     getLazyByteString (fromIntegral n)++instance Serial SText.Text where+  serialize = serialize . SText.encodeUtf8+  deserialize = SText.decodeUtf8 `fmap` deserialize++instance Serial LText.Text where+  serialize = serialize . LText.encodeUtf8+  deserialize = LText.decodeUtf8 `fmap` deserialize  instance Serial () instance Serial a => Serial [a]