tomland-1.3.3.3: Bidirectional TOML serialization
Copyright(c) 2018-2022 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe-Inferred
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
Alla = trueall "a"All True
Anya = trueany "a"Any False
Sum Inta = 11sum int "a"Sum 0
Product Inta = 11product int "a"Product 1
First Inta = 42first int "a"First Nothing
Last Boola = truelast 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