Copyright | (c) 2018-2019 Kowainik |
---|---|
License | MPL-2.0 |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Contains TOML-specific combinators for converting between TOML and user data types.
Synopsis
- bool :: Key -> TomlCodec Bool
- integer :: Key -> TomlCodec Integer
- natural :: Key -> TomlCodec Natural
- int :: Key -> TomlCodec Int
- word :: Key -> TomlCodec Word
- word8 :: Key -> TomlCodec Word8
- double :: Key -> TomlCodec Double
- float :: Key -> TomlCodec Float
- text :: Key -> TomlCodec Text
- lazyText :: Key -> TomlCodec Text
- byteString :: Key -> TomlCodec ByteString
- lazyByteString :: Key -> TomlCodec ByteString
- byteStringArray :: Key -> TomlCodec ByteString
- lazyByteStringArray :: Key -> TomlCodec ByteString
- string :: Key -> TomlCodec String
- zonedTime :: Key -> TomlCodec ZonedTime
- localTime :: Key -> TomlCodec LocalTime
- day :: Key -> TomlCodec Day
- timeOfDay :: Key -> TomlCodec TimeOfDay
- arrayOf :: TomlBiMap a AnyValue -> Key -> TomlCodec [a]
- 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)
- arrayNonEmptyOf :: TomlBiMap a AnyValue -> Key -> TomlCodec (NonEmpty a)
- all :: Key -> TomlCodec All
- any :: Key -> TomlCodec Any
- sum :: (Key -> TomlCodec a) -> Key -> TomlCodec (Sum a)
- product :: (Key -> TomlCodec a) -> Key -> TomlCodec (Product a)
- first :: (Key -> TomlCodec a) -> Key -> TomlCodec (First a)
- last :: (Key -> TomlCodec a) -> Key -> TomlCodec (Last a)
- textBy :: (a -> Text) -> (Text -> Either Text a) -> Key -> TomlCodec a
- read :: (Show a, Read a) => Key -> TomlCodec a
- enumBounded :: (Bounded a, Enum a, Show a) => Key -> TomlCodec a
- table :: forall a. TomlCodec a -> Key -> TomlCodec a
- nonEmpty :: forall a. TomlCodec a -> Key -> TomlCodec (NonEmpty a)
- list :: forall a. TomlCodec a -> Key -> TomlCodec [a]
- set :: forall a. Ord a => TomlCodec a -> Key -> TomlCodec (Set a)
- hashSet :: forall a. (Hashable a, Eq a) => TomlCodec a -> Key -> TomlCodec (HashSet a)
- map :: forall k v. Ord k => TomlCodec k -> TomlCodec v -> Key -> TomlCodec (Map k v)
- match :: forall a. TomlBiMap a AnyValue -> Key -> TomlCodec a
Basic codecs for primitive values
Boolean
Integral numbers
Floating point numbers
Text types
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
Time types
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.
Codecs for Monoid
s
Bool wrappers
Num
wrappers
sum :: (Key -> TomlCodec a) -> Key -> TomlCodec (Sum a) Source #
Codec for Sum
wrapper for given converter's values.
Since: 1.2.1.0
product :: (Key -> TomlCodec a) -> Key -> TomlCodec (Product a) Source #
Codec for Product
wrapper for given converter's values.
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.
Since: 1.2.1.0
last :: (Key -> TomlCodec a) -> Key -> TomlCodec (Last a) Source #
Codec for Last
wrapper for given converter's values.
Since: 1.2.1.0
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.
Combinators for tables
table :: forall a. TomlCodec a -> Key -> TomlCodec a Source #
Codec for tables. Use it when when you have nested objects.
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
Combinators for Maps
:: forall k v. Ord k | |
=> TomlCodec k | Codec for |
-> TomlCodec v | Codec for |
-> Key | TOML key where |
-> TomlCodec (Map k v) | Codec for the |
Bidirectional codec for Map
. It takes birectional converter for keys and
values and produces bidirectional codec for Map
. Currently it works only with array
of tables, so you need to specify Map
s in TOML files like this:
myMap = [ { name = "foo", payload = 42 } , { name = "bar", payload = 69 } ]
TomlCodec
for such TOML field can look like this:
Toml.map
(Toml.text
"name") (Toml.int
"payload") "myMap"
If there's no key with the name "myMap"
then empty Map
is returned.
Since: 1.2.1.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
MyTypeAnyValue
And then you can create codec for your type using match
function:
myType ::Key
->TomlCodec
MyType myType =match
_MyType