Copyright | (c) 2018-2020 Kowainik |
---|---|
License | MPL-2.0 |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
TOML-specific combinators for converting between TOML and Haskell Set-like data types.
There are two way to represent list-like structures with the tomland
library.
Ordinary array sets of primitives:
foo = [100, 200, 300]
Sets via tables:
foo = [ {x = 100} , {x = 200} , {x = 300} ] OR [[foo]] x = 100 [[foo]] x = 200 [[foo]] x = 300
You can find both types of the codecs in this module for different set-like structures. See the following table for the better understanding:
Haskell Type | TOML | TomlCodec |
---|---|---|
| a = ["foo", "bar", "baz"] | |
IntSet | a = [11, 42] | |
| a = ["foo", "bar"] | |
| x = [{a = "foo"}, {a = "bar"}] | |
| x = [{a = "foo"}, {a = "bar"}] | |
Since: 1.3.0.0
Synopsis
- arraySetOf :: Ord a => TomlBiMap a AnyValue -> Key -> TomlCodec (Set a)
- arrayIntSet :: Key -> TomlCodec IntSet
- arrayHashSetOf :: (Hashable a, Eq a) => TomlBiMap a AnyValue -> Key -> TomlCodec (HashSet a)
- set :: forall a. Ord a => TomlCodec a -> Key -> TomlCodec (Set a)
- intSet :: TomlCodec Int -> Key -> TomlCodec IntSet
- hashSet :: forall a. (Hashable a, Eq a) => TomlCodec a -> Key -> TomlCodec (HashSet a)
Array sets
arrayIntSet :: Key -> TomlCodec IntSet Source #
Codec for sets of ints. Takes converter for single value and returns a set of ints.
Example:
Haskell
can look like this in your IntSet
TOML
file:
foo = [1, 2, 3]
In case of the missing field, the following error will be seen:
tomland decode error: Key foo is not found
Since: 0.5.0
arrayHashSetOf :: (Hashable a, Eq a) => TomlBiMap a AnyValue -> Key -> TomlCodec (HashSet a) Source #