Clerk_lib.Clerk_toml_encodingSourceThis module provides constructors and combinators that allow to describe the structure of an expected TOML file. It also provide a type-safe encoder/decoder.
Basic constructors
Object's Field constructors
Object constructors
Objects are translated as inner tables in TOML: e.g., obj2 (req_field ~name:"a" string) (req_field ~name:"b" (list string)) described under a table "target" will match the following TOML:
[target] a = "some string" b = [ "hello" ; "world" ]
Warning: registering multiple fields in an object under the same name will raise an error at runtime when the descriptor gets evaluated.
Union
val case :
info:string ->
proj:('a -> 'b option) ->
inj:('b -> 'a option) ->
'b descr ->
'a caseUnion's case: the info is used to describe the case to the user.
union cases will create a descriptor that matches several patterns, e.g., to describe a sum-type. The first case found for which its proj function returns Some _ will be used.
Table constructors
Tables are translated as toplevel tables in TOML: e.g., table2 (table_opt ~name:"project" (...)) (multi_table ~name:"module" (...)) will match the following TOML:
[project] ... [[module]] ... [[module]] ...
N.b., the project table could be omitted
Warning: describing different toplevel tables using the same name will raise an error at runtime when the descriptor gets evaluated.
Conversion operators
Utilities