Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add mli to our fmt module #272

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ module View = struct
end

let rec pp fmt t =
let open Format in
let open Fmt in
let var s re = sexp fmt s pp re in
let seq s rel = sexp fmt s (list pp) rel in
Expand Down
12 changes: 12 additions & 0 deletions lib/fmt.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type formatter := Format.formatter
type 'a t = formatter -> 'a -> unit

val pp_str_list : string list t
val sexp : formatter -> string -> 'a t -> 'a -> unit
val str : string t
val optint : int option t
val int : int t
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val list : ?pp_sep:unit t -> 'a t -> 'a list t
val to_to_string : 'a t -> 'a -> string
1 change: 1 addition & 0 deletions lib/group.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ let pp fmt t =
let strs = all t in
Array.to_list (Array.init (Array.length strs) (fun i -> strs.(i), offsets.(i)))
in
let open Format in
let open Fmt in
let pp_match fmt (str, (start, stop)) = fprintf fmt "@[(%s (%d %d))@]" str start stop in
sexp fmt "Group" (list pp_match) matches
Expand Down
Loading