json-stream 0.4.1.5 → 0.4.2.0
raw patch · 3 files changed
+21/−6 lines, 3 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Data.JsonStream.Parser: instance Data.Semigroup.Semigroup (Data.JsonStream.Parser.Parser a)
Files
- Data/JsonStream/Parser.hs +15/−3
- changelog.md +3/−0
- json-stream.cabal +3/−3
Data/JsonStream/Parser.hs view
@@ -81,6 +81,10 @@ import Data.Monoid (Monoid, mappend, mempty) #endif +#if MIN_VERSION_base(4,10,0)+import Data.Semigroup (Semigroup(..))+#endif+ import Control.Applicative import qualified Data.Aeson as AE import qualified Data.ByteString.Char8 as BS@@ -166,19 +170,27 @@ -- >>> let parser = arrayOf $ "key1" .: (arrayOf value) <> "key2" .: (arrayOf value) -- >>> parseByteString parser test :: [Int] -- [1,2,5,6]+#if MIN_VERSION_base(4,10,0) instance Monoid (Parser a) where mempty = ignoreVal- mappend m1 m2 = Parser $ \tok -> process (callParse m1 tok) (callParse m2 tok)+ mappend = (<>)+instance Semigroup (Parser a) where+ (<>) m1 m2 =+#else+instance Monoid (Parser a) where+ mempty = ignoreVal+ mappend m1 m2 =+#endif+ Parser $ \tok -> process (callParse m1 tok) (callParse m2 tok) where process (Yield v np1) p2 = Yield v (process np1 p2) process p1 (Yield v np2) = Yield v (process p1 np2)- process (Done ctx ntok) (Done {}) = Done ctx ntok+ process (Done ctx ntok) Done {} = Done ctx ntok process (MoreData (np1, ntok)) (MoreData (np2, _)) = MoreData (Parser $ \tok -> process (callParse np1 tok) (callParse np2 tok), ntok) process (Failed err) _ = Failed err process _ (Failed err) = Failed err process _ _ = Failed "Unexpected error in parallel processing <|>"- -- | Match items from the first parser, if none is matched, return items -- from the second parser. Constant-space if second parser returns
changelog.md view
@@ -1,3 +1,6 @@+# 0.4.2.0+Added Semigroup instance, compatibility with base-4.11+ # 0.4.1.5 Renamed `_js_decode_string` function to avoid conflict with `aeson`.
json-stream.cabal view
@@ -1,5 +1,5 @@ name: json-stream-version: 0.4.1.5+version: 0.4.2.0 synopsis: Incremental applicative JSON parser description: Easy to use JSON parser fully supporting incremental parsing. Parsing grammar in applicative form.@@ -64,7 +64,7 @@ includes: c_lib/lexer.h include-dirs: c_lib cc-options: -fPIC- Build-Depends: base >= 4.7 && <4.11+ Build-Depends: base >= 4.7 && <4.12 , doctest >= 0.9.3 , bytestring , text@@ -93,7 +93,7 @@ hs-source-dirs: test, . default-language: Haskell2010 ghc-options: -Wall- build-depends: base >=4.7 && <4.11+ build-depends: base >=4.7 && <4.12 , bytestring , text , aeson