@@ -58,10 +58,12 @@ import Control.Applicative
58import Control.Monad
58import Control.Monad
59import Data.Aeson hiding (Bool, String)
59import Data.Aeson hiding (Bool, String)
60import qualified Data.Attoparsec.Text as A
60import qualified Data.Attoparsec.Text as A
61+import Data.Bifunctor (first)
61import qualified Data.CaseInsensitive as CI
62import qualified Data.CaseInsensitive as CI
62import Data.Foldable (foldl')
63import Data.Foldable (foldl')
63import Data.Function (on)
64import Data.Function (on)
64import Data.Hashable
65import Data.Hashable
66+import qualified Data.HashMap.Strict as Map
65import Data.List (intersperse)
67import Data.List (intersperse)
66import Data.List (elemIndex, nub, sortOn)
68import Data.List (elemIndex, nub, sortOn)
67import Data.Semigroup hiding (Sum)
69import Data.Semigroup hiding (Sum)
@@ -165,8 +167,9 @@ instance FromJSON Global where
165instance ToJSON Global where
167instance ToJSON Global where
166 toJSON = toJSON . global
168 toJSON = toJSON . global
168−instance TextKey Global where
170+instance FromJSON v => FromJSON (Map Global v) where
169− toKey = mkGlobal
171+ parseJSON = fmap (Map.fromList . map (first mkGlobal) . Map.toList)
171gid :: Format a (Global -> a)
174gid :: Format a (Global -> a)
172gid = later (Build.fromText . global)
175gid = later (Build.fromText . global)
@@ -174,8 +177,9 @@ gid = later (Build.fromText . global)
174newtype Local = Local { local :: Text }
177newtype Local = Local { local :: Text }
175 deriving (Eq, Ord, Show, Generic, Hashable, FromJSON, ToJSON, IsString)
178 deriving (Eq, Ord, Show, Generic, Hashable, FromJSON, ToJSON, IsString)
177−instance TextKey Local where
180+instance FromJSON v => FromJSON (Map Local v) where
178− toKey = Local
181+ parseJSON = fmap (Map.fromList . map (first Local) . Map.toList)
180lid :: Format a (Local -> a)
184lid :: Format a (Local -> a)
181lid = later (Build.fromText . local)
185lid = later (Build.fromText . local)