Skip to content

Commit

Permalink
chore: some clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
sorawee committed Dec 2, 2023
1 parent b6b814a commit 77d745f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions doc/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(documentation
(package pretty_expressive))

(mdx (files :standard - *.mld)
(preludes prelude.ml))
(mdx (preludes prelude.ml))
4 changes: 3 additions & 1 deletion doc/index.mld
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ let print_sexp (s : sexp) (w : int) =
let x_d = pretty x in
let xs_d = List.map pretty xs in
lparen <+>
(* Share x_d and xs_d across choices *)
(acat (x_d :: xs_d) <|> (* the horizontal style *)
vcat (x_d :: xs_d) <|> (* the vertical style *)
(x_d <+> space <+> vcat xs_d)) <+> (* the argument list style *)
Expand All @@ -230,11 +231,12 @@ let print_sexp (s : sexp) (w : int) =

The important point is that we reuse [x_d] and [xs_d] across [<|>].
Had we written the following code instead,
document construction could take exponential time, and the resulting
the document construction could take exponential time, and the resulting
document whose DAG size is very large would also cause pretty-printing
to be inefficient.

{@ocaml skip[
(* Don't do this! *)
lparen <+>
(acat (pretty x :: List.map pretty xs) <|> (* the horizontal style *)
vcat (pretty x :: List.map pretty xs) <|> (* the vertical style *)
Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

(documentation https://sorawee.github.io/pretty-expressive-ocaml/)

(using mdx 0.2)
(using mdx 0.4)

(package
(name pretty_expressive)
(synopsis "A pretty expressive printer")
(description "A pretty printer implementation of 'A Pretty Expressive Printer' (OOPSLA'23), with an emphasis on expressiveness and optimality.")
(depends (ocaml (>= 4.05))
dune
(mdx (and (>= 2.0.0) :with-test))
(mdx (and (>= 2.3.0) :with-test))
(alcotest :with-test)))
2 changes: 1 addition & 1 deletion lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
(modules (:standard \ prelude))
(modules_without_implementation signature))

(mdx (files :standard - *.mli)
(mdx (files :standard *.mli)
(preludes prelude.ml))
2 changes: 1 addition & 1 deletion pretty_expressive.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bug-reports: "https://github.com/sorawee/pretty-expressive-ocaml/issues"
depends: [
"ocaml" {>= "4.05"}
"dune" {>= "3.10"}
"mdx" {>= "2.0.0" & with-test}
"mdx" {>= "2.3.0" & with-test}
"alcotest" {with-test}
"odoc" {with-doc}
]
Expand Down

0 comments on commit 77d745f

Please sign in to comment.