Yaml encoding via Yaml.toByteString instead of Yaml.encode

This commit is contained in:
Tom Sydney Kerckhove 2022-12-25 15:47:52 +01:00
parent b49e3f4201
commit cbfdf3bd52

View File

@ -35,10 +35,11 @@ import Autodocodec.Yaml.IO
import Autodocodec.Yaml.Schema import Autodocodec.Yaml.Schema
import Data.ByteString import Data.ByteString
import qualified Data.Yaml as Yaml import qualified Data.Yaml as Yaml
import qualified Data.Yaml.Builder as Yaml
-- | Encode a value as a Yaml 'ByteString' via its type's 'codec'. -- | Encode a value as a Yaml 'ByteString' via its type's 'codec'.
encodeYamlViaCodec :: HasCodec a => a -> ByteString encodeYamlViaCodec :: HasCodec a => a -> ByteString
encodeYamlViaCodec = Yaml.encode . Autodocodec encodeYamlViaCodec = Yaml.toByteString . Autodocodec
-- | Parse a Yaml 'ByteString' using a type's 'codec'. -- | Parse a Yaml 'ByteString' using a type's 'codec'.
eitherDecodeYamlViaCodec :: HasCodec a => ByteString -> Either Yaml.ParseException a eitherDecodeYamlViaCodec :: HasCodec a => ByteString -> Either Yaml.ParseException a