module Data.Yaml.Util where
import qualified Data.Yaml.Pretty as YamlP
import Data.Yaml
import Data.ByteString (ByteString)
import Data.ByteString.Char8 as B
encodeYaml :: ToJSON a => a -> ByteString
encodeYaml = YamlP.encodePretty YamlP.defConfig
printYaml :: ToJSON a => a -> IO ()
printYaml = B.putStrLn . encodeYaml
decodeYaml :: FromJSON a => ByteString -> Either ParseException a
decodeYaml = decodeEither'
decodeYamlFile :: FromJSON a => FilePath -> IO (Either ParseException a)
decodeYamlFile = decodeFileEither