on master help sign in
Merge pull request #208 from snoyberg/aeson2

aeson 2 in build matrix, revert breaking change

commit35fe989ab041a689213afd185e16fd2f92533d53 authorMichael Snoyman <michael@snoyman.com> dateTue 7 Feb 2023, 06:30 (4 years ago) parentb7aea3e69480c4
6 files changed+23−26
.github/workflows/tests.yml+1−1 stack.yaml+1−1 yaml/ChangeLog.md+4 yaml/package.yaml+1−1 yaml/src/Data/Yaml/Pretty.hs+14−21 yaml/yaml.cabal+2−2
.github/workflows/tests.yml+1−1
@@ -14,7 +14,7 @@ jobs:
1414 fail-fast: false
1515 matrix:
1616 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]
1818 # Bugs in GHC make it crash too often to be worth running
1919 exclude:
2020 - os: macos-latest
stack.yaml+1−1
@@ -1,4 +1,4 @@
1−resolver: lts-14.22
1+resolver: lts-20.5
22
33flags:
44 yaml:
yaml/ChangeLog.md+4
@@ -1,5 +1,9 @@
11# ChangeLog for yaml
22
3+## 0.11.10.0
4+
5+* Undo previous change (breakage with aeson 2)
6+
37## 0.11.9.0
48
59* 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 @@
11name: yaml
2−version: 0.11.9.0
2+version: 0.11.10.0
33synopsis: Support for parsing and rendering YAML documents.
44description: README and API documentation are available at <https://www.stackage.org/package/yaml>
55category: Data
yaml/src/Data/Yaml/Pretty.hs+14−21
@@ -7,7 +7,6 @@ module Data.Yaml.Pretty
77 , Config
88 , getConfCompare
99 , setConfCompare
10− , setConfComparePos
1110 , getConfDropNull
1211 , setConfDropNull
1312 , defConfig
@@ -51,7 +50,7 @@ type Key = Text
5150-- |
5251-- @since 0.8.13
5352data 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
5554 , confDropNull :: Bool -- ^ Drop null values from objects
5655 }
5756
@@ -63,20 +62,14 @@ defConfig = Config mempty False
6362
6463-- |
6564-- @since 0.8.13
66−getConfCompare :: Config -> JSONPath -> Text -> Text -> Ordering
65+getConfCompare :: Config -> Text -> Text -> Ordering
6766getConfCompare = confCompare
6867
6968-- | Sets ordering for object keys
7069--
7170-- @since 0.8.13
7271setConfCompare :: (Text -> Text -> Ordering) -> Config -> Config
73−setConfCompare cmp c = c { confCompare = \_ps -> 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 }
72+setConfCompare cmp c = c { confCompare = cmp }
8073
8174-- |
8275-- @since 0.8.24
@@ -90,17 +83,17 @@ setConfDropNull :: Bool -> Config -> Config
9083setConfDropNull m c = c { confDropNull = m }
9184
9285pretty :: Config -> Value -> YamlBuilder
93−pretty cfg = go []
94− where go ps (Object o) = let sort = sortBy (confCompare cfg (reverse ps) `on` fst)
95− select
96− | confDropNull cfg = HM.filter (/= Null)
97− | otherwise = id
98− in mapping (sort $ fmap (first toText) $ HM.toList $ HM.mapWithKey (\k -> go (Key (toText k): ps)) $ select o)
99− go ps (Array a) = array $ zipWith (\ix -> go (Index ix: ps)) [0..] (V.toList a)
100− go _ Null = null
101− go _ (String s) = string s
102− go _ (Number n) = scientific n
103− go _ (Bool b) = bool b
86+pretty cfg = go
87+ where go (Object o) = let sort = sortBy (confCompare cfg `on` fst)
88+ select
89+ | confDropNull cfg = HM.filter (/= Null)
90+ | otherwise = id
91+ in mapping (sort $ fmap (first toText) $ HM.toList $ HM.map go $ select o)
92+ go (Array a) = array (go <$> V.toList a)
93+ go Null = null
94+ go (String s) = string s
95+ go (Number n) = scientific n
96+ go (Bool b) = bool b
10497
10598-- | Configurable 'encode'.
10699--
yaml/yaml.cabal+2−2
@@ -1,11 +1,11 @@
11cabal-version: 1.12
22
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.
44--
55-- see: https://github.com/sol/hpack
66
77name: yaml
8−version: 0.11.8.0
8+version: 0.11.10.0
99synopsis: Support for parsing and rendering YAML documents.
1010description: README and API documentation are available at <https://www.stackage.org/package/yaml>
1111category: Data