summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs/haskell/xmonad-tv/src/THEnv
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2020-10-18 19:25:11 +0200
committerlassulus <lassulus@lassul.us>2020-10-18 19:25:11 +0200
commit5b29d7a435092aafcea15f588effbb6f45a6a56e (patch)
tree07340bc138d7bdea55bbb33e50fc2fa1b5387a57 /tv/5pkgs/haskell/xmonad-tv/src/THEnv
parent9626d3cda953929e903b5a06595e98972cb08ffc (diff)
parentb034f63f7a2e4361b32c33c0e1a980eecf1a5aa6 (diff)
Merge remote-tracking branch 'ni/master'
Diffstat (limited to 'tv/5pkgs/haskell/xmonad-tv/src/THEnv')
-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