@@ -23,19 +23,22 @@ import Data.Yaml hiding (decodeFile)
23import Language.Haskell.TH
23import Language.Haskell.TH
24import Language.Haskell.TH.Syntax
24import Language.Haskell.TH.Syntax
26−-- | Decode a @yaml@ file at compile time.
26+-- | Decode a @yaml@ file at compile time. Only available on GHC version @7.8.1@
29−-- {-# LANGUAGE TemplateHaskell #-}
34+-- {-\# LANGUAGE TemplateHaskell \#-}
31-- config :: Config
36-- config :: Config
32-- config = $$('decodeFile' "config.yaml")
37-- config = $$('decodeFile' "config.yaml")
36decodeFile :: forall a. (Lift a, FromJSON a) => FilePath -> Q (TExp a)
39decodeFile :: forall a. (Lift a, FromJSON a) => FilePath -> Q (TExp a)
37decodeFile path = do
40decodeFile path = do
38 addDependentFile path
41 addDependentFile path
39 runIO (decodeFileEither path) >>= \case
42 runIO (decodeFileEither path) >>= \case
40 Left err -> fail (prettyPrintParseException err)
43 Left err -> fail (prettyPrintParseException err)
41− Right x -> TExp <$> lift (x :: a)
44+ Right x -> fmap TExp (lift (x :: a))