@@ -0,0 +1,44 @@
1+{-# LANGUAGE LambdaCase #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE TemplateHaskell #-}
8+ -- * Re-exports from "Data.Yaml"
22+import Data.Yaml hiding (decodeFile)
23+import Language.Haskell.TH
24+import Language.Haskell.TH.Syntax
26+-- | Decode a @yaml@ file at compile time. Only available on GHC version @7.8.1@
34+-- {-\# LANGUAGE TemplateHaskell \#-}
37+-- config = $$('decodeFile' "config.yaml")
39+decodeFile :: forall a. (Lift a, FromJSON a) => FilePath -> Q (TExp a)
41+ addDependentFile path
42+ runIO (decodeFileEither path) >>= \case
43+ Left err -> fail (prettyPrintParseException err)
44+ Right x -> fmap TExp (lift (x :: a))