Expected | Ocp-indent output | |
---|---|---|
0 | let () = | let () = |
1 | foo.bar <- | foo.bar <- |
2 | f x | f x |
3 | y z | y z |
4 | ||
5 | (* yminsky *) | (* yminsky *) |
6 | let should_check_can_sell_and_marking regulatory_regime = | let should_check_can_sell_and_marking regulatory_regime = |
7 | match z with | match z with |
8 | | `foo | | `foo |
9 | -> some_function | -> some_function |
10 | argument | argument |
11 | (* pszilagyi: The above typically occurs in a multi-pattern match clause, so the | (* pszilagyi: The above typically occurs in a multi-pattern match clause, so the |
12 | clause expression is on a line by itself. This is the more typical way a | clause expression is on a line by itself. This is the more typical way a |
13 | long single-pattern match clause would be written: *) | long single-pattern match clause would be written: *) |
14 | let should_check_can_sell_and_marking regulatory_regime = | let should_check_can_sell_and_marking regulatory_regime = |
15 | match z with | match z with |
16 | | `foo -> | | `foo -> |
17 | some_function | some_function |
18 | argument | argument |
19 | ||
20 | let f = fun x -> | let f = fun x -> |
21 | ghi | ghi |
22 | x | x |
23 | ||
24 | (* common *) | (* common *) |
25 | let x = | let x = |
26 | try x with | try x with |
27 | | a -> b | | a -> b |
28 | | c -> d | | c -> d |
29 | let x = try x with | let x = try x with |
30 | | a -> b | | a -> b |
31 | | c -> d | | c -> d |
32 | let x = | let x = |
33 | try x | try x |
34 | with | with |
35 | | a -> b | | a -> b |
36 | | c -> d | | c -> d |
37 | ||
38 | let z = | let z = |
39 | some_function | some_function |
40 | argument | argument |
41 | ||
42 | ||
43 | ||
44 | (* dwu *) | (* dwu *) |
45 | let () = | let () = |
46 | f a b ~c:c | f a b ~c:c |
47 | d | d |
48 | ||
49 | let () = | let () = |
50 | f a b ~c:1. | f a b ~c:1. |
51 | d | d |
52 | ||
53 | let () = | let () = |
54 | My_module.f a b ~c:c | My_module.f a b ~c:c |
55 | d | d |
56 | ||
57 | (* This last case is where Tuareg is inconsistent with the others. *) | (* This last case is where Tuareg is inconsistent with the others. *) |
58 | let () = | let () = |
59 | My_module.f a b ~c:1. | My_module.f a b ~c:1. |
60 | d | d |
61 | ||
62 | ||
63 | ||
64 | let () = | let () = |
65 | messages := | messages := |
66 | Message_store.create (Session_id.of_string "") | Message_store.create (Session_id.of_string "") |
67 | (* Tuareg indents these lines too far to the left. *) | (* Tuareg indents these lines too far to the left. *) |
68 | "herd-retransmitter" | "herd-retransmitter" |
69 | Message_store.Message_size.Byte | Message_store.Message_size.Byte |
70 | ||
71 | ||
72 | ||
73 | let () = | let () = |
74 | raise (Bug ("foo" | raise (Bug ("foo" |
75 | (* In this and similar cases, we want the subsequent lines to | (* In this and similar cases, we want the subsequent lines to |
76 | align with the first expression. *) | align with the first expression. *) |
77 | ^ "bar")); | ^ "bar")); |
78 | raise (Bug ("foo" ^ "quux" | raise (Bug ("foo" ^ "quux" |
79 | ^ "bar")); | ^ "bar")); |
80 | raise (Bug (foo + quux | raise (Bug (foo + quux |
81 | ^ "bar")); | ^ "bar")); |
82 | raise (Bug ((foo + quux) | raise (Bug ((foo + quux) |
83 | ^ "bar")) | ^ "bar")) |
84 | ||
85 | (* Except in specific cases, we want the argument indented relative to the | (* Except in specific cases, we want the argument indented relative to the |
86 | function being called. (Exceptions include "fun" arguments where the line | function being called. (Exceptions include "fun" arguments where the line |
87 | ends with "->" and subsequent lines beginning with operators, like above.) *) | ends with "->" and subsequent lines beginning with operators, like above.) *) |
88 | let () = | let () = |
89 | Some (Message_store.create s | Some (Message_store.create s |
90 | "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte) | "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte) |
91 | ||
92 | ||
93 | ||
94 | (* We like the indentation of most arguments, but want to get back towards the | (* We like the indentation of most arguments, but want to get back towards the |
95 | left margin in a few special cases: *) | left margin in a few special cases: *) |
96 | let _ = | let _ = |
97 | foo (bar (fun x -> (* special: "fun _ ->" at EOL *) | foo (bar (fun x -> (* special: "fun _ ->" at EOL *) |
98 | baz)) (* assume no more arguments to "bar" *) | baz)) (* assume no more arguments to "bar" *) |
99 | let _ = | let _ = |
100 | foo | foo |
101 | ~a_long_field_name:(check (fun bar -> | ~a_long_field_name:(check (fun bar -> |
102 | baz)) | baz)) |
103 | let _ = | let _ = |
104 | foo ~a_long_field_name:(check (fun bar -> | foo ~a_long_field_name:(check (fun bar -> |
105 | baz)) | baz)) |
106 | let _ = | let _ = |
107 | foo (bar (quux (fnord (fun x -> (* any depth *) | foo (bar (quux (fnord (fun x -> (* any depth *) |
108 | baz)))) | baz)))) |
109 | ||
110 | (* We also wanted to tweak the operator indentation, making operators like <= | (* We also wanted to tweak the operator indentation, making operators like <= |
111 | not special cases in contexts like this: *) | not special cases in contexts like this: *) |
112 | let _ = | let _ = |
113 | assert (foo (bar + baz | assert (foo (bar + baz |
114 | <= quux)) (* lined up under left argument to op, | <= quux)) (* lined up under left argument to op, |
115 | sim. to ^ above *) | sim. to ^ above *) |
116 | (* Sim. indentation of if conditions: *) | (* Sim. indentation of if conditions: *) |
117 | let _ = | let _ = |
118 | if (a | if (a |
119 | <= b) | <= b) |
120 | then () | then () |
121 | let _ = | let _ = |
122 | if a | if a |
123 | <= b | <= b |
124 | then () | then () |
125 | let _ = | let _ = |
126 | if Edge_adjustment.is_zero arb.cfg.extra_edge | if Edge_adjustment.is_zero arb.cfg.extra_edge |
127 | ·····&&·0.·=·sys.plugs.edge_backoff | ··&&·0.·=·sys.plugs.edge_backoff |
128 | ·····&&·0.·=·zero_acvol_edge_backoff | ··&&·0.·=·zero_acvol_edge_backoff |
129 | then 0. | then 0. |
130 | else 1. | else 1. |
131 | let _ = | let _ = |
132 | if | if |
133 | Edge_adjustment.is_zero arb.cfg.extra_edge | Edge_adjustment.is_zero arb.cfg.extra_edge |
134 | && 0. = sys.plugs.edge_backoff | && 0. = sys.plugs.edge_backoff |
135 | && 0. = zero_acvol_edge_backoff | && 0. = zero_acvol_edge_backoff |
136 | then 0. | then 0. |
137 | else 1. | else 1. |
138 | let _ = | let _ = |
139 | let entries = List.filter (Lazy.force transferstati) ~f:(fun ts -> | let entries = List.filter (Lazy.force transferstati) ~f:(fun ts -> |
140 | Pcre.pmatch ~pat ts.RQ.description | Pcre.pmatch ~pat ts.RQ.description |
141 | ) in | ) in |
142 | x | x |
143 | ||
144 | (* combination of operator at BOL and -> at EOL: *) | (* combination of operator at BOL and -> at EOL: *) |
145 | let _ = | let _ = |
146 | Shell.ssh_lines x | Shell.ssh_lines x |
147 | |! List.map ~f:(f (g (fun x -> | |! List.map ~f:(f (g (fun x -> |
148 | ·······let·name,·path·=·String.lsplit2_exn·~on:'|'·x·in | ····let·name,·path·=·String.lsplit2_exn·~on:'|'·x·in |
149 | ·······String.strip·name,·String.strip·path))) | ····String.strip·name,·String.strip·path))) |
150 | ||
151 | (* open paren ending line like begin *) | (* open paren ending line like begin *) |
152 | let _ = | let _ = |
153 | if a (p ^/ "s") [ e ] = Ok () then `S ( | if a (p ^/ "s") [ e ] = Ok () then `S ( |
154 | let label count = | let label count = |
155 | sprintf "%d s" c ^ if c = 1 then ":" else "s" | sprintf "%d s" c ^ if c = 1 then ":" else "s" |
156 | in | in |
157 | x | x |
158 | ) | ) |
Expected | Ocp-indent output | |
---|---|---|
0 | BENCH_FUN "Array.get (tuple)" = | BENCH_FUN "Array.get (tuple)" = |
1 | ··(*·This·is·mis-indented·only·when·BENCH_FUN·is·on·the·first·line.·*) | (*·This·is·mis-indented·only·when·BENCH_FUN·is·on·the·first·line.·*) |
2 | ··let·len·=·300·in | let·len·=·300·in |
3 | ··let·arr·=·create·~len·(1,2)·in | let·arr·=·create·~len·(1,2)·in |
4 | ··(fun·()·->·ignore(arr.(len-1))) | (fun·()·->·ignore(arr.(len-1))) |
5 | ||
6 | BENCH_FUN "Array.set (tuple)" = | BENCH_FUN "Array.set (tuple)" = |
7 | let len = 300 in | let len = 300 in |
8 | let arr = create ~len (1,2) in | let arr = create ~len (1,2) in |
9 | (fun () -> arr.(len-1) <- (3,4)) | (fun () -> arr.(len-1) <- (3,4)) |
10 | ||
11 | (* Some benchmarks of the blit operations *) | (* Some benchmarks of the blit operations *) |
12 | BENCH_MODULE "Blit tests" = struct | BENCH_MODULE "Blit tests" = struct |
13 | let lengths = [0; 10; 100; 1000; 10_000] | let lengths = [0; 10; 100; 1000; 10_000] |
14 | ||
15 | BENCH_MODULE "Int" = struct | BENCH_MODULE "Int" = struct |
16 | BENCH_INDEXED "blit" len lengths = | BENCH_INDEXED "blit" len lengths = |
17 | let src = create ~len 0 in | let src = create ~len 0 in |
18 | let dst = create ~len 0 in | let dst = create ~len 0 in |
19 | (fun () -> Int.blit ~src ~src_pos:0 ~dst ~dst_pos:0 ~len) | (fun () -> Int.blit ~src ~src_pos:0 ~dst ~dst_pos:0 ~len) |
20 | ||
21 | BENCH_INDEXED "blito" len lengths = | BENCH_INDEXED "blito" len lengths = |
22 | let src = create ~len 0 in | let src = create ~len 0 in |
23 | let dst = create ~len 0 in | let dst = create ~len 0 in |
24 | (fun () -> Int.blito ~src ~src_pos:0 ~dst ~dst_pos:0 ~src_len:len ()) | (fun () -> Int.blito ~src ~src_pos:0 ~dst ~dst_pos:0 ~src_len:len ()) |
25 | end | end |
26 | ||
27 | BENCH_MODULE "Float" = struct | BENCH_MODULE "Float" = struct |
28 | BENCH_INDEXED "blit" len lengths = | BENCH_INDEXED "blit" len lengths = |
29 | let src = create ~len 0.0 in | let src = create ~len 0.0 in |
30 | let dst = create ~len 0.0 in | let dst = create ~len 0.0 in |
31 | (fun () -> Float.blit ~src ~src_pos:0 ~dst ~dst_pos:0 ~len) | (fun () -> Float.blit ~src ~src_pos:0 ~dst ~dst_pos:0 ~len) |
32 | ||
33 | BENCH_INDEXED "blito" len lengths = | BENCH_INDEXED "blito" len lengths = |
34 | let src = create ~len 0.0 in | let src = create ~len 0.0 in |
35 | let dst = create ~len 0.0 in | let dst = create ~len 0.0 in |
36 | (fun () -> Float.blito ~src ~src_pos:0 ~dst ~dst_pos:0 ~src_len:len ()) | (fun () -> Float.blito ~src ~src_pos:0 ~dst ~dst_pos:0 ~src_len:len ()) |
37 | end | end |
38 | end | end |
Expected | Ocp-indent output | |
---|---|---|
0 | (* maizatulin *) | (* maizatulin *) |
1 | type t = | type t = |
2 | { last_trading : Week_date.Spec.t; | { last_trading : Week_date.Spec.t; |
3 | first_notice : Week_date.Spec.t option; | first_notice : Week_date.Spec.t option; |
4 | first_notice_exceptions : Date.t Year_month.Map.t | first_notice_exceptions : Date.t Year_month.Map.t |
5 | ······with·default(Year_month.Map.empty); | ····with·default(Year_month.Map.empty); |
6 | ····offset·······:·Week_date.Offset.t; | ·········offset·······:·Week_date.Offset.t; |
7 | ····(*·n·>·0·*) | ·········(*·n·>·0·*) |
8 | ····new_contract_expires_in_n_months·:·int | ·········new_contract_expires_in_n_months·:·int |
9 | } with sexp, compare | } with sexp, compare |
Expected | Ocp-indent output | |
---|---|---|
0 | module M = | module M = |
1 | Foo (G) | Foo (G) |
2 | (H) | (H) |
3 | ||
4 | module M = | module M = |
5 | Foo | Foo |
6 | (G) | (G) |
7 | (struct | (struct |
8 | let x | let x |
9 | end) | end) |
10 | (H) | (H) |
11 | ||
12 | (* pszilagyi: To me, this looks fine as it is. The rule seems fine as "indent | (* pszilagyi: To me, this looks fine as it is. The rule seems fine as "indent |
13 | arguments by 2". To illustrate, with a case where the functor name is | arguments by 2". To illustrate, with a case where the functor name is |
14 | longer: *) | longer: *) |
15 | module M = | module M = |
16 | Functor (G) | Functor (G) |
17 | (H) | (H) |
18 | (I) | (I) |
19 | ||
20 | ||
21 | ||
22 | (* sweeks *) | (* sweeks *) |
23 | ||
24 | include Foo (struct | include Foo (struct |
25 | ····let·x | ··let·x |
26 | ··end)·(struct | end)·(struct |
27 | ····let·y | ··let·y |
28 | ··end) | end) |
29 | ||
30 | include | include |
31 | Foo (struct | Foo (struct |
32 | let x | let x |
33 | end) (struct | end) (struct |
34 | let y | let y |
35 | end) | end) |
36 | ||
37 | module M = | module M = |
38 | Foo (struct | Foo (struct |
39 | let x | let x |
40 | end) (struct | end) (struct |
41 | let y | let y |
42 | end) | end) |
43 | ||
44 | module M : S = | module M : S = |
45 | Make (M) | Make (M) |
46 | module M : S with type t := int = | module M : S with type t := int = |
47 | Make (M) | Make (M) |
Expected | Ocp-indent output | |
---|---|---|
0 | let foo | let foo |
1 | some very long arguments that we break onto the next line | some very long arguments that we break onto the next line |
2 | = | = |
3 | bar (); | bar (); |
4 | baz | baz |
5 | (* The [some] above is indented less when [let foo] is the first line. The | (* The [some] above is indented less when [let foo] is the first line. The |
6 | problem goes away if there's anything on the line before [let foo]. *) | problem goes away if there's anything on the line before [let foo]. *) |
7 | ||
8 | (* The picture shows where we want the `=' to be. However, Tuareg currently moves it over | (* The picture shows where we want the `=' to be. However, Tuareg currently moves it over |
9 | to line up with the arguments. | to line up with the arguments. |
10 | ||
11 | Perhaps this is merely a personal preference, but that seems ugly to me. | Perhaps this is merely a personal preference, but that seems ugly to me. |
12 | ||
13 | pszilagyi: It's consistent with other infix operators (although this is syntax) for it | pszilagyi: It's consistent with other infix operators (although this is syntax) for it |
14 | to be where you prefer. *) | to be where you prefer. *) |
15 | ||
16 | let foo arguments | let foo arguments |
17 | = bar | = bar |
18 | ||
19 | let foo | let foo |
20 | arguments | arguments |
21 | = bar | = bar |
22 | ||
23 | (* sweeks *) | (* sweeks *) |
24 | (* This program parses, but the [let] is indented incorrectly. *) | (* This program parses, but the [let] is indented incorrectly. *) |
25 | module M = struct | module M = struct |
26 | module M : module type of M = struct | module M : module type of M = struct |
27 | let x = () | let x = () |
28 | end | end |
29 | end | end |
30 | (* Removing the [: module type of M] removes the bug. *) | (* Removing the [: module type of M] removes the bug. *) |
31 | ||
32 | let parenthesized_let_tweak = | let parenthesized_let_tweak = |
33 | (let sub value n l f = | (let sub value n l f = |
34 | ·····case·~value·(message·("fix_sending_"·^·n)·~length:(35·+·29·+·l)·f) | ····case·~value·(message·("fix_sending_"·^·n)·~length:(35·+·29·+·l)·f) |
35 | in | in |
36 | x) | x) |
37 | ||
38 | let parenthesized_let_tweak = | let parenthesized_let_tweak = |
39 | f ~x:(let n = | f ~x:(let n = |
40 | ··········S.S.g·s.S.s·~s | ·········S.S.g·s.S.s·~s |
41 | in | in |
42 | y) | y) |
Expected | Ocp-indent output | |
---|---|---|
0 | (* mixed list styles *) | (* mixed list styles *) |
1 | (* nlinger *) | (* nlinger *) |
2 | let cases = | let cases = |
3 | [ Group ("publishing", [ | [ Group ("publishing", [ |
4 | ······basic_pre2 | ·····basic_pre2 |
5 | ········~name; | ·······~name; |
6 | ····]);·(*·I·think·this·line·and·the·2·preceding·ones·are·indented·one·space·too | ···]);·(*·I·think·this·line·and·the·2·preceding·ones·are·indented·one·space·too |
7 | ···········few·by·ocp-indent·*) | ··········few·by·ocp-indent·*) |
8 | Group ("recovery", [ | Group ("recovery", [ |
9 | basic_pre2 | basic_pre2 |
10 | ~name | ~name |
11 | ]); | ]); |
12 | ] | ] |
Expected | Ocp-indent output | |
---|---|---|
0 | (* Relatively low priority Jane Street indentation bugs. *) | (* Relatively low priority Jane Street indentation bugs. *) |
1 | ||
2 | ||
3 | ||
4 | (* js-args *) | (* js-args *) |
5 | ||
6 | (* uncommon *) | (* uncommon *) |
7 | let x = | let x = |
8 | try x with a -> b | try x with a -> b |
9 | | c -> d | | c -> d |
10 | let x = | let x = |
11 | try x | try x |
12 | with a -> b | with a -> b |
13 | | c -> d | | c -> d |
14 | ||
15 | ||
16 | ||
17 | (* js-comment *) | (* js-comment *) |
18 | ||
19 | (* maizatulin *) | (* maizatulin *) |
20 | let mk_cont_parser cont_parse = (); fun _state str ~max_pos ~pos -> | let mk_cont_parser cont_parse = (); fun _state str ~max_pos ~pos -> |
21 | let len = max_pos - pos + 1 in | let len = max_pos - pos + 1 in |
22 | cont_parse ~pos ~len str | cont_parse ~pos ~len str |
23 | ||
24 | (* CR-someday maizatulin: sexp parser is sensitive to | (* CR-someday maizatulin: sexp parser is sensitive to |
25 | absent newlines at the end of files. *) | absent newlines at the end of files. *) |
26 | ||
27 | ||
28 | ||
29 | (* It would be nice if a partially completed ocamldoc code fragment inside a | (* It would be nice if a partially completed ocamldoc code fragment inside a |
30 | comment had the closing delimiter "]}" indented nicely before the comment is | comment had the closing delimiter "]}" indented nicely before the comment is |
31 | closed. (This has to be the last comment in the file, to be partial.) *) | closed. (This has to be the last comment in the file, to be partial.) *) |
32 | (* CR sweeks: Maybe add: | (* CR sweeks: Maybe add: |
33 | {[ | {[ |
34 | val state : t -> [ `Unstarted | `Running | `Stopped ] | val state : t -> [ `Unstarted | `Running | `Stopped ] |
35 | ···]} | ]} |
Expected | Ocp-indent output | |
---|---|---|
0 | type x = | type x = |
1 | { foo : int | { foo : int |
2 | ; bar : int | ; bar : int |
3 | } | } |
4 | ||
5 | let x = | let x = |
6 | { x with | { x with |
7 | foo = 3 | foo = 3 |
8 | ; bar = 5 | ; bar = 5 |
9 | } | } |
10 | ||
11 | let x = | let x = |
12 | { (* blah blah blah *) | { (* blah blah blah *) |
13 | foo = 3 | foo = 3 |
14 | ; bar = 5 | ; bar = 5 |
15 | } | } |
16 | ;; | ;; |
17 | ||
18 | let x = | let x = |
19 | [{ x with | [{ x with |
20 | foo = 3 | foo = 3 |
21 | ; bar = 5 | ; bar = 5 |
22 | }] | }] |
23 | ||
24 | let x = | let x = |
25 | [{ (* blah blah blah *) | [{ (* blah blah blah *) |
26 | ·····foo·=·3 | ····foo·=·3 |
27 | ···;·bar·=·5 | ··;·bar·=·5 |
28 | ···}] | ··}] |
29 | ;; | ;; |
30 | ||
31 | let x = | let x = |
32 | { M.x with | { M.x with |
33 | M. | M. |
34 | foo = 3 | foo = 3 |
35 | } | } |
36 | ;; | ;; |
37 | ||
38 | let x = | let x = |
39 | { x with | { x with |
40 | M. | M. |
41 | foo = 3 | foo = 3 |
42 | } | } |
43 | ;; | ;; |
44 | ||
45 | let x = | let x = |
46 | { M. | { M. |
47 | foo = 3 | foo = 3 |
48 | } | } |
49 | ;; | ;; |
50 | ||
51 | (* sweeks bug report *) | (* sweeks bug report *) |
52 | let _ = | let _ = |
53 | { foo with | { foo with |
54 | Bar. | Bar. |
55 | field1 = value1 | field1 = value1 |
56 | ; field2 = value2 | ; field2 = value2 |
57 | } | } |
58 | ;; | ;; |
59 | (* sweeks preference *) | (* sweeks preference *) |
60 | let _ = | let _ = |
61 | { foo | { foo |
62 | with Bar. | with Bar. |
63 | ····field1·=·value1 | ······field1·=·value1 |
64 | ··;·field2·=·value2 | ····;·field2·=·value2 |
65 | } | } |
66 | ;; | ;; |
67 | ||
68 | (* multicomponent record module pathname *) | (* multicomponent record module pathname *) |
69 | let _ = | let _ = |
70 | { A.B. | { A.B. |
71 | ····a·=·b | ······a·=·b |
72 | ; c = d | ; c = d |
73 | } | } |
74 | ;; | ;; |
Expected | Ocp-indent output | |
---|---|---|
0 | TEST = | TEST = |
1 | ··let·b·=·true·in | let·b·=·true·in |
2 | ··b | b |
3 | (* Above, a multi-line TEST (likewise BENCH) is indented wrong only when it | (* Above, a multi-line TEST (likewise BENCH) is indented wrong only when it |
4 | starts on the first line. (That's not really a big problem.) *) | starts on the first line. (That's not really a big problem.) *) |
5 | ||
6 | (* oUnit *) | (* oUnit *) |
7 | ||
8 | module E = Example | module E = Example |
9 | ||
10 | TEST_MODULE = struct | TEST_MODULE = struct |
11 | TEST = false | TEST = false |
12 | TEST = | TEST = |
13 | let b = true in | let b = true in |
14 | b | b |
15 | TEST "Name_test" = | TEST "Name_test" = |
16 | let b = true in (* tricky for Tuareg *) | let b = true in (* tricky for Tuareg *) |
17 | b | b |
18 | end | end |
19 | ||
20 | TEST_MODULE "Name" = struct | TEST_MODULE "Name" = struct |
21 | TEST_UNIT = () | TEST_UNIT = () |
22 | TEST_UNIT = | TEST_UNIT = |
23 | let () = () in | let () = () in |
24 | () | () |
25 | TEST_UNIT "Name_unit" = | TEST_UNIT "Name_unit" = |
26 | let () = () in (* tricky for Tuareg *) | let () = () in (* tricky for Tuareg *) |
27 | () | () |
28 | ||
29 | TEST_UNIT = | TEST_UNIT = |
30 | let msgcount = 10_000 in (* tricky for Tuareg *) | let msgcount = 10_000 in (* tricky for Tuareg *) |
31 | () | () |
32 | end | end |
33 | ||
34 | let _ = printf "Hello, world!\n" | let _ = printf "Hello, world!\n" |
Expected | Ocp-indent output | |
---|---|---|
0 | (* Indentation that Jane Street needs to think about and make precise. | (* Indentation that Jane Street needs to think about and make precise. |
1 | ||
2 | These are long term ideas, possibly even conflicting with other tests. *) | These are long term ideas, possibly even conflicting with other tests. *) |
3 | ||
4 | ||
5 | ||
6 | (* js-args *) | (* js-args *) |
7 | ||
8 | let _ = | let _ = |
9 | let min_closing_backoff = | let min_closing_backoff = |
10 | -. ( Hidden_float.expose (arb.cfg.base_edge @! Buy) | -. ( Hidden_float.expose (arb.cfg.base_edge @! Buy) |
11 | ········+.·Hidden_float.expose·(arb.cfg.base_edge·@!·Sell)) | ···········+.·Hidden_float.expose·(arb.cfg.base_edge·@!·Sell)) |
12 | in | in |
13 | 0 | 0 |
14 | ||
15 | ||
16 | ||
17 | (* js-type *) | (* js-type *) |
18 | ||
19 | (* The following tests incorporate several subtle and different indentation | (* The following tests incorporate several subtle and different indentation |
20 | ideas. Please consider this only a proposal for discussion, for now. | ideas. Please consider this only a proposal for discussion, for now. |
21 | ||
22 | First, notice the display treatment of "(,)" tuples, analogous to "[;]" | First, notice the display treatment of "(,)" tuples, analogous to "[;]" |
23 | lists. While "(,)" is an intensional combination of "()" and ",", unlike | lists. While "(,)" is an intensional combination of "()" and ",", unlike |
24 | "[;]" lists, we believe "(,)" isn't too big a departure. Value expression | "[;]" lists, we believe "(,)" isn't too big a departure. Value expression |
25 | analogies are included in js-type.ml, (meant to be) consistent with the | analogies are included in js-type.ml, (meant to be) consistent with the |
26 | proposed type indentation. | proposed type indentation. |
27 | ||
28 | Second, and more divergently, the proposed indentation of function types is | Second, and more divergently, the proposed indentation of function types is |
29 | based on the idea of aligning the arguments, even the first argument, even | based on the idea of aligning the arguments, even the first argument, even |
30 | where that means automatically inserting spaces within lines. This applies | where that means automatically inserting spaces within lines. This applies |
31 | to the extra spaces in ":__unit" and "(____Config.Network.t" below. | to the extra spaces in ":__unit" and "(____Config.Network.t" below. |
32 | ||
33 | We believe this fits into a more general incorporation of alignment into | We believe this fits into a more general incorporation of alignment into |
34 | ocp-indent, to replace our internal alignment tool with a syntax-aware one. | ocp-indent, to replace our internal alignment tool with a syntax-aware one. |
35 | We like to align things for readability, like big records, record types, | We like to align things for readability, like big records, record types, |
36 | lists used to build tables, etc. | lists used to build tables, etc. |
37 | ||
38 | The proposal also includes indenting "->" in the circumstances below relative | The proposal also includes indenting "->" in the circumstances below relative |
39 | to the enclosing "()", by two spaces. In a sense, this happens first, and | to the enclosing "()", by two spaces. In a sense, this happens first, and |
40 | then the first argument is aligned accordingly. So, there's no manual | then the first argument is aligned accordingly. So, there's no manual |
41 | indentation or spacing below. *) | indentation or spacing below. *) |
42 | ||
43 | (* sweeks *) | (* sweeks *) |
44 | val instances | val instances |
45 | : unit | : unit |
46 | -> ( Config.Network.t | -> ( Config.Network.t |
47 | ·······->·(App.t·*·Config.instance·*·Config.app)·list | ··········->·(App.t·*·Config.instance·*·Config.app)·list |
48 | ·······->·verbose:bool | ··········->·verbose:bool |
49 | ·······->·'m | ··········->·'m |
50 | , 'm | , 'm |
51 | ) Command.Spec.t | ) Command.Spec.t |
52 | ||
53 | (* jmcarthur *) | (* jmcarthur *) |
54 | val instances | val instances |
55 | : unit | : unit |
56 | -> ( Config.Network.t | -> ( Config.Network.t |
57 | ·······->·(App.t·*·Config.instance·*·Config.app)·list | ··········->·(App.t·*·Config.instance·*·Config.app)·list |
58 | ·······->·verbose:bool·->·'m | ··········->·verbose:bool·->·'m |
59 | , 'm | , 'm |
60 | ) Command.Spec.t | ) Command.Spec.t |
61 | ||
62 | (* presumed analog with stars *) | (* presumed analog with stars *) |
63 | val instances : | val instances : |
64 | unit | unit |
65 | * ( Config.Network.t | * ( Config.Network.t |
66 | ······*·(App.t·*·Config.instance·*·Config.app)·list | ········*·(App.t·*·Config.instance·*·Config.app)·list |
67 | ······*·bool | ········*·bool |
68 | ······*·'m | ········*·'m |
69 | , 'm | , 'm |
70 | ) Command.Spec.t | ) Command.Spec.t |
Expected | Ocp-indent output | |
---|---|---|
0 | type t = | type t = |
1 | ··S.s········(*·looks·like·a·constructor·to·ocp-indent,·which·indents·too·far·*) | ····S.s········(*·looks·like·a·constructor·to·ocp-indent,·which·indents·too·far·*) |
2 | type t = | type t = |
3 | s (* correct, because this doesn't look like a constructor to ocp-indent *) | s (* correct, because this doesn't look like a constructor to ocp-indent *) |
4 | type t = | type t = |
5 | S (* correctly indented a little more, because... *) | S (* correctly indented a little more, because... *) |
6 | type t = | type t = |
7 | | S (* we leave room for the vertical bar *) | | S (* we leave room for the vertical bar *) |
8 | ||
9 | ||
10 | ||
11 | (* analogous value expressions, analogous to lists, some different from now *) | (* analogous value expressions, analogous to lists, some different from now *) |
12 | let _ = | let _ = |
13 | [ x | [ x |
14 | ; y | ; y |
15 | ] | ] |
16 | let _ = | let _ = |
17 | [ x; | [ x; |
18 | y | y |
19 | ] | ] |
20 | let _ = | let _ = |
21 | ( x | ( x |
22 | , y | , y |
23 | ) | ) |
24 | let _ = | let _ = |
25 | ( x, | ( x, |
26 | y | y |
27 | ) | ) |
28 | let _ = | let _ = |
29 | ( | ( |
30 | x | x |
31 | , y | , y |
32 | ) | ) |
33 | let _ = | let _ = |
34 | [ | [ |
35 | x | x |
36 | ; y | ; y |
37 | ] | ] |
38 | let _ = ( | let _ = ( |
39 | x, | x, |
40 | y | y |
41 | ) | ) |
42 | let _ = [ | let _ = [ |
43 | x; | x; |
44 | y | y |
45 | ] | ] |
46 | let _ = ( | let _ = ( |
47 | x | x |
48 | , y | , y |
49 | ) | ) |
50 | let _ = [ | let _ = [ |
51 | x | x |
52 | ; y | ; y |
53 | ] | ] |