Streaming opam file codec for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-opam: enable MDX on lib/opam.mli, fix broken doc example

Run mdx on lib/opam.mli so the {[ ... ]} odoc block now type-checks
the codec construction + decode round-trip.

The example referenced a free `input`. Replaced with a concrete
opam-format string literal, decoded it, and asserted on the resulting
record fields (`pkg.name = "demo"`, `pkg.depends = ["ocaml"; "dune"]`)
so the documented codec actually demonstrates a working decode.
Errors surface via `Fmt.failwith "%a" Opam.Error.pp e` rather than
`Result.get_ok` swallowing them.

+17 -1
+4
lib/dune
··· 4 4 (libraries 5 5 fmt 6 6 (re_export nox-loc))) 7 + 8 + (mdx 9 + (files opam.mli) 10 + (libraries nox-opam fmt))
+13 -1
lib/opam.mli
··· 25 25 ~dec_absent:[] 26 26 |> finish) 27 27 28 - let r = Opam.decode_string pkg_codec input 28 + let input = 29 + {|opam-version: "2.0" 30 + name: "demo" 31 + version: "0.1.0" 32 + depends: [ "ocaml" "dune" ]|} 33 + 34 + let pkg = 35 + match Opam.decode_string pkg_codec input with 36 + | Ok p -> p 37 + | Error e -> Fmt.failwith "decode: %a" Opam.Error.pp e 38 + 39 + let () = assert (pkg.name = "demo") 40 + let () = assert (pkg.depends = [ "ocaml"; "dune" ]) 29 41 ]} 30 42 31 43 For raw value parsing without codecs, see {!Opam_bytesrw}. *)