From 92a599c660d130dec430b7f50cd35ecc37672cb5 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sun, 29 Sep 2024 00:48:58 +0100 Subject: [PATCH] refactor: improve marks pp (#506) --- lib/automata.ml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/automata.ml b/lib/automata.ml index 93d7cc3f..f070d940 100644 --- a/lib/automata.ml +++ b/lib/automata.ml @@ -283,14 +283,21 @@ module Marks = struct let set_pmark t i = { t with pmarks = Pmark.Set.add i t.pmarks } let pp fmt { marks; pmarks } = - Format.fprintf - fmt - "@[(@[<2>marks@ %a@] @[<2>pmarks %a@])@]" - (Format.pp_print_list (fun fmt (a, i) -> - Format.fprintf fmt "%a-%a" Mark.pp a Idx.pp i)) - marks - (Format.pp_print_list Pmark.pp) - (Pmark.Set.to_list pmarks) + Format.pp_open_box fmt 1; + (match marks with + | [] -> () + | _ :: _ -> + Format.fprintf + fmt + "@[<2>marks@ %a@]" + (Format.pp_print_list (fun fmt (a, i) -> + Format.fprintf fmt "%a-%a" Mark.pp a Idx.pp i)) + marks); + (match Pmark.Set.to_list pmarks with + | [] -> () + | pmarks -> + Format.fprintf fmt "@[<2>pmarks %a@]" (Format.pp_print_list Pmark.pp) pmarks); + Format.pp_close_box fmt () ;; end