# (* This will return either `Ok $tomltable or `Error $error_with_location *)
let ok_or_error = Toml.Parser.from_string "key=[1,2]";;
val ok_or_error : Toml.Parser.result = `Ok <abstr>
# (* You can use the 'unsafe' combinator to get the result directly, or an
exception if a parsing error occurred *)
let parsed_toml = Toml.Parser.(from_string "key=[1,2]" |> unsafe);;
val parsed_toml : Toml.Types.table = <abstr>
# (* Use simple pattern matching to read the value *)
Toml.Types.Table.find (Toml.Min.key "key") parsed_toml;;
- : Toml.Types.value = Toml.Types.TArray (Toml.Types.NodeInt [1; 2])
Through lenses, it is possible to read/write deeply nested data with ease. The Toml.Lenses module provides partial lenses (that is, lenses returning option types) to manipulate TOML data structures.
Keys don't quite follow the TOML standard. Both section keys (eg, [key1.key2]) and ordinary keys (key=...) may not contain the following characters: space, \t, \n, \r, ., [, ], " and #.