diff --git a/dune-project b/dune-project index ed5b69b4..d879c429 100644 --- a/dune-project +++ b/dune-project @@ -1,3 +1,3 @@ -(lang dune 1.0) +(lang dune 3.20) (name ocp-indent) (version 1.8.1) diff --git a/ocp-indent.opam b/ocp-indent.opam index 4786c421..63b7aa73 100644 --- a/ocp-indent.opam +++ b/ocp-indent.opam @@ -31,7 +31,7 @@ run-test: [ ] depends: [ "ocaml" {>= "4.08"} - "dune" {>= "1.0"} + "dune" {>= "3.20"} "cmdliner" {>= "1.3.0"} "ocamlfind" ] diff --git a/tests/failing-output/escaped-nl.ml b/tests/failing-output/escaped-nl.ml deleted file mode 100644 index 1c9821d5..00000000 --- a/tests/failing-output/escaped-nl.ml +++ /dev/null @@ -1,44 +0,0 @@ -let s1 = "No field 'install', but a field 'remove': install instructions \ - probably part of 'build'. Use the 'install' field or a .install \ - file" - -let x = - cond 40 `Warning - "Package uses flags that aren't recognised by earlier versions in \ - OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \ - instead for compatibility" - ~detail:alpha_flags - (alpha_flags <> []) - -let s2 = "bla bla - bli bli \ - blo" - -let s3 = "\ -" - -let s4 = " \ - " - -let s5 = " \ - \ - " - -let s6 = " -" - -let s7 = " -" - -let c1 = ' - ' - -let x1 = f x ' - ' y - z - -let zz = "\ - -s \ - \ - " diff --git a/tests/failing-output/indent-empty-numeric.ml b/tests/failing-output/indent-empty-numeric.ml deleted file mode 100644 index 4a1ad12a..00000000 --- a/tests/failing-output/indent-empty-numeric.ml +++ /dev/null @@ -1,10 +0,0 @@ -0 -0 -2 -2 -0 -0 -0 -0 -2 -15 diff --git a/tests/failing-output/js-args.ml b/tests/failing-output/js-args.ml deleted file mode 100644 index 729f7196..00000000 --- a/tests/failing-output/js-args.ml +++ /dev/null @@ -1,162 +0,0 @@ -let () = - foo.bar <- - f x - y z - -let should_check_can_sell_and_marking regulatory_regime = - match z with - | `foo - -> some_function - argument -(* The above typically occurs in a multi-pattern match clause, so the clause - expression is on a line by itself. This is the more typical way a long - single-pattern match clause would be written: *) -let should_check_can_sell_and_marking regulatory_regime = - match z with - | `foo -> - some_function - argument - -let f = fun x -> - ghi - x - -(* common *) -let x = - try x with - | a -> b - | c -> d -let x = try x with - | a -> b - | c -> d -let x = - try x - with - | a -> b - | c -> d - -let z = - some_function - argument - - - -let () = - f a b ~c:c - d - -let () = - f a b ~c:1. - d - -let () = - My_module.f a b ~c:c - d - -(* This last case is where Tuareg is inconsistent with the others. *) -let () = - My_module.f a b ~c:1. - d - - - -let () = - messages := - Message_store.create (Session_id.of_string "") - (* Tuareg indents these lines too far to the left. *) - "herd-retransmitter" - Message_store.Message_size.Byte - - - -let () = - raise (Bug ("foo" - (* In this and similar cases, we want the subsequent lines to - align with the first expression. *) - ^ "bar")); - raise (Bug ("foo" ^ "quux" - ^ "bar")); - raise (Bug (foo + quux - ^ "bar")); - raise (Bug ((foo + quux) - ^ "bar")) - -(* Except in specific cases, we want the argument indented relative to the - function being called. (Exceptions include "fun" arguments where the line - ends with "->" and subsequent lines beginning with operators, like above.) *) -let () = - Some (Message_store.create s - "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte) - - - -(* We like the indentation of most arguments, but want to get back towards the - left margin in a few special cases: *) -let _ = - foo (bar (fun x -> (* special: "fun _ ->" at EOL *) - baz)) (* assume no more arguments to "bar" *) -let _ = - foo - ~a_long_field_name:(check (fun bar -> - baz)) -let _ = - foo ~a_long_field_name:(check (fun bar -> - baz)) -let _ = - foo (bar (quux (fnord (fun x -> (* any depth *) - baz)))) - -(* We also wanted to tweak the operator indentation, making operators like <= - not special cases in contexts like this: *) -let _ = - assert (foo (bar + baz - <= quux)) (* lined up under left argument to op, - sim. to ^ above *) -(* Sim. indentation of if conditions: *) -let _ = - if (a - <= b) - then () -let _ = - (* Comparisons are different than conditionals; we don't regard them as - conceptually part of the [if] expression. *) - if a - <= b - then () -let _ = - (* We regard the outermost condition terms as conceptually part of the [if] - expression and indent accordingly. Whether [&&] or [||], conditionals - effectively state lists of conditions for [then]. *) - if Edge_adjustment.is_zero arb.cfg.extra_edge - && 0. = sys.plugs.edge_backoff - && 0. = zero_acvol_edge_backoff - then 0. - else 1. -let _ = - if - Edge_adjustment.is_zero arb.cfg.extra_edge - && 0. = sys.plugs.edge_backoff - && 0. = zero_acvol_edge_backoff - then 0. - else 1. -let _ = - let entries = List.filter (Lazy.force transferstati) ~f:(fun ts -> - Pcre.pmatch ~pat ts.RQ.description - ) in - x - -(* combination of operator at BOL and -> at EOL: *) -let _ = - Shell.ssh_lines x - |! List.map ~f:(f (g (fun x -> - let name, path = String.lsplit2_exn ~on:'|' x in - String.strip name, String.strip path))) - -(* open paren ending line like begin *) -let _ = - if a (p ^/ "s") [ e ] = Ok () then `S ( - let label count = - sprintf "%d s" c ^ if c = 1 then ":" else "s" - in - x - ) diff --git a/tests/failing-output/js-begin.ml b/tests/failing-output/js-begin.ml deleted file mode 100644 index e679cc70..00000000 --- a/tests/failing-output/js-begin.ml +++ /dev/null @@ -1,17 +0,0 @@ -let f = function - | zoo -> begin - foo; - bar; - end -;; -let g = function - | zoo -> ( - foo; - bar; - ) -;; -let () = - begin match foo with - | Bar -> snoo - end -;; diff --git a/tests/failing-output/js-fun.ml b/tests/failing-output/js-fun.ml deleted file mode 100644 index df9810c5..00000000 --- a/tests/failing-output/js-fun.ml +++ /dev/null @@ -1,132 +0,0 @@ -(* preferred list style *) -let z = - f - [ y - ; foo ~f:(fun () -> - arg) - ] -;; -let z = - f - [ y - ; foo ~f:(fun () -> - arg - ) - ] -;; - -(* legacy list style *) -let _ = - [ f (fun x -> - x); - f (fun x -> - x); - f (fun x -> - x); - ] -let _ = - [ f (fun x -> - x - ); - f (fun x -> - x - ); - f (fun x -> - x - ); - ] -;; -let _ = - [f (fun x -> - x - ); - f (fun x -> - x - ); - f (fun x -> - x - ); - ] -;; - -let _ = - x - >>= fun x -> - (try x with _ -> ()) - >>= fun x -> - try x with _ -> () - >>= fun x -> - x -;; - -let () = - expr - >>| function - | x -> 3 - | y -> 4 -;; - -let () = - expr - >>| fun z -> match z with - | x -> 3 - | y -> 4 -;; - -let () = - expr - >>| fun z -> function - | x -> 3 - | y -> 4 -;; - -let () = - my_func () >>= function - | A -> 0 - | B -> 0 -;; - -let () = - my_func () >>= (function - | A -> 0 - | B -> 0) -;; - -let () = - expr - >>| function - | x -> 3 - | y -> 4 -;; - -let () = - expr - >>| (function - | x -> 3 - | y -> 4) -;; - - - -let f = - f >>= m (fun f -> - fun x -> - y); - z -;; - -let f = - f - |> m (fun f -> - fun x -> - y - ); - z -;; -let f = - f - |> m (fun f -> - fun x -> - y); - z -;; diff --git a/tests/failing-output/js-functor.ml b/tests/failing-output/js-functor.ml deleted file mode 100644 index 0d6aa696..00000000 --- a/tests/failing-output/js-functor.ml +++ /dev/null @@ -1,93 +0,0 @@ -module M = - Foo (G) - (H) - -module M = - Foo - (G) - (struct - let x - end) - (H) - -(* To me, this looks fine as it is. The rule seems fine as "indent arguments by - 2". To illustrate, with a case where the functor name is longer: *) -module M = - Functor (G) - (H) - (I) - - - -include Foo (struct - let x - end) (struct - let y - end) - -include - Foo (struct - let x - end) (struct - let y - end) - -include - Foo - (struct - let x - end) (struct - let y - end) - -include Persistent.Make - (struct let version = 1 end) - (Stable.Cr_soons_or_pending.V1) - -include Persistent.Make - (struct - let version = 1 - end) - (Stable.Cr_soons_or_pending.V1) - -include - Persistent.Make - (struct let version = 1 end) - (Stable.Cr_soons_or_pending.V1) - -include - Persistent.Make - (struct - let version = 1 - end) - (Stable.Cr_soons_or_pending.V1) - -module M = - Foo (struct - let x - end) (struct - let y - end) - -module M : S = - Make (M) -module M : S with type t := int = - Make (M) - - - -module Simple_command(Arg:sig - end) = struct end - -module Simple_command(Arg : sig - end) = struct end - -module Simple_command (Arg:sig - end) = struct end - -module Simple_command (Arg : sig - end) = struct end - -module Simple_command - (Arg : sig - end) = struct end diff --git a/tests/failing-output/js-pattern.ml b/tests/failing-output/js-pattern.ml deleted file mode 100644 index ea2211b1..00000000 --- a/tests/failing-output/js-pattern.ml +++ /dev/null @@ -1,51 +0,0 @@ -let f = function - | _ -> 0 -;; - -let f x = match x with - | _ -> 0 -;; - -let f = - function - | _ -> 0 -;; - -let f x = - match x with - | _ -> 0 -;; - -let f x = - begin match x with - | _ -> 0 - end -;; - -let check_price t = function - | { Exec. - trade_at_settlement = (None | Some false); - } -> () - -let check_price t = function - | simpler -> () - | other -> () - -(* Sometimes we like to write big alternations like this, in which case the - comment should typically align with the following clause. *) -let 0 = - match x with - | A - (* a *) - -> a -let 0 = - match x with - A - (* a *) - -> a - -let _ = - a - || match a with - | a -> true - | b -> false diff --git a/tests/failing-output/js-record.ml b/tests/failing-output/js-record.ml deleted file mode 100644 index d9af2bd3..00000000 --- a/tests/failing-output/js-record.ml +++ /dev/null @@ -1,103 +0,0 @@ -type x = - { foo : int - ; bar : int - } - -let x = - { x with - foo = 3 - ; bar = 5 - } - -let x = - { (* blah blah blah *) - foo = 3 - ; bar = 5 - } -;; - -let x = - [{ x with - foo = 3 - ; bar = 5 - }] - -let x = - [{ (* blah blah blah *) - foo = 3 - ; bar = 5 - }] -;; - -let x = - { M.x with - M. - foo = 3 - } -;; - -let x = - { x with - M. - foo = 3 - } -;; - -let x = - { M. - foo = 3 - } -;; - -let _ = - { foo with - Bar. - field1 = value1 - ; field2 = value2 - } -;; -let _ = - { foo - with Bar. - field1 = value1 - ; field2 = value2 - } -;; - -(* multicomponent record module pathname *) -let _ = - { A.B. - a = b - ; c = d - } -;; - -type t = - { a - : something_lengthy list list - [@default String.Map.empty] - } - -type t = - { a - : Something_lengthy.t list list - [@default String.Map.empty] - } - -type t = - { a - : something_lengthy list - list - } - -type t = - { a - : Something_lengthy.t list - list - } - -type t = - { a - : Something_lengthy.t - list - } diff --git a/tests/failing-output/js-syntax.ml b/tests/failing-output/js-syntax.ml deleted file mode 100644 index 14590d69..00000000 --- a/tests/failing-output/js-syntax.ml +++ /dev/null @@ -1,15 +0,0 @@ -(* s *) - -let _ = - [%raise_structural_sexp - "feature's tip is already an ancestor of new base" - { feature_tip = (old_tip : Rev.t) - ; new_base = (new_base : Rev.t) - }] - -let _ = - [%raise_structural_sexp "feature's tip is already an ancestor of new base" - { feature_tip = (old_tip : Rev.t) - ; new_base = (new_base : Rev.t) - } - ] diff --git a/tests/failing-output/js-to-do.ml b/tests/failing-output/js-to-do.ml deleted file mode 100644 index 24a989c4..00000000 --- a/tests/failing-output/js-to-do.ml +++ /dev/null @@ -1,69 +0,0 @@ -(* Indentation that Jane Street needs to think about and make precise. - - These are long term ideas, possibly even conflicting with other tests. *) - - - -(* js-args *) - -let _ = - let min_closing_backoff = - -. ( Hidden_float.expose (arb.cfg.base_edge @! Buy) - +. Hidden_float.expose (arb.cfg.base_edge @! Sell)) - in - 0 - - - -(* js-type *) - -(* The following tests incorporate several subtle and different indentation - ideas. Please consider this only a proposal for discussion, for now. - - First, notice the display treatment of "(,)" tuples, analogous to "[;]" - lists. While "(,)" is an intensional combination of "()" and ",", unlike - "[;]" lists, we believe "(,)" isn't too big a departure. Value expression - analogies are included in js-type.ml, (meant to be) consistent with the - proposed type indentation. - - Second, and more divergently, the proposed indentation of function types is - based on the idea of aligning the arguments, even the first argument, even - where that means automatically inserting spaces within lines. This applies - to the extra spaces in ":__unit" and "(____Config.Network.t" below. - - We believe this fits into a more general incorporation of alignment into - ocp-indent, to replace our internal alignment tool with a syntax-aware one. - We like to align things for readability, like big records, record types, - lists used to build tables, etc. - - The proposal also includes indenting "->" in the circumstances below relative - to the enclosing "()", by two spaces. In a sense, this happens first, and - then the first argument is aligned accordingly. So, there's no manual - indentation or spacing below. *) - -val instances - : unit - -> ( Config.Network.t - -> (App.t * Config.instance * Config.app) list - -> verbose:bool - -> 'm - , 'm - ) Command.Spec.t - -val instances - : unit - -> ( Config.Network.t - -> (App.t * Config.instance * Config.app) list - -> verbose:bool -> 'm - , 'm - ) Command.Spec.t - -(* presumed analog with stars *) -val instances : - unit - * ( Config.Network.t - * (App.t * Config.instance * Config.app) list - * bool - * 'm - , 'm - ) Command.Spec.t diff --git a/tests/failing-output/js-upon.ml b/tests/failing-output/js-upon.ml deleted file mode 100644 index d7db7199..00000000 --- a/tests/failing-output/js-upon.ml +++ /dev/null @@ -1,13 +0,0 @@ -let f x = - stop - (* We don't do this as a matter of style, but the indentation reveals a common - mistake. *) - >>> fun () -> don't_wait_for (close fd); - bind fd - -let f x = - stop - (* This is what was intended, which is indented correctly, although it's bad - style on my part. *) - >>> (fun () -> don't_wait_for (close fd)); - bind diff --git a/tests/failing-output/list_of_funs.ml b/tests/failing-output/list_of_funs.ml deleted file mode 100644 index 6398b684..00000000 --- a/tests/failing-output/list_of_funs.ml +++ /dev/null @@ -1,33 +0,0 @@ -let f x = - (fun x -> x [ (fun () -> 3) ; - (fun () -> 4) ]) - -let f x = (fun x -> x [ (fun () -> 3) ; - (fun () -> 4) ]) - -let f x = - x [ (fun () -> 3) ; - (fun () -> 4) ] - -let f x = - [ (fun () -> 3) ; - (fun () -> 4) ] - -let f x = - (fun x -> x [ (fun () -> - 3) ; - (fun () -> 4) ]) - -let f x = (fun x -> x [ (fun () -> - 3) ; - (fun () -> 4) ]) - -let f x = - x [ (fun () -> - 3) ; - (fun () -> 4) ] - -let f x = - [ (fun () -> - 3) ; - (fun () -> 4) ] diff --git a/tests/failing.html b/tests/failing.html deleted file mode 100644 index 271dab15..00000000 --- a/tests/failing.html +++ /dev/null @@ -1,820 +0,0 @@ - - -
-| Expected | Ocp-indent output | |
|---|---|---|
| 0 | let s1 = "No field 'install', but a field 'remove': install instructions \ | let s1 = "No field 'install', but a field 'remove': install instructions \ |
| 1 | probably part of 'build'. Use the 'install' field or a .install \ | probably part of 'build'. Use the 'install' field or a .install \ |
| 2 | file" | file" |
| 3 | ||
| 4 | let x = | let x = |
| 5 | cond 40 `Warning | cond 40 `Warning |
| 6 | "Package uses flags that aren't recognised by earlier versions in \ | "Package uses flags that aren't recognised by earlier versions in \ |
| 7 | OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \ | OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \ |
| 8 | instead for compatibility" | instead for compatibility" |
| 9 | ~detail:alpha_flags | ~detail:alpha_flags |
| 10 | (alpha_flags <> []) | (alpha_flags <> []) |
| 11 | ||
| 12 | let s2 = "bla bla | let s2 = "bla bla |
| 13 | bli bli \ | bli bli \ |
| 14 | blo" | blo" |
| 15 | ||
| 16 | let s3 = "\ | let s3 = "\ |
| 17 | " | " |
| 18 | ||
| 19 | let s4 = " \ | let s4 = " \ |
| 20 | " | " |
| 21 | ||
| 22 | let s5 = " \ | let s5 = " \ |
| 23 | \ | \ |
| 24 | " | " |
| 25 | ||
| 26 | let s6 = " | let s6 = " |
| 27 | " | " |
| 28 | ||
| 29 | let s7 = " | let s7 = " |
| 30 | " | " |
| 31 | ||
| 32 | let c1 = ' | let c1 = ' |
| 33 | ' | ···········' |
| 34 | ||
| 35 | let x1 = f x ' | let x1 = f x ' |
| 36 | '·y | ···············'·y |
| 37 | z | z |
| 38 | ||
| 39 | let zz = "\ | let zz = "\ |
| 40 | ||
| 41 | s \ | s \ |
| 42 | \ | \ |
| 43 | " | " |
| Expected | Ocp-indent output | |
|---|---|---|
| 0 | let () = | let () = |
| 1 | foo.bar <- | foo.bar <- |
| 2 | f x | f x |
| 3 | y z | y z |
| 4 | ||
| 5 | let should_check_can_sell_and_marking regulatory_regime = | let should_check_can_sell_and_marking regulatory_regime = |
| 6 | match z with | match z with |
| 7 | | `foo | | `foo |
| 8 | -> some_function | -> some_function |
| 9 | argument | argument |
| 10 | (* The above typically occurs in a multi-pattern match clause, so the clause | (* The above typically occurs in a multi-pattern match clause, so the clause |
| 11 | expression is on a line by itself. This is the more typical way a long | expression is on a line by itself. This is the more typical way a long |
| 12 | single-pattern match clause would be written: *) | single-pattern match clause would be written: *) |
| 13 | let should_check_can_sell_and_marking regulatory_regime = | let should_check_can_sell_and_marking regulatory_regime = |
| 14 | match z with | match z with |
| 15 | | `foo -> | | `foo -> |
| 16 | some_function | some_function |
| 17 | argument | argument |
| 18 | ||
| 19 | let f = fun x -> | let f = fun x -> |
| 20 | ghi | ghi |
| 21 | x | x |
| 22 | ||
| 23 | (* common *) | (* common *) |
| 24 | let x = | let x = |
| 25 | try x with | try x with |
| 26 | | a -> b | | a -> b |
| 27 | | c -> d | | c -> d |
| 28 | let x = try x with | let x = try x with |
| 29 | | a -> b | | a -> b |
| 30 | | c -> d | | c -> d |
| 31 | let x = | let x = |
| 32 | try x | try x |
| 33 | with | with |
| 34 | | a -> b | | a -> b |
| 35 | | c -> d | | c -> d |
| 36 | ||
| 37 | let z = | let z = |
| 38 | some_function | some_function |
| 39 | argument | argument |
| 40 | ||
| 41 | ||
| 42 | ||
| 43 | let () = | let () = |
| 44 | f a b ~c:c | f a b ~c:c |
| 45 | d | d |
| 46 | ||
| 47 | let () = | let () = |
| 48 | f a b ~c:1. | f a b ~c:1. |
| 49 | d | d |
| 50 | ||
| 51 | let () = | let () = |
| 52 | My_module.f a b ~c:c | My_module.f a b ~c:c |
| 53 | d | d |
| 54 | ||
| 55 | (* This last case is where Tuareg is inconsistent with the others. *) | (* This last case is where Tuareg is inconsistent with the others. *) |
| 56 | let () = | let () = |
| 57 | My_module.f a b ~c:1. | My_module.f a b ~c:1. |
| 58 | d | d |
| 59 | ||
| 60 | ||
| 61 | ||
| 62 | let () = | let () = |
| 63 | messages := | messages := |
| 64 | Message_store.create (Session_id.of_string "") | Message_store.create (Session_id.of_string "") |
| 65 | (* Tuareg indents these lines too far to the left. *) | (* Tuareg indents these lines too far to the left. *) |
| 66 | "herd-retransmitter" | "herd-retransmitter" |
| 67 | Message_store.Message_size.Byte | Message_store.Message_size.Byte |
| 68 | ||
| 69 | ||
| 70 | ||
| 71 | let () = | let () = |
| 72 | raise (Bug ("foo" | raise (Bug ("foo" |
| 73 | (* In this and similar cases, we want the subsequent lines to | (* In this and similar cases, we want the subsequent lines to |
| 74 | align with the first expression. *) | align with the first expression. *) |
| 75 | ^ "bar")); | ^ "bar")); |
| 76 | raise (Bug ("foo" ^ "quux" | raise (Bug ("foo" ^ "quux" |
| 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 | ||
| 83 | (* Except in specific cases, we want the argument indented relative to the | (* Except in specific cases, we want the argument indented relative to the |
| 84 | function being called. (Exceptions include "fun" arguments where the line | function being called. (Exceptions include "fun" arguments where the line |
| 85 | ends with "->" and subsequent lines beginning with operators, like above.) *) | ends with "->" and subsequent lines beginning with operators, like above.) *) |
| 86 | let () = | let () = |
| 87 | Some (Message_store.create s | Some (Message_store.create s |
| 88 | "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte) | "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte) |
| 89 | ||
| 90 | ||
| 91 | ||
| 92 | (* 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 |
| 93 | left margin in a few special cases: *) | left margin in a few special cases: *) |
| 94 | let _ = | let _ = |
| 95 | foo (bar (fun x -> (* special: "fun _ ->" at EOL *) | foo (bar (fun x -> (* special: "fun _ ->" at EOL *) |
| 96 | baz)) (* assume no more arguments to "bar" *) | baz)) (* assume no more arguments to "bar" *) |
| 97 | let _ = | let _ = |
| 98 | foo | foo |
| 99 | ~a_long_field_name:(check (fun bar -> | ~a_long_field_name:(check (fun bar -> |
| 100 | baz)) | baz)) |
| 101 | let _ = | let _ = |
| 102 | foo ~a_long_field_name:(check (fun bar -> | foo ~a_long_field_name:(check (fun bar -> |
| 103 | baz)) | baz)) |
| 104 | let _ = | let _ = |
| 105 | foo (bar (quux (fnord (fun x -> (* any depth *) | foo (bar (quux (fnord (fun x -> (* any depth *) |
| 106 | baz)))) | baz)))) |
| 107 | ||
| 108 | (* We also wanted to tweak the operator indentation, making operators like <= | (* We also wanted to tweak the operator indentation, making operators like <= |
| 109 | not special cases in contexts like this: *) | not special cases in contexts like this: *) |
| 110 | let _ = | let _ = |
| 111 | assert (foo (bar + baz | assert (foo (bar + baz |
| 112 | <= quux)) (* lined up under left argument to op, | <= quux)) (* lined up under left argument to op, |
| 113 | sim. to ^ above *) | sim. to ^ above *) |
| 114 | (* Sim. indentation of if conditions: *) | (* Sim. indentation of if conditions: *) |
| 115 | let _ = | let _ = |
| 116 | if (a | if (a |
| 117 | <= b) | <= b) |
| 118 | then () | then () |
| 119 | let _ = | let _ = |
| 120 | (* Comparisons are different than conditionals; we don't regard them as | (* Comparisons are different than conditionals; we don't regard them as |
| 121 | conceptually part of the [if] expression. *) | conceptually part of the [if] expression. *) |
| 122 | if a | if a |
| 123 | <= b | <= b |
| 124 | then () | then () |
| 125 | let _ = | let _ = |
| 126 | (* We regard the outermost condition terms as conceptually part of the [if] | (* We regard the outermost condition terms as conceptually part of the [if] |
| 127 | expression and indent accordingly. Whether [&&] or [||], conditionals | expression and indent accordingly. Whether [&&] or [||], conditionals |
| 128 | effectively state lists of conditions for [then]. *) | effectively state lists of conditions for [then]. *) |
| 129 | if Edge_adjustment.is_zero arb.cfg.extra_edge | if Edge_adjustment.is_zero arb.cfg.extra_edge |
| 130 | && 0. = sys.plugs.edge_backoff | && 0. = sys.plugs.edge_backoff |
| 131 | && 0. = zero_acvol_edge_backoff | && 0. = zero_acvol_edge_backoff |
| 132 | then 0. | then 0. |
| 133 | else 1. | else 1. |
| 134 | let _ = | let _ = |
| 135 | if | if |
| 136 | Edge_adjustment.is_zero arb.cfg.extra_edge | Edge_adjustment.is_zero arb.cfg.extra_edge |
| 137 | && 0. = sys.plugs.edge_backoff | && 0. = sys.plugs.edge_backoff |
| 138 | && 0. = zero_acvol_edge_backoff | && 0. = zero_acvol_edge_backoff |
| 139 | then 0. | then 0. |
| 140 | else 1. | else 1. |
| 141 | let _ = | let _ = |
| 142 | let entries = List.filter (Lazy.force transferstati) ~f:(fun ts -> | let entries = List.filter (Lazy.force transferstati) ~f:(fun ts -> |
| 143 | Pcre.pmatch ~pat ts.RQ.description | Pcre.pmatch ~pat ts.RQ.description |
| 144 | ) in | ) in |
| 145 | x | x |
| 146 | ||
| 147 | (* combination of operator at BOL and -> at EOL: *) | (* combination of operator at BOL and -> at EOL: *) |
| 148 | let _ = | let _ = |
| 149 | Shell.ssh_lines x | Shell.ssh_lines x |
| 150 | |! List.map ~f:(f (g (fun x -> | |! List.map ~f:(f (g (fun x -> |
| 151 | ·······let·name,·path·=·String.lsplit2_exn·~on:'|'·x·in | ····let·name,·path·=·String.lsplit2_exn·~on:'|'·x·in |
| 152 | ·······String.strip·name,·String.strip·path))) | ····String.strip·name,·String.strip·path))) |
| 153 | ||
| 154 | (* open paren ending line like begin *) | (* open paren ending line like begin *) |
| 155 | let _ = | let _ = |
| 156 | if a (p ^/ "s") [ e ] = Ok () then `S ( | if a (p ^/ "s") [ e ] = Ok () then `S ( |
| 157 | let label count = | let label count = |
| 158 | sprintf "%d s" c ^ if c = 1 then ":" else "s" | sprintf "%d s" c ^ if c = 1 then ":" else "s" |
| 159 | in | in |
| 160 | x | x |
| 161 | ) | ) |
| Expected | Ocp-indent output | |
|---|---|---|
| 0 | let f = function | let f = function |
| 1 | | zoo -> begin | | zoo -> begin |
| 2 | foo; | foo; |
| 3 | bar; | bar; |
| 4 | end | end |
| 5 | ;; | ;; |
| 6 | let g = function | let g = function |
| 7 | | zoo -> ( | | zoo -> ( |
| 8 | foo; | foo; |
| 9 | bar; | bar; |
| 10 | ) | ) |
| 11 | ;; | ;; |
| 12 | let () = | let () = |
| 13 | begin match foo with | begin match foo with |
| 14 | ········|·Bar·->·snoo | ··|·Bar·->·snoo |
| 15 | end | end |
| 16 | ;; | ;; |
| Expected | Ocp-indent output | |
|---|---|---|
| 0 | (* preferred list style *) | (* preferred list style *) |
| 1 | let z = | let z = |
| 2 | f | f |
| 3 | [ y | [ y |
| 4 | ; foo ~f:(fun () -> | ; foo ~f:(fun () -> |
| 5 | arg) | arg) |
| 6 | ] | ] |
| 7 | ;; | ;; |
| 8 | let z = | let z = |
| 9 | f | f |
| 10 | [ y | [ y |
| 11 | ; foo ~f:(fun () -> | ; foo ~f:(fun () -> |
| 12 | arg | arg |
| 13 | ) | ) |
| 14 | ] | ] |
| 15 | ;; | ;; |
| 16 | ||
| 17 | (* legacy list style *) | (* legacy list style *) |
| 18 | let _ = | let _ = |
| 19 | [ f (fun x -> | [ f (fun x -> |
| 20 | x); | x); |
| 21 | f (fun x -> | f (fun x -> |
| 22 | x); | x); |
| 23 | f (fun x -> | f (fun x -> |
| 24 | x); | x); |
| 25 | ] | ] |
| 26 | let _ = | let _ = |
| 27 | [ f (fun x -> | [ f (fun x -> |
| 28 | x | x |
| 29 | ); | ); |
| 30 | f (fun x -> | f (fun x -> |
| 31 | x | x |
| 32 | ); | ); |
| 33 | f (fun x -> | f (fun x -> |
| 34 | x | x |
| 35 | ); | ); |
| 36 | ] | ] |
| 37 | ;; | ;; |
| 38 | let _ = | let _ = |
| 39 | [f (fun x -> | [f (fun x -> |
| 40 | x | x |
| 41 | ); | ); |
| 42 | f (fun x -> | f (fun x -> |
| 43 | x | x |
| 44 | ); | ); |
| 45 | f (fun x -> | f (fun x -> |
| 46 | x | x |
| 47 | ); | ); |
| 48 | ] | ] |
| 49 | ;; | ;; |
| 50 | ||
| 51 | let _ = | let _ = |
| 52 | x | x |
| 53 | >>= fun x -> | >>= fun x -> |
| 54 | (try x with _ -> ()) | (try x with _ -> ()) |
| 55 | >>= fun x -> | >>= fun x -> |
| 56 | try x with _ -> () | try x with _ -> () |
| 57 | >>= fun x -> | >>= fun x -> |
| 58 | x | x |
| 59 | ;; | ;; |
| 60 | ||
| 61 | let () = | let () = |
| 62 | expr | expr |
| 63 | >>| function | >>| function |
| 64 | | x -> 3 | | x -> 3 |
| 65 | | y -> 4 | | y -> 4 |
| 66 | ;; | ;; |
| 67 | ||
| 68 | let () = | let () = |
| 69 | expr | expr |
| 70 | >>| fun z -> match z with | >>| fun z -> match z with |
| 71 | ···············|·x·->·3 | ··|·x·->·3 |
| 72 | ···············|·y·->·4 | ··|·y·->·4 |
| 73 | ;; | ;; |
| 74 | ||
| 75 | let () = | let () = |
| 76 | expr | expr |
| 77 | >>| fun z -> function | >>| fun z -> function |
| 78 | | x -> 3 | | x -> 3 |
| 79 | | y -> 4 | | y -> 4 |
| 80 | ;; | ;; |
| 81 | ||
| 82 | let () = | let () = |
| 83 | my_func () >>= function | my_func () >>= function |
| 84 | | A -> 0 | | A -> 0 |
| 85 | | B -> 0 | | B -> 0 |
| 86 | ;; | ;; |
| 87 | ||
| 88 | let () = | let () = |
| 89 | my_func () >>= (function | my_func () >>= (function |
| 90 | | A -> 0 | | A -> 0 |
| 91 | | B -> 0) | | B -> 0) |
| 92 | ;; | ;; |
| 93 | ||
| 94 | let () = | let () = |
| 95 | expr | expr |
| 96 | >>| function | >>| function |
| 97 | | x -> 3 | | x -> 3 |
| 98 | | y -> 4 | | y -> 4 |
| 99 | ;; | ;; |
| 100 | ||
| 101 | let () = | let () = |
| 102 | expr | expr |
| 103 | >>| (function | >>| (function |
| 104 | | x -> 3 | | x -> 3 |
| 105 | | y -> 4) | | y -> 4) |
| 106 | ;; | ;; |
| 107 | ||
| 108 | ||
| 109 | ||
| 110 | let f = | let f = |
| 111 | f >>= m (fun f -> | f >>= m (fun f -> |
| 112 | fun x -> | fun x -> |
| 113 | y); | y); |
| 114 | z | z |
| 115 | ;; | ;; |
| 116 | ||
| 117 | let f = | let f = |
| 118 | f | f |
| 119 | |> m (fun f -> | |> m (fun f -> |
| 120 | fun x -> | fun x -> |
| 121 | y | y |
| 122 | ); | ); |
| 123 | z | z |
| 124 | ;; | ;; |
| 125 | let f = | let f = |
| 126 | f | f |
| 127 | |> m (fun f -> | |> m (fun f -> |
| 128 | fun x -> | fun x -> |
| 129 | y); | y); |
| 130 | z | z |
| 131 | ;; | ;; |
| 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 | (* To me, this looks fine as it is. The rule seems fine as "indent arguments by | (* To me, this looks fine as it is. The rule seems fine as "indent arguments by |
| 13 | 2". To illustrate, with a case where the functor name is longer: *) | 2". To illustrate, with a case where the functor name is longer: *) |
| 14 | module M = | module M = |
| 15 | Functor (G) | Functor (G) |
| 16 | (H) | (H) |
| 17 | (I) | (I) |
| 18 | ||
| 19 | ||
| 20 | ||
| 21 | include Foo (struct | include Foo (struct |
| 22 | let x | let x |
| 23 | end) (struct | end) (struct |
| 24 | let y | let y |
| 25 | end) | end) |
| 26 | ||
| 27 | include | include |
| 28 | Foo (struct | Foo (struct |
| 29 | ······let·x | ····let·x |
| 30 | ····end)·(struct | ··end)·(struct |
| 31 | ······let·y | ····let·y |
| 32 | ····end) | ··end) |
| 33 | ||
| 34 | include | include |
| 35 | Foo | Foo |
| 36 | (struct | (struct |
| 37 | let x | let x |
| 38 | end) (struct | end) (struct |
| 39 | ······let·y | ····let·y |
| 40 | ····end) | ··end) |
| 41 | ||
| 42 | include Persistent.Make | include Persistent.Make |
| 43 | ··(struct·let·version·=·1·end) | ····(struct·let·version·=·1·end) |
| 44 | ··(Stable.Cr_soons_or_pending.V1) | ····(Stable.Cr_soons_or_pending.V1) |
| 45 | ||
| 46 | include Persistent.Make | include Persistent.Make |
| 47 | ··(struct | ····(struct |
| 48 | ····let·version·=·1 | ······let·version·=·1 |
| 49 | ··end) | ····end) |
| 50 | ··(Stable.Cr_soons_or_pending.V1) | ····(Stable.Cr_soons_or_pending.V1) |
| 51 | ||
| 52 | include | include |
| 53 | Persistent.Make | Persistent.Make |
| 54 | (struct let version = 1 end) | (struct let version = 1 end) |
| 55 | (Stable.Cr_soons_or_pending.V1) | (Stable.Cr_soons_or_pending.V1) |
| 56 | ||
| 57 | include | include |
| 58 | Persistent.Make | Persistent.Make |
| 59 | (struct | (struct |
| 60 | let version = 1 | let version = 1 |
| 61 | end) | end) |
| 62 | (Stable.Cr_soons_or_pending.V1) | (Stable.Cr_soons_or_pending.V1) |
| 63 | ||
| 64 | module M = | module M = |
| 65 | Foo (struct | Foo (struct |
| 66 | ······let·x | ····let·x |
| 67 | ····end)·(struct | ··end)·(struct |
| 68 | ······let·y | ····let·y |
| 69 | ····end) | ··end) |
| 70 | ||
| 71 | module M : S = | module M : S = |
| 72 | Make (M) | Make (M) |
| 73 | module M : S with type t := int = | module M : S with type t := int = |
| 74 | Make (M) | Make (M) |
| 75 | ||
| 76 | ||
| 77 | ||
| 78 | module Simple_command(Arg:sig | module Simple_command(Arg:sig |
| 79 | end) = struct end | end) = struct end |
| 80 | ||
| 81 | module Simple_command(Arg : sig | module Simple_command(Arg : sig |
| 82 | end) = struct end | end) = struct end |
| 83 | ||
| 84 | module Simple_command (Arg:sig | module Simple_command (Arg:sig |
| 85 | end) = struct end | end) = struct end |
| 86 | ||
| 87 | module Simple_command (Arg : sig | module Simple_command (Arg : sig |
| 88 | end) = struct end | end) = struct end |
| 89 | ||
| 90 | module Simple_command | module Simple_command |
| 91 | ··(Arg·:·sig | ····(Arg·:·sig |
| 92 | ···end)·=·struct·end | ·····end)·=·struct·end |
| Expected | Ocp-indent output | |
|---|---|---|
| 0 | let f = function | let f = function |
| 1 | | _ -> 0 | | _ -> 0 |
| 2 | ;; | ;; |
| 3 | ||
| 4 | let f x = match x with | let f x = match x with |
| 5 | ··········|·_·->·0 | ··|·_·->·0 |
| 6 | ;; | ;; |
| 7 | ||
| 8 | let f = | let f = |
| 9 | function | function |
| 10 | | _ -> 0 | | _ -> 0 |
| 11 | ;; | ;; |
| 12 | ||
| 13 | let f x = | let f x = |
| 14 | match x with | match x with |
| 15 | | _ -> 0 | | _ -> 0 |
| 16 | ;; | ;; |
| 17 | ||
| 18 | let f x = | let f x = |
| 19 | begin match x with | begin match x with |
| 20 | ········|·_·->·0 | ··|·_·->·0 |
| 21 | end | end |
| 22 | ;; | ;; |
| 23 | ||
| 24 | let check_price t = function | let check_price t = function |
| 25 | | { Exec. | | { Exec. |
| 26 | trade_at_settlement = (None | Some false); | trade_at_settlement = (None | Some false); |
| 27 | } -> () | } -> () |
| 28 | ||
| 29 | let check_price t = function | let check_price t = function |
| 30 | | simpler -> () | | simpler -> () |
| 31 | | other -> () | | other -> () |
| 32 | ||
| 33 | (* Sometimes we like to write big alternations like this, in which case the | (* Sometimes we like to write big alternations like this, in which case the |
| 34 | comment should typically align with the following clause. *) | comment should typically align with the following clause. *) |
| 35 | let 0 = | let 0 = |
| 36 | match x with | match x with |
| 37 | | A | | A |
| 38 | (* a *) | (* a *) |
| 39 | -> a | -> a |
| 40 | let 0 = | let 0 = |
| 41 | match x with | match x with |
| 42 | A | A |
| 43 | (* a *) | (* a *) |
| 44 | -> a | -> a |
| 45 | ||
| 46 | let _ = | let _ = |
| 47 | a | a |
| 48 | || match a with | || match a with |
| 49 | ·····|·a·->·true | ··|·a·->·true |
| 50 | ·····|·b·->·false | ··|·b·->·false |
| 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 | let _ = | let _ = |
| 52 | { foo with | { foo with |
| 53 | Bar. | Bar. |
| 54 | field1 = value1 | field1 = value1 |
| 55 | ; field2 = value2 | ; field2 = value2 |
| 56 | } | } |
| 57 | ;; | ;; |
| 58 | let _ = | let _ = |
| 59 | { foo | { foo |
| 60 | with Bar. | with Bar. |
| 61 | ····field1·=·value1 | ······field1·=·value1 |
| 62 | ··;·field2·=·value2 | ····;·field2·=·value2 |
| 63 | } | } |
| 64 | ;; | ;; |
| 65 | ||
| 66 | (* multicomponent record module pathname *) | (* multicomponent record module pathname *) |
| 67 | let _ = | let _ = |
| 68 | { A.B. | { A.B. |
| 69 | a = b | a = b |
| 70 | ; c = d | ; c = d |
| 71 | } | } |
| 72 | ;; | ;; |
| 73 | ||
| 74 | type t = | type t = |
| 75 | { a | { a |
| 76 | : something_lengthy list list | : something_lengthy list list |
| 77 | [@default String.Map.empty] | [@default String.Map.empty] |
| 78 | } | } |
| 79 | ||
| 80 | type t = | type t = |
| 81 | { a | { a |
| 82 | : Something_lengthy.t list list | : Something_lengthy.t list list |
| 83 | [@default String.Map.empty] | [@default String.Map.empty] |
| 84 | } | } |
| 85 | ||
| 86 | type t = | type t = |
| 87 | { a | { a |
| 88 | : something_lengthy list | : something_lengthy list |
| 89 | list | list |
| 90 | } | } |
| 91 | ||
| 92 | type t = | type t = |
| 93 | { a | { a |
| 94 | : Something_lengthy.t list | : Something_lengthy.t list |
| 95 | list | list |
| 96 | } | } |
| 97 | ||
| 98 | type t = | type t = |
| 99 | { a | { a |
| 100 | : Something_lengthy.t | : Something_lengthy.t |
| 101 | list | list |
| 102 | } | } |
| Expected | Ocp-indent output | |
|---|---|---|
| 0 | (* s *) | (* s *) |
| 1 | ||
| 2 | let _ = | let _ = |
| 3 | [%raise_structural_sexp | [%raise_structural_sexp |
| 4 | "feature's tip is already an ancestor of new base" | "feature's tip is already an ancestor of new base" |
| 5 | ····{·feature_tip·=·(old_tip·:·Rev.t) | ······{·feature_tip·=·(old_tip·:·Rev.t) |
| 6 | ····;·new_base····=·(new_base·:·Rev.t) | ······;·new_base····=·(new_base·:·Rev.t) |
| 7 | ····}] | ······}] |
| 8 | ||
| 9 | let _ = | let _ = |
| 10 | [%raise_structural_sexp "feature's tip is already an ancestor of new base" | [%raise_structural_sexp "feature's tip is already an ancestor of new base" |
| 11 | ····{·feature_tip·=·(old_tip·:·Rev.t) | ····························{·feature_tip·=·(old_tip·:·Rev.t) |
| 12 | ····;·new_base····=·(new_base·:·Rev.t) | ····························;·new_base····=·(new_base·:·Rev.t) |
| 13 | ····} | ····························} |
| 14 | ] | ] |
| 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 | val instances | val instances |
| 44 | : unit | : unit |
| 45 | -> ( Config.Network.t | -> ( Config.Network.t |
| 46 | ·······->·(App.t·*·Config.instance·*·Config.app)·list | ··········->·(App.t·*·Config.instance·*·Config.app)·list |
| 47 | ·······->·verbose:bool | ··········->·verbose:bool |
| 48 | ·······->·'m | ··········->·'m |
| 49 | , 'm | , 'm |
| 50 | ) Command.Spec.t | ) Command.Spec.t |
| 51 | ||
| 52 | val instances | val instances |
| 53 | : unit | : unit |
| 54 | -> ( Config.Network.t | -> ( Config.Network.t |
| 55 | ·······->·(App.t·*·Config.instance·*·Config.app)·list | ··········->·(App.t·*·Config.instance·*·Config.app)·list |
| 56 | ·······->·verbose:bool·->·'m | ··········->·verbose:bool·->·'m |
| 57 | , 'm | , 'm |
| 58 | ) Command.Spec.t | ) Command.Spec.t |
| 59 | ||
| 60 | (* presumed analog with stars *) | (* presumed analog with stars *) |
| 61 | val instances : | val instances : |
| 62 | unit | unit |
| 63 | * ( Config.Network.t | * ( Config.Network.t |
| 64 | ······*·(App.t·*·Config.instance·*·Config.app)·list | ········*·(App.t·*·Config.instance·*·Config.app)·list |
| 65 | ······*·bool | ········*·bool |
| 66 | ······*·'m | ········*·'m |
| 67 | , 'm | , 'm |
| 68 | ) Command.Spec.t | ) Command.Spec.t |
| Expected | Ocp-indent output | |
|---|---|---|
| 0 | let f x = | let f x = |
| 1 | stop | stop |
| 2 | (* We don't do this as a matter of style, but the indentation reveals a common | (* We don't do this as a matter of style, but the indentation reveals a common |
| 3 | mistake. *) | mistake. *) |
| 4 | >>> fun () -> don't_wait_for (close fd); | >>> fun () -> don't_wait_for (close fd); |
| 5 | ················bind·fd | ··bind·fd |
| 6 | ||
| 7 | let f x = | let f x = |
| 8 | stop | stop |
| 9 | (* This is what was intended, which is indented correctly, although it's bad | (* This is what was intended, which is indented correctly, although it's bad |
| 10 | style on my part. *) | style on my part. *) |
| 11 | >>> (fun () -> don't_wait_for (close fd)); | >>> (fun () -> don't_wait_for (close fd)); |
| 12 | bind | bind |
| Expected | Ocp-indent output | |
|---|---|---|
| 0 | let f x = | let f x = |
| 1 | (fun x -> x [ (fun () -> 3) ; | (fun x -> x [ (fun () -> 3) ; |
| 2 | (fun () -> 4) ]) | (fun () -> 4) ]) |
| 3 | ||
| 4 | let f x = (fun x -> x [ (fun () -> 3) ; | let f x = (fun x -> x [ (fun () -> 3) ; |
| 5 | (fun () -> 4) ]) | (fun () -> 4) ]) |
| 6 | ||
| 7 | let f x = | let f x = |
| 8 | x [ (fun () -> 3) ; | x [ (fun () -> 3) ; |
| 9 | (fun () -> 4) ] | (fun () -> 4) ] |
| 10 | ||
| 11 | let f x = | let f x = |
| 12 | [ (fun () -> 3) ; | [ (fun () -> 3) ; |
| 13 | (fun () -> 4) ] | (fun () -> 4) ] |
| 14 | ||
| 15 | let f x = | let f x = |
| 16 | (fun x -> x [ (fun () -> | (fun x -> x [ (fun () -> |
| 17 | ···················3)·; | ·······3)·; |
| 18 | ················(fun·()·->·4)·]) | ·······(fun·()·->·4)·]) |
| 19 | ||
| 20 | let f x = (fun x -> x [ (fun () -> | let f x = (fun x -> x [ (fun () -> |
| 21 | ···························3)·; | ····3)·; |
| 22 | ························(fun·()·->·4)·]) | ····(fun·()·->·4)·]) |
| 23 | ||
| 24 | let f x = | let f x = |
| 25 | x [ (fun () -> | x [ (fun () -> |
| 26 | ·········3)·; | ······3)·; |
| 27 | (fun () -> 4) ] | (fun () -> 4) ] |
| 28 | ||
| 29 | let f x = | let f x = |
| 30 | [ (fun () -> | [ (fun () -> |
| 31 | ·······3)·; | ········3)·; |
| 32 | (fun () -> 4) ] | (fun () -> 4) ] |
| Expected | Ocp-indent output | |
|---|---|---|
| '$line' | ' - echo -n ''"$l1"' | '
- echo -n ''"$l2"' | '
- echo '
| '$line' | ' - echo -n '' - echo -n ' | '"$l2"' | '
- echo '
All tests pass: no currently known bugs.
" >>failing.html - fi - cat <