@@ -30,7 +30,6 @@ import Language.Haskell.TH.Quote
31import Data.Yaml hiding (decodeFile)
31import Data.Yaml hiding (decodeFile)
33−#if MIN_VERSION_template_haskell(2,9,0)
34-- | Decode a YAML file at compile time. Only available on GHC version @7.8.1@
33-- | Decode a YAML file at compile time. Only available on GHC version @7.8.1@
35-- or higher.
34-- or higher.
@@ -47,18 +46,13 @@ import Data.Yaml hiding (decodeFile)
47decodeFile :: forall a. (Lift a, FromJSON a) => FilePath -> Q (TExp a)
46decodeFile :: forall a. (Lift a, FromJSON a) => FilePath -> Q (TExp a)
48decodeFile path = do
47decodeFile path = do
49 addDependentFile path
48 addDependentFile path
50− runIO (decodeFileEither path) >>= \case
49+ x <- runIO $ decodeFileThrow path
51− Left err -> fail (prettyPrintParseException err)
52− Right x -> fmap TExp (lift (x :: a))
50+ fmap TExp (lift (x :: a))
55−decodeValue :: String -> Either String Value
56−decodeValue = decodeEither . encodeUtf8 . T.pack
58yamlExp :: String -> Q Exp
52yamlExp :: String -> Q Exp
59−yamlExp input = case decodeValue input of
53+yamlExp input = do
60− Left err -> fail err
54+ val <- runIO $ decodeThrow $ encodeUtf8 $ T.pack input
61− Right a -> lift a
55+ lift (val :: Value)
63-- | A @QuasiQuoter@ for YAML.
57-- | A @QuasiQuoter@ for YAML.