summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs/haskell/xmonad-tv/src/THEnv
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2020-10-23 21:02:02 +0200
committermakefu <github@syntax-fehler.de>2020-10-23 21:02:02 +0200
commite8b6cc0587929a7ebd0d00f83d298640b20b055f (patch)
treee0f813b8264119a84d6b8c32fa68041c8541ab59 /tv/5pkgs/haskell/xmonad-tv/src/THEnv
parentfd41a76d4cab2765f9ef95ce5322b7bffe52b8a7 (diff)
parent242530680d5dcb37a5a023d0b8f6155ab441cead (diff)
Merge remote-tracking branch 'lass/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