tomland-1.2.0.0: Bidirectional TOML serialization
Safe HaskellNone
LanguageHaskell2010

Toml.Bi.Combinators

Description

Contains TOML-specific combinators for converting between TOML and user data types.

Synopsis

Basic codecs for primitive values

Boolean

bool :: Key -> TomlCodec Bool Source #

Codec for boolean values.

Integral numbers

integer :: Key -> TomlCodec Integer Source #

Codec for integer values.

natural :: Key -> TomlCodec Natural Source #

Codec for natural values.

int :: Key -> TomlCodec Int Source #

Codec for integer values.

word :: Key -> TomlCodec Word Source #

Codec for word values.

word8 :: Key -> TomlCodec Word8 Source #

Codec for word8 values.

Since: 1.2.0.0

Floating point numbers

double :: Key -> TomlCodec Double Source #

Codec for floating point values with double precision.

float :: Key -> TomlCodec Float Source #

Codec for floating point values.

Text types

text :: Key -> TomlCodec Text Source #

Codec for text values.

lazyText :: Key -> TomlCodec Text Source #

Codec for lazy text values.

byteString :: Key -> TomlCodec ByteString Source #

Codec for text values as ByteString.

lazyByteString :: Key -> TomlCodec ByteString Source #

Codec for text values as ByteString.

byteStringArray :: Key -> TomlCodec ByteString Source #

Codec for positive integer array values as ByteString.

Since: 1.2.0.0

lazyByteStringArray :: Key -> TomlCodec ByteString Source #

Codec for positive integer array values as lazy ByteString.

Since: 1.2.0.0

string :: Key -> TomlCodec String Source #

Codec for string values.

Time types

zonedTime :: Key -> TomlCodec ZonedTime Source #

Codec for zoned time values.

localTime :: Key -> TomlCodec LocalTime Source #

Codec for local time values.

day :: Key -> TomlCodec Day Source #

Codec for day values.

timeOfDay :: Key -> TomlCodec TimeOfDay Source #

Codec for time of day values.

Codecs for containers of primitives

arrayOf :: TomlBiMap a AnyValue -> Key -> TomlCodec [a] Source #

Codec for list of values. Takes converter for single value and returns a list of values.

arraySetOf :: Ord a => TomlBiMap a AnyValue -> Key -> TomlCodec (Set a) Source #

Codec for sets. Takes converter for single value and returns a set of values.

arrayIntSet :: Key -> TomlCodec IntSet Source #

Codec for sets of ints. Takes converter for single value and returns a set of ints.

arrayHashSetOf :: (Hashable a, Eq a) => TomlBiMap a AnyValue -> Key -> TomlCodec (HashSet a) Source #

Codec for hash sets. Takes converter for single hashable value and returns a set of hashable values.

arrayNonEmptyOf :: TomlBiMap a AnyValue -> Key -> TomlCodec (NonEmpty a) Source #

Codec for non- empty lists of values. Takes converter for single value and returns a non-empty list of values.

Additional codecs for custom types

textBy :: (a -> Text) -> (Text -> Either Text a) -> Key -> TomlCodec a Source #

Codec for text values with custom error messages for parsing.

read :: (Show a, Read a) => Key -> TomlCodec a Source #

Codec for values with a Read and Show instance.

enumBounded :: (Bounded a, Enum a, Show a) => Key -> TomlCodec a Source #

Codec for general nullary sum data types with a Bounded, Enum, and Show instance. This codec provides much better error messages than read for nullary sum types.

Since: 1.1.1.0

Combinators for tables

table :: forall a. TomlCodec a -> Key -> TomlCodec a Source #

Codec for tables. Use it when when you have nested objects.

nonEmpty :: forall a. TomlCodec a -> Key -> TomlCodec (NonEmpty a) Source #

Codec for NonEmpty list of values. Represented in TOML as array of tables.

list :: forall a. TomlCodec a -> Key -> TomlCodec [a] Source #

Codec for list of values. Represented in TOML as array of tables.

set :: forall a. Ord a => TomlCodec a -> Key -> TomlCodec (Set a) Source #

Codec for set of values. Represented in TOML as array of tables.

Since: 1.2.0.0

hashSet :: forall a. (Hashable a, Eq a) => TomlCodec a -> Key -> TomlCodec (HashSet a) Source #

Codec for HashSet of values. Represented in TOML as array of tables.

Since: 1.2.0.0

General construction of codecs

match :: forall a. TomlBiMap a AnyValue -> Key -> TomlCodec a Source #

General function to create bidirectional converters for key-value pairs. In order to use this function you need to create TomlBiMap for your type and AnyValue:

_MyType :: TomlBiMap MyType AnyValue

And then you can create codec for your type using match function:

myType :: Key -> TomlCodec MyType
myType = match _MyType