Copyright | (c) Daniel Firth 2018 |
---|---|
License | BSD3 |
Maintainer | locallycompact@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
This file defines yaml pretty printers with additional MonadThrow helpers and RIO display functionality.
- module Data.Yaml
- module Data.Yaml.Pretty
- class ToJSON a => ToPrettyYaml a where
- encodeFilePretty :: MonadIO m => ToPrettyYaml a => FilePath -> a -> m ()
- decodeFileThrow :: (MonadIO m, FromJSON c, MonadThrow m) => FilePath -> m c
- displayPrettyYaml :: ToPrettyYaml a => a -> Utf8Builder
- decodeFileThrowLogged :: (MonadReader env m, MonadThrow m, MonadIO m, HasLogFunc env, FromJSON b, ToPrettyYaml b, Typeable b) => FilePath -> m b
- encodeFilePrettyLogged :: (MonadReader env m, MonadThrow m, MonadIO m, HasLogFunc env, ToPrettyYaml b, Typeable b) => FilePath -> b -> m ()
Documentation
module Data.Yaml
module Data.Yaml.Pretty
Yaml Pretty Printers
class ToJSON a => ToPrettyYaml a where Source #
Augments ToJSON by allowing specification of a fieldOrder for printing.
data Person = { name :: Text, age :: Int, job :: Text } deriving (Eq, FromJSON, Generic, Show, ToJSON) instance ToPrettyYaml Person where fieldOrder = const ["name", "age", "job"]
fieldOrder :: a -> [Text] Source #
The order that detected fields should be printed in, fields that aren't found in this function will be printed non-deterministically.
dropNull :: a -> Bool Source #
Whether to drop null elements on this type.
toPrettyYaml :: a -> ByteString Source #
Prints a Yaml ByteString according to specified fieldOrder.
encodeFilePretty :: MonadIO m => ToPrettyYaml a => FilePath -> a -> m () Source #
A version of Data.Yaml's encodeFile using toPrettyYaml
instead of toJSON
RIO Helpers (Codecs and Logging)
decodeFileThrow :: (MonadIO m, FromJSON c, MonadThrow m) => FilePath -> m c Source #
A version of Data.Yaml's decodeFileEither lifted to MonadThrow
displayPrettyYaml :: ToPrettyYaml a => a -> Utf8Builder Source #
Displays a ToPrettyYaml instance as Utf8, for use with RIO log functions
decodeFileThrowLogged :: (MonadReader env m, MonadThrow m, MonadIO m, HasLogFunc env, FromJSON b, ToPrettyYaml b, Typeable b) => FilePath -> m b Source #
decodeFileThrow with info logging, reports what was parsed via RIO's logInfo
encodeFilePrettyLogged :: (MonadReader env m, MonadThrow m, MonadIO m, HasLogFunc env, ToPrettyYaml b, Typeable b) => FilePath -> b -> m () Source #
encodeFilePretty with info logging, reports what was saved to disk via RIO's logInfo