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

chore: update to ocamlformat.0.26 #8

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
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.17.0
version=0.26.0
break-separators=before
dock-collection-brackets=false
break-sequences=true
Expand Down
19 changes: 3 additions & 16 deletions src/pp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ let rec to_fmt ppf t =
Render.render ppf t ~tag_handler:(fun ppf _tag t -> to_fmt ppf t)

let nop = Nop

let seq a b = Seq (a, b)

let concat ?(sep = Nop) = function
Expand All @@ -182,34 +181,22 @@ let concat_mapi ?(sep = Nop) l ~f =
| l -> Concat (sep, List.mapi l ~f)

let box ?(indent = 0) t = Box (indent, t)

let vbox ?(indent = 0) t = Vbox (indent, t)

let hbox t = Hbox t

let hvbox ?(indent = 0) t = Hvbox (indent, t)

let hovbox ?(indent = 0) t = Hovbox (indent, t)

let verbatim x = Verbatim x

let char x = Char x

let custom_break ~fits ~breaks = Break (fits, breaks)

let break ~nspaces ~shift =
custom_break ~fits:("", nspaces, "") ~breaks:("", shift, "")

let space = break ~nspaces:1 ~shift:0

let cut = break ~nspaces:0 ~shift:0

let newline = Newline

let text s = Text s

let textf fmt = Printf.ksprintf text fmt

let tag tag t = Tag (tag, t)

let enumerate l ~f =
Expand All @@ -225,9 +212,9 @@ let chain l ~f =
(seq
(verbatim
(if i = 0 then
" "
else
"-> "))
" "
else
"-> "))
(f x)))))

module O = struct
Expand Down
4 changes: 3 additions & 1 deletion src/pp.mli
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ val newline : _ t
And the top left corner of this shape is anchored where the box was
declared. So for instance, the following document:

{[ Pp.verbatim "....." ++ Pp.box ~indent:2 (Pp.text "some long ... text") ]}
{[
Pp.verbatim "....." ++ Pp.box ~indent:2 (Pp.text "some long ... text")
]}

would produce:

Expand Down
3 changes: 0 additions & 3 deletions test/tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ open StdLabels
open Pp.O

let print pp = Format.printf "%a@." Pp.to_fmt pp

let many n pp = Array.make n pp |> Array.to_list |> Pp.concat ~sep:Pp.space

let xs n = many n (Pp.char 'x')

let ys n = many n (Pp.char 'y')

let%expect_test _ =
Expand Down
Loading