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