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]
16
17let to_string = function
18 | `Any -> "any"
19 | `Plain -> "plain"
20 | `Single_quoted -> "single-quoted"
21 | `Double_quoted -> "double-quoted"
22 | `Literal -> "literal"
23 | `Folded -> "folded"
24
25let pp fmt t =
26 Format.pp_print_string fmt (to_string t)
27
28let equal a b = a = b
29
30let compare a b =
31 let to_int = function
32 | `Any -> 0
33 | `Plain -> 1
34 | `Single_quoted -> 2
35 | `Double_quoted -> 3
36 | `Literal -> 4
37 | `Folded -> 5
38 in
39 Int.compare (to_int a) (to_int b)