Page
Library
Module
Module type
Parameter
Class
Class type
Source
Base.MakeSourcemodule N : TomlNumberRaised when a table field does not exist.
Raised when a TOML value type is not what an accessor or another function expects.
Raised when the parser encounters invalid TOML syntax. The first member of the tuple is the source file position (line and column).
type t = | TomlString of string| TomlInteger of toml_integer| TomlFloat of toml_float| TomlBoolean of bool| TomlOffsetDateTime of toml_date| TomlLocalDateTime of toml_date| TomlLocalDate of toml_date| TomlLocalTime of toml_date| TomlArray of t list| TomlTable of (string * t) list| TomlInlineTable of (string * t) list| TomlTableArray of t listConstructors create TOML values from OCaml values.
Accessors can be used by themselves on TOML values, or passed to high-level interface functions such as find.
By default they expect a strict match, e.g. get_string fails on values other than TomlString _. However, they all provide a boolean ~strict argument that enables type conversion when set to false. Not all types can be converted between each other, so ~strict:false does not prevent all type errors.
All accessors will raise Type_error exception if type conversion is disabled or fails. High-level interface functions handle those exceptions, so you don't need to handle it.
If you want to use accessors directly on TOML values and you want option or result values instead of exceptions, you can use get_opt and get_result combinators.
Unwraps a table and applies an accessor to the values of its fields, useful for unwrapping tables with homogenous field types in a single step.
Converts a TOML array to a list of OCaml values by applying an accessor function to each of them.
For example, if you want to retrieve an array of strings, you can use get_array get_string toml_value.
In non-strict mode, forces a value x to a single-item array [x].
Note that the strict flag is not passed to the accessor. If you want the accessor to also attempt type conversion on the array values, you should specify it explicitly: get_array ~strict:false (get_string ~strict:false) toml_value.
In non-strict mode, converts integer, float, boolean, and datetime values to strings. Trying to convert an array or a table to string will raise Type_error.
In non-strict mode, converts string and boolean values to integers.
Strings are parsed as integers, true is converted to 1, false is converted to 0, and floats are truncated.
In non-strict mode, converts string, boolean, and integer values to floats.
In non-strict mode, converts integer, float, and string values to booleans.
The conversion logic mimics "truth values" in dynamically typed languages. Empty strings, numeric values 0 (integer) and 0.0 (float), empty arrays and tables are treated as false, everything else is true.
These combinators are mainly useful for unwrapping standalong TOML values by hand. They handle the Type_error exception and return None or Error msg when it occurs.
The high-level interface functions handle exceptions raised by accessors themselves.
Returns true if there is a value at the specified path in a table.
For the purpose of this function, an empty table does exist, i.e. if you have foo.bar = {}, then path_exists t ["foo"; "bar"] is true.
Returns a list of all keys of a table, in their original order.
Looks up a value in a table and unwraps it using an accessor function.
Updates a table field at a specified path.
Passing Some toml_value inserts a new value or replaces an existing value.
If a key path partially does not exist, additional tables are created as needed. For example, update (TomlTable []) ["foo"; "bar"] (Some (TomlString "baz"))] will produce TomlTable [("foo", TomlTable [("bar", TomlString "baz")])].
The use_inline_tables flag determines whether automatically-created missing tables will be normal or inline tables.
Passing None as the argument will delete the field at the specified path. It's safe to attempt deleting values at paths that don't exist: there will be no error and the original TOML will be returned unchanged.
Makes a printable representation of a table key path, for example, ["foo"; "bar baz"; "quux"] gives foo."bar baz".quux.