feat(ser_value): print

This commit is contained in:
Simon Cruanes 2022-09-19 22:23:45 -04:00
parent 9a2249292f
commit adcb6233a3
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 16 additions and 0 deletions

View file

@ -1,3 +1,5 @@
module Fmt = CCFormat
type t =
| Bool of bool
| Str of string
@ -13,3 +15,15 @@ let bytes x : t = Bytes x
let list x : t = List x
let dict x : t = Dict x
let dict_of_list l = dict (Util.Str_map.of_list l)
let rec pp out (self : t) =
match self with
| Bool b -> Fmt.bool out b
| Int i -> Fmt.int out i
| Str s -> Fmt.Dump.string out s
| Bytes s -> Fmt.fprintf out "(bytes %S)" s
| List l -> Fmt.Dump.list pp out l
| Dict m ->
Fmt.fprintf out "{@[%a@]}"
(Util.pp_iter ~sep:", " Fmt.Dump.(pair string pp))
(Util.Str_map.to_iter m)

View file

@ -21,3 +21,5 @@ val bytes : string -> t
val list : t list -> t
val dict : t Util.Str_map.t -> t
val dict_of_list : (string * t) list -> t
include Sidekick_sigs.PRINT with type t := t