Skip to content

Commit 5151756

Browse files
make map ~a:(fun and map (fun consistent
1 parent cdb8721 commit 5151756

34 files changed

+167
-117
lines changed

lib/Params.ml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,10 @@ module Exp = struct
176176
| Some ((Labelled _ | Optional _), _, _) -> true
177177
| _ -> false
178178
in
179-
let is_ctx_beginend =
180-
match ctx0 with
181-
| Exp {pexp_desc= Pexp_beginend _; _} -> true
182-
| _ -> false
183-
in
184179
if Conf.(c.fmt_opts.ocp_indent_compat.v) then
185180
if last_arg || is_labelled_arg then break 1 2 else str " "
186181
else if is_labelled_arg then break 1 2
187-
else if last_arg then break 1 0
188-
else if is_ctx_beginend then break 1 0
189-
else str " "
182+
else break 1 0
190183

191184
let box_fun_decl_args ~ctx ~ctx0 ?(last_arg = false) ?epi c ~parens ~kw
192185
~args ~annot =
@@ -217,11 +210,8 @@ module Exp = struct
217210
match ctx_is_apply_and_exp_is_arg ~ctx ~ctx0 with
218211
| Some (_, _, true) ->
219212
(* Is last arg. *) hvbox ~name (if parens then 0 else 2)
220-
| Some (Nolabel, _, false) ->
221-
(* TODO: Inconsistent formatting of fun args. *)
222-
hovbox ~name 0
223-
| Some ((Labelled _ | Optional _), _, false) -> hvbox ~name 0
224-
| None -> Fn.id
213+
| Some (_, _, false) -> hvbox ~name 0
214+
| None -> hvbox ~name 0
225215
in
226216
(box, not c.fmt_opts.wrap_fun_args.v)
227217
in

test/passing/refs.ahrefs/break_fun_decl-fit_or_vertical.ml.ref

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ let f
136136

137137
let new_specialised_args =
138138
Variable.Map.mapi
139-
(fun new_inner_var______ (definition : Definition.t) :
140-
Flambda.specialised_to -> ())
139+
(fun
140+
new_inner_var______
141+
(definition : Definition.t)
142+
:
143+
Flambda.specialised_to
144+
-> ())
141145
foo
142146

143147
let new_specialised_args =

test/passing/refs.ahrefs/break_fun_decl-smart.ml.ref

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,12 @@ let f
129129

130130
let new_specialised_args =
131131
Variable.Map.mapi
132-
(fun new_inner_var______ (definition : Definition.t) :
133-
Flambda.specialised_to -> ())
132+
(fun
133+
new_inner_var______
134+
(definition : Definition.t)
135+
:
136+
Flambda.specialised_to
137+
-> ())
134138
foo
135139

136140
let new_specialised_args =

test/passing/refs.ahrefs/break_fun_decl-wrap.ml.ref

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ let f (module Store : Irmin.Generic_key.S with type repo = repo)
110110

111111
let new_specialised_args =
112112
Variable.Map.mapi
113-
(fun new_inner_var______ (definition : Definition.t) :
114-
Flambda.specialised_to -> ())
113+
(fun
114+
new_inner_var______
115+
(definition : Definition.t)
116+
:
117+
Flambda.specialised_to
118+
-> ())
115119
foo
116120

117121
let new_specialised_args =

test/passing/refs.ahrefs/break_fun_decl.ml.ref

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ let f (module Store : Irmin.Generic_key.S with type repo = repo)
110110

111111
let new_specialised_args =
112112
Variable.Map.mapi
113-
(fun new_inner_var______ (definition : Definition.t) :
114-
Flambda.specialised_to -> ())
113+
(fun
114+
new_inner_var______
115+
(definition : Definition.t)
116+
:
117+
Flambda.specialised_to
118+
-> ())
115119
foo
116120

117121
let new_specialised_args =

test/passing/refs.ahrefs/class_expr.ml.err

Whitespace-only changes.

test/passing/refs.ahrefs/class_expr.ml.ref

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class c (* xx *) i (* yy *) = x
99
class c =
1010
object
1111
method class_infos : 'a. ('a -> 'res) -> 'a class_infos -> 'res =
12-
fun _a
12+
fun
13+
_a
1314
{ pci_virt; pci_params; pci_name; pci_expr; pci_loc; pci_attributes } ->
1415
let pci_virt = self#virtual_flag pci_virt in
1516
let pci_params = self#list in

test/passing/refs.ahrefs/exp_grouping.ml.ref

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,7 @@ let v =
394394
let v =
395395
map x
396396
begin fun
397-
x
398-
arggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
399-
->
397+
x arggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg ->
400398
y
401399
end
402400

@@ -457,10 +455,7 @@ let _ =
457455

458456
let _ =
459457
lazy begin fun
460-
xxxxxxxxxxxxxxxxxxxxxxx
461-
yyyyyyyyyyyyyyyyyyy
462-
zzzzzzzzzzzzzzzzzzzzzzzz
463-
->
458+
xxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyy zzzzzzzzzzzzzzzzzzzzzzzz ->
464459
print_endline xxxxxxxxx;
465460
f xxxxxxxxxx yyyyyyyyyyyyy zzzzzzzzzzzzzzzzzzzzz
466461
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Warning: fun_decl-no-wrap-fun-args.ml:39 exceeds the margin
1+
Warning: fun_decl-no-wrap-fun-args.ml:41 exceeds the margin

test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.ref

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@ let _ = fun (x : int) : int -> (some_large_computation : int)
55
let fooo = List.foooo ~f:(fun foooo foooo : bool -> foooooooooooooooooooooo)
66

77
let _ =
8-
fun (x : int)
9-
(x : int)
10-
(x : int)
11-
(x : int)
12-
(x : int)
13-
:
14-
fooooooooooooooooooooooooooo foooooooooooooo foooooooooo ->
8+
fun
9+
(x : int)
10+
(x : int)
11+
(x : int)
12+
(x : int)
13+
(x : int)
14+
:
15+
fooooooooooooooooooooooooooo foooooooooooooo foooooooooo ->
1516
some_large_computation
1617

1718
let _ =
18-
fun (x : int)
19-
(x : int)
20-
(x : int)
21-
(x : int)
22-
(x : int)
23-
(x : int)
24-
(x : int)
25-
:
26-
fooooooooooooooooooooooooooo foooooooooooooo foooooooooo ->
19+
fun
20+
(x : int)
21+
(x : int)
22+
(x : int)
23+
(x : int)
24+
(x : int)
25+
(x : int)
26+
(x : int)
27+
:
28+
fooooooooooooooooooooooooooo foooooooooooooo foooooooooo ->
2729
some_large_computation
2830

2931
let () =
@@ -94,17 +96,19 @@ let _ =
9496

9597
let _ =
9698
let _ = () in
97-
fun (context : Context.t)
98-
~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t)
99-
->
99+
fun
100+
(context : Context.t)
101+
~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t)
102+
->
100103
let _ = () in
101104
()
102105

103106
let _ =
104107
print_endline "foo";
105-
fun (context : Context.t)
106-
~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t)
107-
->
108+
fun
109+
(context : Context.t)
110+
~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t)
111+
->
108112
let _ = () in
109113
()
110114

0 commit comments

Comments
 (0)