Native CBOR codec with type-safe combinators
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'].

+9 -5
+2 -1
lib/sort.ml
··· 32 32 | Float -> "float" 33 33 34 34 let pp ppf s = Format.pp_print_string ppf (to_string s) 35 - let kinded ~kind s = if kind = "" then to_string s else kind ^ " " ^ to_string s 36 35 let or_kind ~kind s = if kind <> "" then kind else to_string s 36 + let kinded' ~kind:k s = if k = "" then s else k ^ " " ^ s 37 + let kinded ~kind s = kinded' ~kind (to_string s)
+7 -4
lib/sort.mli
··· 30 30 val pp : Format.formatter -> t -> unit 31 31 (** [pp] formats sorts. *) 32 32 33 - val kinded : kind:string -> t -> string 34 - (** [kinded ~kind s] is [kind ^ " " ^ to_string s] when [kind] is non-empty, 35 - otherwise {!to_string} [s]. *) 36 - 37 33 val or_kind : kind:string -> t -> string 38 34 (** [or_kind ~kind s] is [kind] when non-empty, otherwise {!to_string} [s]. *) 35 + 36 + val kinded' : kind:string -> string -> string 37 + (** [kinded' ~kind s] is [s] when [kind] is empty, [kind] followed by a space 38 + and [s] otherwise. *) 39 + 40 + val kinded : kind:string -> t -> string 41 + (** [kinded ~kind sort] is {!kinded'} applied to {!to_string} [sort]. *)