mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
feat(ser_value): print
This commit is contained in:
parent
9a2249292f
commit
adcb6233a3
2 changed files with 16 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Fmt = CCFormat
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
| Bool of bool
|
| Bool of bool
|
||||||
| Str of string
|
| Str of string
|
||||||
|
|
@ -13,3 +15,15 @@ let bytes x : t = Bytes x
|
||||||
let list x : t = List x
|
let list x : t = List x
|
||||||
let dict x : t = Dict x
|
let dict x : t = Dict x
|
||||||
let dict_of_list l = dict (Util.Str_map.of_list l)
|
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)
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,5 @@ val bytes : string -> t
|
||||||
val list : t list -> t
|
val list : t list -> t
|
||||||
val dict : t Util.Str_map.t -> t
|
val dict : t Util.Str_map.t -> t
|
||||||
val dict_of_list : (string * t) list -> t
|
val dict_of_list : (string * t) list -> t
|
||||||
|
|
||||||
|
include Sidekick_sigs.PRINT with type t := t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue