allow building with aeson >= 2.0
In aeson 2.0, Text has been replaced by the Key type and HashMap by the KeyMap interface. Accomodating this required adding some CPP in order to still be able to compile with aeson < 2.0. The required changes were: * Prevent Key from being re-exported by Utilities.Aeson, as it clashes with git-annex's own Key type. * Fix up convertion from String/Text to Key (or Text in aeson 1.*) in a couple of places * Import Data.Aeson.KeyMap instead of Data.HashMap.Strict, as they are mostly API-compatible. insertWith needs to be replaced by unionWith, however, as KeyMap lacks the former function.
This commit is contained in:
parent
55f71b0ebd
commit
ca596e7c54
5 changed files with 51 additions and 15 deletions
19
Remote.hs
19
Remote.hs
|
@ -5,7 +5,7 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE OverloadedStrings, CPP #-}
|
||||
|
||||
module Remote (
|
||||
Remote,
|
||||
|
@ -63,6 +63,9 @@ module Remote (
|
|||
|
||||
import Data.Ord
|
||||
import Data.String
|
||||
#if MIN_VERSION_aeson(2,0,0)
|
||||
import qualified Data.Aeson.Key as AK
|
||||
#endif
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Vector as V
|
||||
|
||||
|
@ -239,11 +242,17 @@ prettyPrintUUIDsWith optfield header descm showval uuidvals = do
|
|||
Nothing -> s
|
||||
Just val -> val ++ ": " ++ s
|
||||
jsonify hereu (u, optval) = object $ catMaybes
|
||||
[ Just (packString "uuid", toJSON' (fromUUID u :: String))
|
||||
, Just (packString "description", toJSON' $ finddescription u)
|
||||
, Just (packString "here", toJSON' $ hereu == u)
|
||||
[ Just ("uuid", toJSON' (fromUUID u :: String))
|
||||
, Just ("description", toJSON' $ finddescription u)
|
||||
, Just ("here", toJSON' $ hereu == u)
|
||||
, case (optfield, optval) of
|
||||
(Just field, Just val) -> Just (packString field, toJSON' val)
|
||||
(Just field, Just val) -> Just
|
||||
(
|
||||
#if MIN_VERSION_aeson(2,0,0)
|
||||
AK.fromText $
|
||||
#endif
|
||||
packString field
|
||||
, toJSON' val)
|
||||
_ -> Nothing
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue