on master help sign in
Merge pull request #208 from snoyberg/aeson2
35fe989Michael Snoyman
.github/workflows/tests.yml+1−1
@@ -14,7 +14,7 @@ jobs:
14 fail-fast: false
14 fail-fast: false
15 matrix:
15 matrix:
16 os: [ubuntu-latest, macos-latest, windows-latest]
16 os: [ubuntu-latest, macos-latest, windows-latest]
17− resolver: [nightly, lts-15, lts-14, lts-12, lts-11, lts-9]
17+ resolver: [nightly, lts-20, lts-15, lts-14, lts-12, lts-11, lts-9]
18 # Bugs in GHC make it crash too often to be worth running
18 # Bugs in GHC make it crash too often to be worth running
19 exclude:
19 exclude:
20 - os: macos-latest
20 - os: macos-latest
stack.yaml+1−1
@@ -1,4 +1,4 @@
1−resolver: lts-14.22
1+resolver: lts-20.5
2
2
3flags:
3flags:
4 yaml:
4 yaml:
yaml/ChangeLog.md+4
@@ -1,5 +1,9 @@
1# ChangeLog for yaml
1# ChangeLog for yaml
2
2
3+## 0.11.10.0
4+
5+* Undo previous change (breakage with aeson 2)
6+
3## 0.11.9.0
7## 0.11.9.0
4
8
5* Data.Yaml.Pretty: provide key-sorting function with path to parent object [#206](https://github.com/snoyberg/yaml/pull/206)
9* Data.Yaml.Pretty: provide key-sorting function with path to parent object [#206](https://github.com/snoyberg/yaml/pull/206)
yaml/package.yaml+1−1
@@ -1,5 +1,5 @@
1name: yaml
1name: yaml
2−version: 0.11.9.0
2+version: 0.11.10.0
3synopsis: Support for parsing and rendering YAML documents.
3synopsis: Support for parsing and rendering YAML documents.
4description: README and API documentation are available at <https://www.stackage.org/package/yaml>
4description: README and API documentation are available at <https://www.stackage.org/package/yaml>
5category: Data
5category: Data
yaml/src/Data/Yaml/Pretty.hs+14−21
@@ -7,7 +7,6 @@ module Data.Yaml.Pretty
7 , Config
7 , Config
8 , getConfCompare
8 , getConfCompare
9 , setConfCompare
9 , setConfCompare
10− , setConfComparePos
11 , getConfDropNull
10 , getConfDropNull
12 , setConfDropNull
11 , setConfDropNull
13 , defConfig
12 , defConfig
@@ -51,7 +50,7 @@ type Key = Text
51-- |
50-- |
52-- @since 0.8.13
51-- @since 0.8.13
53data Config = Config
52data Config = Config
54− { confCompare :: JSONPath -> Text -> Text -> Ordering -- ^ Function used to sort keys in objects
53+ { confCompare :: Text -> Text -> Ordering -- ^ Function used to sort keys in objects
55 , confDropNull :: Bool -- ^ Drop null values from objects
54 , confDropNull :: Bool -- ^ Drop null values from objects
56 }
55 }
57
56
@@ -63,20 +62,14 @@ defConfig = Config mempty False
63
62
64-- |
63-- |
65-- @since 0.8.13
64-- @since 0.8.13
66−getConfCompare :: Config -> JSONPath -> Text -> Text -> Ordering
65+getConfCompare :: Config -> Text -> Text -> Ordering
67getConfCompare = confCompare
66getConfCompare = confCompare
68
67
69-- | Sets ordering for object keys
68-- | Sets ordering for object keys
70--
69--
71-- @since 0.8.13
70-- @since 0.8.13
72setConfCompare :: (Text -> Text -> Ordering) -> Config -> Config
71setConfCompare :: (Text -> Text -> Ordering) -> Config -> Config
73−setConfCompare cmp c = c { confCompare = \_ps -> cmp }
72+setConfCompare cmp c = c { confCompare = cmp }
74−
75−-- | Set ordering for object keys that depends on location of object in the document.
76−--
77−-- @since 0.11.9
78−setConfComparePos :: (JSONPath -> Text -> Text -> Ordering) -> Config -> Config
79−setConfComparePos cmp c = c { confCompare = cmp }
80
73
81-- |
74-- |
82-- @since 0.8.24
75-- @since 0.8.24
@@ -90,17 +83,17 @@ setConfDropNull :: Bool -> Config -> Config
90setConfDropNull m c = c { confDropNull = m }
83setConfDropNull m c = c { confDropNull = m }
91
84
92pretty :: Config -> Value -> YamlBuilder
85pretty :: Config -> Value -> YamlBuilder
93−pretty cfg = go []
86+pretty cfg = go
94− where go ps (Object o) = let sort = sortBy (confCompare cfg (reverse ps) `on` fst)
87+ where go (Object o) = let sort = sortBy (confCompare cfg `on` fst)
95− select
88+ select
96− | confDropNull cfg = HM.filter (/= Null)
89+ | confDropNull cfg = HM.filter (/= Null)
97− | otherwise = id
90+ | otherwise = id
98− in mapping (sort $ fmap (first toText) $ HM.toList $ HM.mapWithKey (\k -> go (Key (toText k): ps)) $ select o)
91+ in mapping (sort $ fmap (first toText) $ HM.toList $ HM.map go $ select o)
99− go ps (Array a) = array $ zipWith (\ix -> go (Index ix: ps)) [0..] (V.toList a)
92+ go (Array a) = array (go <$> V.toList a)
100− go _ Null = null
93+ go Null = null
101− go _ (String s) = string s
94+ go (String s) = string s
102− go _ (Number n) = scientific n
95+ go (Number n) = scientific n
103− go _ (Bool b) = bool b
96+ go (Bool b) = bool b
104
97
105-- | Configurable 'encode'.
98-- | Configurable 'encode'.
106--
99--
yaml/yaml.cabal+2−2
@@ -1,11 +1,11 @@
1cabal-version: 1.12
1cabal-version: 1.12
2
2
3−-- This file has been generated from package.yaml by hpack version 0.35.0.
3+-- This file has been generated from package.yaml by hpack version 0.35.1.
4--
4--
5-- see: https://github.com/sol/hpack
5-- see: https://github.com/sol/hpack
6
6
7name: yaml
7name: yaml
8−version: 0.11.8.0
8+version: 0.11.10.0
9synopsis: Support for parsing and rendering YAML documents.
9synopsis: Support for parsing and rendering YAML documents.
10description: README and API documentation are available at <https://www.stackage.org/package/yaml>
10description: README and API documentation are available at <https://www.stackage.org/package/yaml>
11category: Data
11category: Data