{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
module Data.Yaml.TH
(
decodeFile
, Value (..)
, Parser
, Object
, Array
, object
, array
, (.=)
, (.:)
, (.:?)
, (.!=)
, FromJSON (..)
) where
import Data.Yaml hiding (decodeFile)
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
decodeFile :: forall a. (Lift a, FromJSON a) => FilePath -> Q (TExp a)
decodeFile path = do
addDependentFile path
runIO (decodeFileEither path) >>= \case
Left err -> fail (prettyPrintParseException err)
Right x -> fmap TExp (lift (x :: a))