blob: 017d03b020390e187c99fc129361dc837a509dbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
{-# LANGUAGE OverloadedStrings #-}
module Bangs (Bangs) where
import Data.Aeson
import Data.Aeson.Types (Parser)
import Data.Text (Text)
import qualified Data.Map.Strict as M
-- The map stored is equivalent to `HM.HashMap Shortcut URL`.
-- For now, we're omitting category information as I don't want to force our
-- own custom bangs to need that info.
data Bangs = Bangs (M.Map Text Text) deriving (Show)
instance FromJSON Bangs where
parseJSON b = fmap (Bangs . M.fromList) $
(parseJSON b :: Parser [Value])
>>= mapM (withObject "Bang" $ \ob ->
(,) <$> ob .: "t" <*> ob .: "u")
|