packages feed

bookhound-format 0.1.1.0 → 0.1.2.0

raw patch · 5 files changed

+40/−42 lines, 5 filesdep ~bookhoundPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: bookhound

API changes (from Hackage documentation)

Files

bookhound-format.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           bookhound-format-version:        0.1.1.0+version:        0.1.2.0 synopsis:       Parsers for usual data formats description:    Please see the README on GitHub at <https://github.com/albertprz/bookhound-format#readme> category:       Parsers@@ -73,10 +73,10 @@       DeriveTraversable       DeriveGeneric       GeneralizedNewtypeDeriving-  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wpartial-fields -Wincomplete-uni-patterns -Wredundant-constraints+  ghc-options: -Wcompat -Widentities -Wincomplete-record-updates -Wpartial-fields -Wincomplete-uni-patterns -Wredundant-constraints   build-depends:       base >=4.7 && <5-    , bookhound >=0.1.13.0+    , bookhound >=0.1.24.0 && <0.2     , containers >=0.6 && <1     , text >=2.0 && <3     , time >=1.9 && <2
src/Bookhound/Format/Operations/Finder.hs view
@@ -7,9 +7,9 @@ import Bookhound.Parsers.Number    (unsignedInt) import Bookhound.Parsers.String    (withinSquareBrackets) -import Bookhound.Format.SyntaxTrees.Json  (JsonExpression (..))-import Bookhound.Format.SyntaxTrees.Toml  (TomlExpression (..))-import Bookhound.Format.SyntaxTrees.Yaml  (YamlExpression (..))+import Bookhound.Format.SyntaxTrees.Json (JsonExpression (..))+import Bookhound.Format.SyntaxTrees.Toml (TomlExpression (..))+import Bookhound.Format.SyntaxTrees.Yaml (YamlExpression (..))   import Data.Either (fromRight)@@ -33,18 +33,18 @@   find f = listToMaybe . findAll f    findByKeys []       expr = Just expr-  findByKeys (x : xs) expr = findByKey x expr >>= findByKeys xs  where--    findByKey key = find (\(str, _) -> str == key)--  findByPath path = findByKeys pathSeq where+  findByKeys (x : xs) expr = findByKey x expr >>= findByKeys xs+    where+      findByKey key = find (\(str, _) -> str == key) -    pathSeq = fromRight [] $ runParser parsePath $ pack path-    parsePath = is '$' *> ((index <|> key) |*)+  findByPath path = findByKeys pathSeq+    where+      pathSeq = fromRight [] $ runParser parsePath $ pack path+      parsePath = is '$' *> ((index <|> key) |*) -    index = show <$> withinSquareBrackets unsignedInt-    key   = dot *> word-    word  = (noneOf ['.', '['] |*)+      index = show <$> withinSquareBrackets unsignedInt+      key   = dot *> word+      word  = (noneOf ['.', '['] |*)   
src/Bookhound/Format/Operations/ToJson.hs view
@@ -4,11 +4,11 @@ import Bookhound.ParserCombinators (IsMatch (..), maybeWithin, (<|>), (|*)) import Bookhound.Parsers.String    (spacing) -import Bookhound.Format.Parsers.Json      (json)-import Bookhound.Format.SyntaxTrees.Json  (JsonExpression (..))-import Bookhound.Format.SyntaxTrees.Toml  (TomlExpression (..))-import Bookhound.Format.SyntaxTrees.Xml   (XmlExpression (..))-import Bookhound.Format.SyntaxTrees.Yaml  (YamlExpression (..))+import Bookhound.Format.Parsers.Json     (json)+import Bookhound.Format.SyntaxTrees.Json (JsonExpression (..))+import Bookhound.Format.SyntaxTrees.Toml (TomlExpression (..))+import Bookhound.Format.SyntaxTrees.Xml  (XmlExpression (..))+import Bookhound.Format.SyntaxTrees.Yaml (YamlExpression (..))  import Data.Either (fromRight) import Data.Text   (pack)@@ -30,13 +30,12 @@     | tag == "literal"  = fromRight JsNull . runParser literalParser .                               pack . head . elems $ fields     | tag == "array"    = JsArray $ childExprToJson <$> exprs-    | tag == "object"   = JsObject . Map.fromList $ (\x -> (tagName x, childExprToJson x)) <$>-                                        exprs-    | otherwise          = JsNull   where--        literalParser = json <|> (JsString <$> maybeWithin spacing (isNot '<' |*))--        childExprToJson = toJson . head . (expressions)+    | tag == "object"   = JsObject . Map.fromList $+      (\x -> (tagName x, childExprToJson x)) <$> exprs+    | otherwise          = JsNull+    where+      literalParser = json <|> (JsString <$> maybeWithin spacing (isNot '<' |*))+      childExprToJson = toJson . head . expressions   instance ToJson YamlExpression where
src/Bookhound/Format/Parsers/Xml.hs view
@@ -62,6 +62,5 @@   is "<!--" *> (isNot '-' |*) <* is "-->"  - text :: Parser String text = (noneOf ['/', '>', ' ', '='] |+)
src/Bookhound/Format/SyntaxTrees/Xml.hs view
@@ -21,22 +21,22 @@    show XmlExpression { tagName = tag, .. }     | tag == "literal" = head . elems $ fields-    | otherwise        = "<" <> tag <> flds <> innerExprs   where--        innerExprs = if | null expressions -> "/>"-                        | otherwise        -> ">"  <> ending--        (sep, n) = if | ((tagName) . head) expressions == "literal" -> ("", 0)-                      | otherwise                                   -> ("\n", 2)+    | otherwise        = "<" <> tag <> flds <> innerExprs+    where+      innerExprs = if | null expressions -> "/>"+                      | otherwise        -> ">"  <> ending -        ending = stringify sep sep sep n (show <$> expressions) <> "</" <> tag <> ">"+      (sep, n) = if | ((tagName) . head) expressions == "literal" -> ("", 0)+                    | otherwise                                   -> ("\n", 2) -        flds | null fields = ""-             | otherwise = " " <> fieldsString where+      ending = stringify sep sep sep n (show <$> expressions) <> "</" <> tag <> ">" -            fieldsString = stringify " " "" "" 0 $ showFn <$> tuples-            showFn (x, y) = x <> "=" <> show y-            tuples = zip (keys fields) (elems fields)+      flds | null fields = ""+           | otherwise = " " <> fieldsString+        where+          fieldsString = stringify " " "" "" 0 $ showFn <$> tuples+          showFn (x, y) = x <> "=" <> show y+          tuples = zip (keys fields) (elems fields)