summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTony Zorman <soliditsallgood@mailbox.org>2022-03-24 10:58:13 +0100
committerJoey Hess <joeyh@joeyh.name>2022-03-24 11:33:28 -0400
commitc7bae27f009ccaae4d365dc2471c0725de2f5793 (patch)
treecec365633151a0d51a35b07a474d87005885c3ae
parent342d4dea8496b62d0b9f4567675fab9e152da8f6 (diff)
downloaddebug-me-c7bae27f009ccaae4d365dc2471c0725de2f5793.tar.gz
Support aeson 2.0
As per the aeson 2.0.0.0 changelog[1], starting with that version the map type used by Object is now abstract, as is the key type of that map. Related: https://github.com/haskell/aeson/pull/866 Related: https://github.com/haskell/aeson/pull/868 [1]: https://hackage.haskell.org/package/aeson-2.0.0.0/changelog
-rw-r--r--Gpg/Wot.hs13
-rw-r--r--debug-me.cabal2
2 files changed, 13 insertions, 2 deletions
diff --git a/Gpg/Wot.hs b/Gpg/Wot.hs
index 2a6d541..d916ebc 100644
--- a/Gpg/Wot.hs
+++ b/Gpg/Wot.hs
@@ -3,6 +3,7 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
-- | Gpg web of trust checking, using wotsap's JSON output
@@ -15,8 +16,13 @@ import JSON
import Network.HTTP.Client
import Network.HTTP.Client.TLS
import Data.List
-import qualified Data.HashMap.Strict as M
import qualified Data.Text as T
+#if MIN_VERSION_aeson(2, 0, 0)
+import qualified Data.Aeson.KeyMap as AM
+import qualified Data.Aeson.Key as AK
+#else
+import qualified Data.HashMap.Strict as M
+#endif
data WotStats = WotStats
{ key :: Node
@@ -43,9 +49,14 @@ data Node = Node
-- | wotsap's json has some upper-case fields; lowercase field for parsing
jsonLower :: Value -> Value
+#if MIN_VERSION_aeson(2, 0, 0)
+jsonLower (Object o) = Object . AM.mapKeyVal lowerKey id $ o
+ where lowerKey = AK.fromText . T.toLower . AK.toText
+#else
jsonLower (Object o) = Object . M.fromList . map lowerPair . M.toList $ o
where
lowerPair (k, v) = (T.toLower k, v)
+#endif
jsonLower x = x
instance FromJSON WotStats where
diff --git a/debug-me.cabal b/debug-me.cabal
index d859cbb..db7cc63 100644
--- a/debug-me.cabal
+++ b/debug-me.cabal
@@ -64,7 +64,7 @@ Executable debug-me
, stm-chans (>= 3.0)
, posix-pty (>= 0.2.1)
, terminal-size (>= 0.3)
- , aeson (>= 0.11 && < 1.5)
+ , aeson (>= 0.11 && < 2.1)
, sandi (>= 0.4)
, text (>= 1.2.2)
, optparse-applicative (>= 0.12)