A pure-OCaml YAML 1.2 and 1.1 library with a lossless, comment-preserving AST.
Features:
- Full YAML 1.2 compliance — passes all 371 tests from the yaml-test-suite.
- Pure OCaml — no C bindings, no external runtime dependencies.
- Lossless AST — the parsed node tree preserves scalar styles (plain,
'single-quoted', "double-quoted", | literal, > folded), flow vs. block
collection style, tags, anchors, and source positions.
- Best-effort comment preservation — standalone (head) comments before a node,
inline (line) comments after a value, and trailing (foot) comments after the
last item of a block collection are attached to the nearest node and
re-emitted by the printer.
- Pretty-printer — `Nodes.to_yaml` serializes a node list back to a YAML
string, preserving all of the above.
- Plain-YAML printer — `Nodes.to_plain_yaml_exn` produces a restricted subset
with no anchors, no aliases (expanded inline), no tags, no flow collections,
and no complex mapping keys — the fragment of YAML that most people
recognize on sight.
- Typed-value resolver — `Values.of_yaml` applies the YAML 1.2 JSON schema and
returns value list with `Null | Bool | Int | Float | String | Seq | Map`
constructors.
- Multi-document streams — both the node and value APIs handle streams
containing more than one ----separated document.
- Correct anchor scoping — anchors are document-local; an alias in document N
cannot refer to an anchor defined in document N−1.
- Structured errors — `Scan_error` and `Parse_error` carry a pos record with
line, column, and byte offset. `catch_errors` wraps any of these into a
`(_, string)` result with a human-readable message, optionally prefixed with
a file name.
- Command-line tool — the yamlx binary reads YAML from a file or stdin and
prints it in one of several formats.
Provides
Requires