package kdl
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=c6bff16d8b9194f1d99789ad45aaee948cdf3ebeba1a3e839d261e341329c4c7
Description
README
ocaml-kdl

OCaml implementation of the KDL Document Language v2.
$ opam install kdlFeatures
- Parsing
- Pretty-printing
- Lenses
- KDL Query Language (KQL)
- KDL Schema Language
- Formatting-preserving editing
Usage
Example:
# let kdl = Kdl.of_string {|
contents {
section "First section" {
paragraph "This is the first paragraph"
paragraph "This is the second paragraph"
}
}
|}
val kdl : (Kdl.t, Kdl.error) result = Ok
[{Kdl.name = "contents"; annot = None; args = []; props = [];
children =
[{Kdl.name = "section"; annot = None;
args = [(None, `String "First section")]; props = [];
children =
[{Kdl.name = "paragraph"; annot = None;
args = [(None, `String "This is the first paragraph")]; props = [];
children = []};
{Kdl.name = "paragraph"; annot = None;
args = [(None, `String "This is the second paragraph")]; props = [];
children = []}]}]}]Convert to a sexp-expression (uses the sexplib0 library):
# Kdl.sexp_of_t kdl |> Sexplib0.Sexp.to_string_hum |> print_endline
(contents
(children
(section (string "First section")
(children (paragraph (string "This is the first paragraph"))
(paragraph (string "This is the second paragraph"))))))Pretty-print the KDL document back:
# Kdl.to_string kdl |> print_endline
contents {
section "First section" {
paragraph "This is the first paragraph"
paragraph "This is the second paragraph"
}
}Similar to to.ml, ocaml-kdl provides lenses. The lenses can be composed using // or |--:
# let open Kdl.L in
kdl.@(top // child "section" // child_nth 1 // first_arg // string_value)
- : string option = Some "This is the second paragraph"Additionaly, type-annotated values can be "interpreted":
# let parsed = Kdl.of_string_exn "- (u8)220"
# Kdl.interpret Kdl.L.(parsed.@!(node "-" // first_arg))
- : [> Kdl.typed_value ] = `U8 220For the full list of available functions, see the mli file.
Dev Dependencies (3)
-
odoc
with-doc -
zarith
with-test -
ppx_expect
with-test
Optional Dependencies
None
Used by (1)
-
alice
>= "0.4.0"
Conflicts
None
Build status
Results of building kdl with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.2.0 (this version) | n/a | good | good | good | good |
| 0.1.0 | good | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure