cereal-enumerator 0.2.1 → 0.3
raw patch · 2 files changed
+15/−12 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Serialize.Get.Enumerator: EOFError :: ParseError
Files
- Data/Serialize/Get/Enumerator.hs +14/−11
- cereal-enumerator.cabal +1/−1
Data/Serialize/Get/Enumerator.hs view
@@ -9,12 +9,11 @@ import Data.Monoid import Data.Typeable -import Data.Serialize.Get+import Data.Serialize import Data.Enumerator import Data.ByteString as BS data ParseError = ParseError String- | EOFError deriving (Show, Typeable) instance Exception ParseError@@ -24,16 +23,20 @@ iterGet :: Monad m => Get a -> Iteratee ByteString m a iterGet = continue . step . runGetPartial where- step p (Chunks xs) = loop p xs- step p EOF = case p mempty of+ step p (Chunks xs) = loop p (P.filter (not . BS.null) xs)+ step p EOF = case feed mempty (p mempty) of Done r _ -> yield r EOF- Partial{} -> throwError EOFError- Fail s -> throwError (ParseError s)+ Partial{} -> parseError "iterGet: divergent parser"+ Fail s -> parseError s loop p [] = continue (step p)- loop p (x:xs)- | BS.null x = loop p xs- | otherwise = case p x of+ loop p (x:xs) = case p x of Done r bs -> yield r $ Chunks $ if BS.null bs then xs else bs:xs- Partial c -> loop c xs- Fail s -> throwError (ParseError s)+ Partial k -> loop k xs+ Fail s -> parseError s++ parseError = throwError . ParseError++feed :: ByteString -> Result a -> Result a+feed s (Partial k) = k s+feed _ r = r
cereal-enumerator.cabal view
@@ -1,5 +1,5 @@ name: cereal-enumerator-version: 0.2.1+version: 0.3 synopsis: Deserialize things with cereal and enumerator license: PublicDomain author: Patrick Palka