Protocol Buffers codec for hand-written schemas
0
fork

Configure Feed

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

xml, cbor, csv, protobuf: add Sort.kinded' helper

Factor [kinded] through [kinded' ~kind s = if kind = "" then s else
kind ^ " " ^ s], matching the shape of json's and toml's Sort
modules. Consistent API across every encoding library's Sort: every
module exposes [to_string], [pp], [or_kind], [kinded'], [kinded].

protobuf previously lacked [or_kind] and [kinded] entirely; add them
alongside [kinded'].

+13
+3
lib/sort.ml
··· 40 40 | Message -> "message" 41 41 42 42 let pp ppf s = Fmt.string ppf (to_string s) 43 + let or_kind ~kind s = if kind <> "" then kind else to_string s 44 + let kinded' ~kind:k s = if k = "" then s else k ^ " " ^ s 45 + let kinded ~kind s = kinded' ~kind (to_string s)
+10
lib/sort.mli
··· 34 34 35 35 val pp : Format.formatter -> t -> unit 36 36 (** [pp] formats sorts. *) 37 + 38 + val or_kind : kind:string -> t -> string 39 + (** [or_kind ~kind s] is [kind] when non-empty, otherwise {!to_string} [s]. *) 40 + 41 + val kinded' : kind:string -> string -> string 42 + (** [kinded' ~kind s] is [s] when [kind] is empty, [kind] followed by a space 43 + and [s] otherwise. *) 44 + 45 + val kinded : kind:string -> t -> string 46 + (** [kinded ~kind sort] is {!kinded'} applied to {!to_string} [sort]. *)