packages feed

yaml 0.11.9.0 → 0.11.10.0

raw patch · 3 files changed

+19/−22 lines, 3 files

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # ChangeLog for yaml +## 0.11.10.0++* Undo previous change (breakage with aeson 2)+ ## 0.11.9.0  * Data.Yaml.Pretty: provide key-sorting function with path to parent object [#206](https://github.com/snoyberg/yaml/pull/206)
src/Data/Yaml/Pretty.hs view
@@ -7,7 +7,6 @@     , Config     , getConfCompare     , setConfCompare-    , setConfComparePos     , getConfDropNull     , setConfDropNull     , defConfig@@ -51,7 +50,7 @@ -- | -- @since 0.8.13 data Config = Config-  { confCompare :: JSONPath -> Text -> Text -> Ordering -- ^ Function used to sort keys in objects+  { confCompare :: Text -> Text -> Ordering -- ^ Function used to sort keys in objects   , confDropNull :: Bool -- ^ Drop null values from objects   } @@ -63,20 +62,14 @@  -- | -- @since 0.8.13-getConfCompare :: Config -> JSONPath -> Text -> Text -> Ordering+getConfCompare :: Config -> Text -> Text -> Ordering getConfCompare = confCompare  -- | Sets ordering for object keys -- -- @since 0.8.13 setConfCompare :: (Text -> Text -> Ordering) -> Config -> Config-setConfCompare cmp c = c { confCompare = \_ps -> cmp }---- | Set ordering for object keys that depends on location of object in the document.------ @since 0.11.9-setConfComparePos :: (JSONPath -> Text -> Text -> Ordering) -> Config -> Config-setConfComparePos cmp c = c { confCompare = cmp }+setConfCompare cmp c = c { confCompare = cmp }  -- | -- @since 0.8.24@@ -90,17 +83,17 @@ setConfDropNull m c = c { confDropNull = m }  pretty :: Config -> Value -> YamlBuilder-pretty cfg = go []-  where go ps (Object o) = let sort = sortBy (confCompare cfg (reverse ps) `on` fst)-                               select-                                 | confDropNull cfg = HM.filter (/= Null)-                                 | otherwise        = id-                        in mapping (sort $ fmap (first toText) $ HM.toList $ HM.mapWithKey (\k -> go (Key (toText k): ps)) $ select o)-        go ps (Array a) = array $ zipWith (\ix -> go (Index ix: ps)) [0..] (V.toList a)-        go _ Null       = null-        go _ (String s) = string s-        go _ (Number n) = scientific n-        go _ (Bool b)   = bool b+pretty cfg = go+  where go (Object o) = let sort = sortBy (confCompare cfg `on` fst)+                            select+                              | confDropNull cfg = HM.filter (/= Null)+                              | otherwise        = id+                        in mapping (sort $ fmap (first toText) $ HM.toList $ HM.map go $ select o)+        go (Array a)  = array (go <$> V.toList a)+        go Null       = null+        go (String s) = string s+        go (Number n) = scientific n+        go (Bool b)   = bool b  -- | Configurable 'encode'. --
yaml.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           yaml-version:        0.11.9.0+version:        0.11.10.0 synopsis:       Support for parsing and rendering YAML documents. description:    README and API documentation are available at <https://www.stackage.org/package/yaml> category:       Data