diff --git a/src/import.ml b/src/import.ml index 961730a5..b233dbaf 100644 --- a/src/import.ml +++ b/src/import.ml @@ -138,6 +138,29 @@ module Fmt = struct let nl = Format.pp_print_newline let prefix f g ppf x = f ppf; g ppf x + + let ocaml_list pp fmt = function + | [] -> Format.pp_print_string fmt "[]" + | l -> + Format.fprintf fmt "@[[ %a@ ]@]" + (list ~pp_sep:(fun fmt () -> Format.fprintf fmt "@,; ") + pp) l + + let quoted fmt = Format.fprintf fmt "%S" + + let const + : 'a t -> 'a -> unit t + = fun pp a' fmt () -> pp fmt a' + + let record fmt = function + | [] -> Format.pp_print_string fmt "{}" + | xs -> + let pp fmt (field, pp) = + Format.fprintf fmt "@[%s@ =@ %a@]" + field pp () in + let pp_sep fmt () = Format.fprintf fmt "@,; " in + Format.fprintf fmt "@[{ %a@ }@]" + (Format.pp_print_list ~pp_sep pp) xs end (* This is ugly *)