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(** Scalar formatting styles *)
7
8type t =
9 [ `Any (** Let emitter choose *)
10 | `Plain (** Unquoted: foo *)
11 | `Single_quoted (** 'foo' *)
12 | `Double_quoted (** "foo" *)
13 | `Literal (** | block *)
14 | `Folded (** > block *) ]
15
16let to_string = function
17 | `Any -> "any"
18 | `Plain -> "plain"
19 | `Single_quoted -> "single-quoted"
20 | `Double_quoted -> "double-quoted"
21 | `Literal -> "literal"
22 | `Folded -> "folded"
23
24let pp fmt t = Format.pp_print_string fmt (to_string t)
25let equal a b = a = b
26
27let compare a b =
28 let to_int = function
29 | `Any -> 0
30 | `Plain -> 1
31 | `Single_quoted -> 2
32 | `Double_quoted -> 3
33 | `Literal -> 4
34 | `Folded -> 5
35 in
36 Int.compare (to_int a) (to_int b)