summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-10-03 03:23:18 +0200
committertv <tv@krebsco.de>2020-10-03 03:26:37 +0200
commit291bc460d522b2e2c785ec3c3b71a80f22b67853 (patch)
tree7d532dae80c75f224293ebdacbabd844536b0f09 /tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs
parent0cbb18c16e17e220ec3a7d9a44da8f22f083dd48 (diff)
tv xmonad: read screen/font width from build env
Diffstat (limited to 'tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs')
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs b/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs
new file mode 100644
index 000000000..2a3a0e523
--- /dev/null
+++ b/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module THEnv.JSON where
+
+import Data.Aeson (eitherDecode,FromJSON)
+import Data.ByteString.Lazy.Char8 (pack)
+import Language.Haskell.TH.Syntax (Exp,Lift(lift),Q)
+import THEnv (getCompileEnv)
+import Control.Monad
+
+getCompileEnvJSON :: (FromJSON a) => String -> Q a
+getCompileEnvJSON name =
+ either error (id :: a -> a) . eitherDecode . pack <$> getCompileEnv name
+
+getCompileEnvJSONExp ::
+ forall proxy a. (FromJSON a, Lift a) => proxy a -> String -> Q Exp
+getCompileEnvJSONExp _ =
+ (lift :: a -> Q Exp) <=< getCompileEnvJSON