The ocaml-syck library provides Syck bindings for OCaml, allowing an OCaml program to read and write YAML files. The code is available under the MIT license.
Here's a simple example that illustrates how
the YamlParser
module works.
let parser = YamlParser.make () in
try
let root =
YamlParser.parse_string
parser
"---\n- one\n- two\n- three\n"
in
match root with
| YamlNode.SEQUENCE (_, nodes) ->
List.iter
(function
| YamlNode.SCALAR (_, value) ->
print_endline value
| _ -> ())
nodes
| _ -> ()
with YamlParser.Error (msg) ->
prerr_endline msg