mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-13 06:20:55 -05:00
34 lines
812 B
OCaml
34 lines
812 B
OCaml
|
|
(* This file is free software. See file "license" for more details. *)
|
|
|
|
(** {1 Util} *)
|
|
|
|
module Fmt = CCFormat
|
|
|
|
type 'a printer = 'a CCFormat.printer
|
|
|
|
let pp_sep sep out () = Format.fprintf out "%s@," sep
|
|
|
|
let pp_list ?(sep=" ") pp out l =
|
|
Fmt.list ~sep:(pp_sep sep) pp out l
|
|
|
|
let pp_seq ?(sep=" ") pp out l =
|
|
Fmt.seq ~sep:(pp_sep sep) pp out l
|
|
|
|
let pp_pair ?(sep=" ") pp1 pp2 out t =
|
|
Fmt.pair ~sep:(pp_sep sep) pp1 pp2 out t
|
|
|
|
let pp_array ?(sep=" ") pp out l =
|
|
Fmt.array ~sep:(pp_sep sep) pp out l
|
|
|
|
let pp_iarray ?(sep=" ") pp out a =
|
|
Fmt.seq ~sep:(pp_sep sep) pp out (IArray.to_seq a)
|
|
|
|
exception Error of string
|
|
|
|
let () = Printexc.register_printer
|
|
(function
|
|
| Error msg -> Some ("internal error: " ^ msg)
|
|
| _ -> None)
|
|
|
|
let errorf msg = Fmt.ksprintf msg ~f:(fun s -> raise (Error s))
|