1 From c88e67e675bc4a990da53863c7fb42e67bcf9847 Mon Sep 17 00:00:00 2001
2 From: Julian Ospald <hasufell@posteo.de>
3 Date: Sun, 10 Oct 2021 00:46:36 +0200
4 Subject: [PATCH] cabal-install-parsers: Allow to build with aeson >=2 (#546)
6 * Allow to build with aeson >=2
7 * Allow to build haskell-ci with aeson >=2 as well
9 cabal-install-parsers/cabal-install-parsers.cabal | 2 +-
10 haskell-ci.cabal | 2 +-
11 src/HaskellCI/YamlSyntax.hs | 10 ++++++++++
12 3 files changed, 12 insertions(+), 2 deletions(-)
14 diff --git a/haskell-ci.cabal b/haskell-ci.cabal
15 index 670e0da9..3b99150f 100644
16 --- a/haskell-ci.cabal
17 +++ b/haskell-ci.cabal
18 @@ -153,7 +153,7 @@ library haskell-ci-internal
23 + , aeson ^>=1.5.6.0 || ^>=2.0.0.0
24 , attoparsec ^>=0.13.2.4
26 , base16-bytestring ^>=1.0.1.0
27 diff --git a/src/HaskellCI/YamlSyntax.hs b/src/HaskellCI/YamlSyntax.hs
28 index 47634056..1c98f835 100644
29 --- a/src/HaskellCI/YamlSyntax.hs
30 +++ b/src/HaskellCI/YamlSyntax.hs
33 {-# LANGUAGE DeriveFoldable #-}
34 {-# LANGUAGE DeriveFunctor #-}
35 {-# LANGUAGE DeriveTraversable #-}
36 @@ -24,7 +25,12 @@ import Data.Monoid (Endo (..))
38 import qualified Data.Aeson as Aeson
39 import qualified Data.Aeson.Encoding as AE
40 +#if MIN_VERSION_aeson(2,0,0)
41 +import qualified Data.Aeson.Key as AK
42 +import qualified Data.Aeson.KeyMap as AKM
44 import qualified Data.HashMap.Strict as HM
46 import qualified Data.List.NonEmpty as NE
47 import qualified Data.Map.Strict as M
48 import qualified Data.Text as T
49 @@ -340,7 +346,11 @@ encodeValue = TL.unpack . TLE.decodeUtf8 . AE.encodingToLazyByteString . enc whe
50 enc (Aeson.Array v) = AE.list enc (toList v)
51 enc (Aeson.Object m) = AE.dict AE.text enc M.foldrWithKey (toMap m)
53 +#if MIN_VERSION_aeson(2,0,0)
54 + toMap = M.fromList . fmap (\(k, v) -> (AK.toText k, v)) . AKM.toList
56 toMap = M.fromList . HM.toList
59 -- a 'Line' is comments before in and actual text after!
60 data Line = Line [String] ShowS