tomland-1.3.1.0: Bidirectional TOML serialization
Copyright(c) 2018-2020 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Toml.Codec.Combinator.Monoid

Description

TOML-specific combinators for converting between TOML and Haskell Monoid wrapper data types. These codecs are especially handy when you are implementing the Partial Options Monoid pattern.

Haskell Type TOML TomlCodec Default on missing field
All a = true all "a" All True
Any a = true any "a" Any False
Sum Int a = 11 sum int "a" Sum 0
Product Int a = 11 product int "a" Product 1
First Int a = 42 first int "a" First Nothing
Last Bool a = true last bool "a" Last Nothing

Since: 1.3.0.0

Synopsis

Codecs for Monoids

Bool wrappers

all :: Key -> TomlCodec All Source #

Codec for All wrapper for boolean values. Returns All True on missing fields.

Decodes to All True when the key is not present.

Since: 1.2.1.0

any :: Key -> TomlCodec Any Source #

Codec for Any wrapper for boolean values. Returns Any False on missing fields.

Decodes to Any False when the key is not present.

Since: 1.2.1.0

Num wrappers

sum :: Num a => (Key -> TomlCodec a) -> Key -> TomlCodec (Sum a) Source #

Codec for Sum wrapper for given converter's values.

Decodes to Sum 0 when the key is not present.

Since: 1.2.1.0

product :: Num a => (Key -> TomlCodec a) -> Key -> TomlCodec (Product a) Source #

Codec for Product wrapper for given converter's values.

Decodes to Product 1 when the key is not present.

Since: 1.2.1.0

Maybe wrappers

first :: (Key -> TomlCodec a) -> Key -> TomlCodec (First a) Source #

Codec for First wrapper for given converter's values.

Decodes to First Nothing when the key is not present.

Since: 1.2.1.0

last :: (Key -> TomlCodec a) -> Key -> TomlCodec (Last a) Source #

Codec for Last wrapper for given converter's values.

Decodes to Last Nothing when the key is not present.

Since: 1.2.1.0