on master help sign in
Only compile Data.Yaml.TH on ghc >= 7.8.1
ab14a89Mitchell Rosen
Data/Yaml/TH.hs+8−5
@@ -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
25
25
26−-- | Decode a @yaml@ file at compile time.
26+-- | Decode a @yaml@ file at compile time. Only available on GHC version @7.8.1@
27+-- or higher.
28+--
29+-- @since 0.8.19.0
30+--
31+-- ==== __Examples__
27--
32--
28-- @
33-- @
29−-- {-# LANGUAGE TemplateHaskell #-}
34+-- {-\# LANGUAGE TemplateHaskell \#-}
30--
35--
31-- config :: Config
36-- config :: Config
32-- config = $$('decodeFile' "config.yaml")
37-- config = $$('decodeFile' "config.yaml")
33-- @
38-- @
34−--
35−-- @since 0.8.19.0
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))
yaml.cabal+2−1
@@ -68,7 +68,8 @@ library
68 Data.Yaml.Include
68 Data.Yaml.Include
69 Data.Yaml.Parser
69 Data.Yaml.Parser
70 Data.Yaml.Pretty
70 Data.Yaml.Pretty
71+ if impl(ghc >= 7.8.1)
71− Data.Yaml.TH
72+ exposed-modules: Data.Yaml.TH
72 other-modules:
73 other-modules:
73 Data.Yaml.Internal
74 Data.Yaml.Internal
74 ghc-options: -Wall
75 ghc-options: -Wall