yamlet

yamlet

A YAML 1.2.2 library written in Haskell. Main features:

  • Conformance: the parser passes all cases of the YAML test suite.
  • Performance: decoding and encoding are very fast, see the benchmarks.
  • Decoding and encoding with the classes FromYaml and ToYaml, with instances for common types.
  • Instances for your own data types, derived via GenericYaml. Inspection tests check that the generic representation optimizes away for common shapes of data types.
  • Errors with the line, the column and the path of the problem, e.g. jobs[1].name. The decoder reports the errors of independent parts together, e.g. every bad field of a record.
  • A syntax tree that keeps the comments and the empty lines. A program can change a file and write it back with its comments, and a decoded value can keep a part of the document as it was written.
  • Output that YAML 1.1 parsers read the same way, e.g. PyYAML and go-yaml v2, which Kubernetes uses.
  • Safe for untrusted input. The time of a decode is close to linear in the size of the input, and the memory is linear.

See also yamlet-aeson, which decodes and encodes YAML with the FromJSON and ToJSON instances of aeson, e.g. in a program that moves from the yaml package to yamlet.

Modules