yamleam
yamleam — a pure-Gleam YAML parser.
Public API. Implementation lives under src/yamleam/. See README.md
and ROADMAP.md for the supported subset, the planned coverage, and
the design philosophy.
Types
pub type YamlError =
error.YamlError
pub type YamlNode =
node.YamlNode
Values
pub fn parse(
source: String,
decoder: decode.Decoder(a),
) -> Result(a, error.YamlError)
Parse a YAML source string and run a decoder on the resulting tree.
The decoder is a standard gleam/dynamic/decode.Decoder(a), the same
type used by gleam_json.parse. Decoders written for JSON sources
can be reused unchanged against YAML sources. Multi-document streams
are rejected; use parse_documents for those.
pub fn parse_documents(
source: String,
decoder: decode.Decoder(a),
) -> Result(List(a), error.YamlError)
Parse a YAML stream containing one or more documents and run the given decoder against each document. Returns a list of decoded values in document order.
pub fn parse_documents_raw(
source: String,
) -> Result(List(node.YamlNode), error.YamlError)
Parse a YAML stream containing one or more documents into a list of
YamlNode trees. Documents are separated by --- (start) or ...
(end) markers as defined in YAML 1.2 §9.
A stream with no markers and a single document returns [node].
An empty stream returns [].
Use parse_documents if you want each document run through a decoder.
pub fn parse_raw(
source: String,
) -> Result(node.YamlNode, error.YamlError)
Parse a YAML source string into a typed YamlNode tree.
Returns a ParseError for invalid YAML or an Unsupported error for
features yamleam does not yet implement. Multi-document streams are
rejected; use parse_documents_raw for those.
pub fn yaml_bool(b: Bool) -> node.YamlNode
pub fn yaml_float(f: Float) -> node.YamlNode
pub fn yaml_int(i: Int) -> node.YamlNode
pub fn yaml_list(items: List(node.YamlNode)) -> node.YamlNode
pub fn yaml_map(
pairs: List(#(String, node.YamlNode)),
) -> node.YamlNode
pub const yaml_null: node.YamlNode
pub fn yaml_string(s: String) -> node.YamlNode