Yaml

:= [
    Null,
    Bool(Bool),
    Int(I64),
    Float(F64),
    String(Str),
    Sequence(List(Yaml)),
    Mapping(List({ key : Str, value : Yaml })),
]

A practical YAML configuration parser.

This module implements a deliberately small YAML 1.2-style subset aimed at configuration files and Markdown frontmatter. It supports a single block document, nested mappings and sequences, flow collections, comments, quoted strings, and common null, boolean, integer, and floating-point scalars.

Anchors, aliases, tags, directives, block scalars, complex keys, and multi-document streams are rejected with a parse error.

is_eq : _

Compare two parsed YAML values structurally.

parse_str : Str -> Try(Yaml, [YamlError(Error)])

Parse one YAML configuration document from a string.

Empty input produces Null. Invalid input returns YamlError with a one-based line and column. See the module description for the supported subset.

expect Yaml.parse_str("draft: false") == Ok(Mapping([{ key: "draft", value: Bool(Bool.False) }]))
to_inspect : Yaml -> Str

Render a parsed YAML value in Roc source-like notation for inspection.

Error : { line : U64, column : U64, message : Str }

Location and explanation of invalid YAML input. Lines and columns are one-based.