Copyright | (c) 2018-2022 Kowainik |
---|---|
License | MPL-2.0 |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Stability | Stable |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
TOML-specific combinators for converting between TOML and Haskell tuples. It's recommended to create your custom data types and implement codecs for them, but if you need to have tuples (e.g. for decoding different constructors of sum types), you can find codecs from this module helpful.
Haskell Type | TOML | TomlCodec |
---|---|---|
( | [foo] |
|
a = 42 | ( | |
b = "bar" | ( | |
( | [foo] |
|
a = 42 | ( | |
b = "bar" | ( | |
c = false | ( |
Since: 1.3.0.0
Documentation
pair :: TomlCodec a -> TomlCodec b -> TomlCodec (a, b) Source #
Codec for pair of values. Takes codecs for the first and for the second values of the pair.
If I have the following TOML
entry
myPair = { first = 11, second = "eleven"}
and want to convert it into the Haskell tuple of two elements, I can use the following codec:
myPairCodec ::TomlCodec
(Int
,Text
) myPairCodec = flip Toml.table
"myPair" $ Toml.pair
(Toml.int
"first") (Toml.text
"second")
Since: 1.3.0.0
triple :: TomlCodec a -> TomlCodec b -> TomlCodec c -> TomlCodec (a, b, c) Source #
Codec for triple of values. Takes codecs for the first, second and third values of the triple.
If I have the following TOML
entry
myTriple = { first = 11 , second = "eleven" , isMyFavourite = true }
and want to convert it into the Haskell tuple of three elements, I can use the following codec:
myTripleCodec ::TomlCodec
(Int
,Text
,Bool
) myTripleCodec = flip Toml.table
"myTriple" $ Toml.triple
(Toml.int
"first") (Toml.text
"second") (Toml.bool
"isMyFavourite")
Since: 1.3.0.0