Pure OCaml Yaml 1.2 reader and writer using Bytesrw
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** JSON-compatible YAML value representation *)
7
8type t = [
9 | `Null
10 | `Bool of bool
11 | `Float of float
12 | `String of string
13 | `A of t list
14 | `O of (string * t) list
15]
16
17(** {2 Constructors} *)
18
19val null : t
20val bool : bool -> t
21val int : int -> t
22val float : float -> t
23val string : string -> t
24val list : ('a -> t) -> 'a list -> t
25val obj : (string * t) list -> t
26
27(** {2 Type Name} *)
28
29val type_name : t -> string
30(** Get the type name for error messages *)
31
32(** {2 Safe Accessors} *)
33
34val as_null : t -> unit option
35val as_bool : t -> bool option
36val as_float : t -> float option
37val as_string : t -> string option
38val as_list : t -> t list option
39val as_assoc : t -> (string * t) list option
40val as_int : t -> int option
41
42(** {2 Unsafe Accessors} *)
43
44val to_null : t -> unit
45val to_bool : t -> bool
46val to_float : t -> float
47val to_string : t -> string
48val to_list : t -> t list
49val to_assoc : t -> (string * t) list
50val to_int : t -> int
51
52(** {2 Object Access} *)
53
54val mem : string -> t -> bool
55val find : string -> t -> t option
56val get : string -> t -> t
57val keys : t -> string list
58val values : t -> t list
59
60(** {2 Combinators} *)
61
62val combine : t -> t -> t
63val map : (t -> t) -> t -> t
64val filter : (t -> bool) -> t -> t
65
66(** {2 Comparison} *)
67
68val pp : Format.formatter -> t -> unit
69val equal : t -> t -> bool
70val compare : t -> t -> int