Skip to content
New issue

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

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

Already on GitHub? # to your account

[ocaml] Allow blank lines between recursive type definitions #628

Merged
merged 1 commit into from
Sep 14, 2023
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
6 changes: 6 additions & 0 deletions topiary/languages/ocaml.scm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
(let_and_operator) @allow_blank_line_before
)

; In a definition including several mutually recursive types,
; one can skip a line before each of them.
(type_definition
"and" @allow_blank_line_before
)

; Append line breaks. If there is a comment following, we don't add anything,
; because the input softlines and spaces above will already have sorted out the
; formatting.
Expand Down
4 changes: 4 additions & 0 deletions topiary/tests/samples/expected/ocaml-interface.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4590,16 +4590,19 @@ type 'kind operation = {
shell: Operation.shell_header;
protocol_data: 'kind protocol_data;
}

and 'kind protocol_data = {
contents: 'kind contents_list;
signature: signature option;
}

and _ contents_list =
| Single : 'kind contents -> 'kind contents_list
| Cons :
'kind Kind.manager contents
* 'rest Kind.manager contents_list ->
('kind * 'rest) Kind.manager contents_list

and _ contents =
| Preendorsement : consensus_content -> Kind.preendorsement contents
| Endorsement : consensus_content -> Kind.endorsement contents
Expand Down Expand Up @@ -4672,6 +4675,7 @@ and _ contents =
storage_limit: Z.t;
} ->
'kind Kind.manager contents

and _ manager_operation =
| Reveal : public_key -> Kind.reveal manager_operation
| Transaction :
Expand Down
4 changes: 4 additions & 0 deletions topiary/tests/samples/expected/ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ let [1; snd] = [1; 2]
type a = int
and b = float

type a = int

and b = float

(* Messing around with quoted strings and curly brackets *)
type string_record = { my_string: string; }
let quoted_string =
Expand Down
4 changes: 4 additions & 0 deletions topiary/tests/samples/input/ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,10 @@ let [1; snd] = [1; 2]
type a = int and
b = float

type a = int

and b = float

(* Messing around with quoted strings and curly brackets *)
type string_record = { my_string: string; }
let quoted_string =
Expand Down