aboutsummaryrefslogtreecommitdiff
path: root/src/Bangs.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bangs.hs')
-rw-r--r--src/Bangs.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Bangs.hs b/src/Bangs.hs
new file mode 100644
index 0000000..017d03b
--- /dev/null
+++ b/src/Bangs.hs
@@ -0,0 +1,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")
+