@@ -58,10 +58,12 @@ import Control.Applicative
5858import Control.Monad
5959import Data.Aeson hiding (Bool, String)
6060import qualified Data.Attoparsec.Text as A
61+import Data.Bifunctor (first)
6162import qualified Data.CaseInsensitive as CI
6263import Data.Foldable (foldl')
6364import Data.Function (on)
6465import Data.Hashable
66+import qualified Data.HashMap.Strict as Map
6567import Data.List (intersperse)
6668import Data.List (elemIndex, nub, sortOn)
6769import Data.Semigroup hiding (Sum)
@@ -165,8 +167,9 @@ instance FromJSON Global where
165167instance ToJSON Global where
166168 toJSON = toJSON . global
167169
168−instance TextKey Global where
169− toKey = mkGlobal
170+instance FromJSON v => FromJSON (Map Global v) where
171+ parseJSON = fmap (Map.fromList . map (first mkGlobal) . Map.toList)
172+ . parseJSON
170173
171174gid :: Format a (Global -> a)
172175gid = later (Build.fromText . global)
@@ -174,8 +177,9 @@ gid = later (Build.fromText . global)
174177newtype Local = Local { local :: Text }
175178 deriving (Eq, Ord, Show, Generic, Hashable, FromJSON, ToJSON, IsString)
176179
177−instance TextKey Local where
178− toKey = Local
180+instance FromJSON v => FromJSON (Map Local v) where
181+ parseJSON = fmap (Map.fromList . map (first Local) . Map.toList)
182+ . parseJSON
179183
180184lid :: Format a (Local -> a)
181185lid = later (Build.fromText . local)