Skip to content

Indent further args of anonymous functions#1440

Merged
gpetiot merged 2 commits intoocaml-ppx:masterfrom
gpetiot:indent-anon-fun-args
Aug 6, 2020
Merged

Indent further args of anonymous functions#1440
gpetiot merged 2 commits intoocaml-ppx:masterfrom
gpetiot:indent-anon-fun-args

Conversation

@gpetiot
Copy link
Copy Markdown
Collaborator

@gpetiot gpetiot commented Aug 6, 2020

@jberdine #1343 changed the indentation of arguments like this:

     let last_loc =
       List.fold l ~init:loc
         ~f:(fun (acc : Location.t)
-                ({attr_name= {loc; _}; attr_payload= payload; _} :
-                  Parsetree.attribute)
-                ->
+           ({attr_name= {loc; _}; attr_payload= payload; _} :
+             Parsetree.attribute)
+           ->

I didn't pay attention to it when #1343 was merged, what do you think of the new indentation suggested in this PR?

Here is the diff with test_branch:

diff --git a/lib/Source.ml b/lib/Source.ml
index 77ea664..ed4d28e 100644
--- a/lib/Source.ml
+++ b/lib/Source.ml
@@ -153,8 +153,9 @@ let extend_loc_to_include_attributes t (loc : Location.t) (l : Parsetree.attribu
       List.fold
         l
         ~init:loc
-        ~f:(fun (acc : Location.t)
-           ({ attr_name = { loc; _ }; attr_payload = payload; _ } : Parsetree.attribute)
+        ~f:(fun
+             (acc : Location.t)
+             ({ attr_name = { loc; _ }; attr_payload = payload; _ } : Parsetree.attribute)
            ->
           if loc.loc_ghost
           then acc
diff --git a/infer/src/integration/Help.ml b/infer/src/integration/Help.ml
index e5f974e17..9af75d105 100644
--- a/infer/src/integration/Help.ml
+++ b/infer/src/integration/Help.ml
@@ -153,18 +153,19 @@ let list_issue_types () =
   L.result "@[<v>";
   IssueType.all_issues ()
   |> List.iter
-       ~f:(fun ({ IssueType.unique_id
-                ; checker
-                ; visibility
-                ; user_documentation =
-                    _
-                    (* do not show this as this can be a big multi-line string and not tool-friendly *)
-                ; default_severity
-                ; enabled
-                ; hum
-                ; doc_url
-                ; linters_def_file
-                }[@warning "+9"])
+       ~f:(fun
+            ({ IssueType.unique_id
+             ; checker
+             ; visibility
+             ; user_documentation =
+                 _
+                 (* do not show this as this can be a big multi-line string and not tool-friendly *)
+             ; default_severity
+             ; enabled
+             ; hum
+             ; doc_url
+             ; linters_def_file
+             }[@warning "+9"])
           ->
          L.result
            "%s:%s:%s:%s:%b:%s:%s:%s@;"
diff --git a/infer/src/nullsafe/eradicateChecks.ml b/infer/src/nullsafe/eradicateChecks.ml
index 34e2429c2..d592b1f06 100644
--- a/infer/src/nullsafe/eradicateChecks.ml
+++ b/infer/src/nullsafe/eradicateChecks.ml
@@ -681,13 +681,14 @@ let check_inheritance_rule_for_params
          L.result
            "%s:%s:%s:%s:%b:%s:%s:%s@;"
diff --git a/infer/src/nullsafe/eradicateChecks.ml b/infer/src/nullsafe/eradicat
eChecks.ml
index 34e2429c2..d592b1f06 100644
--- a/infer/src/nullsafe/eradicateChecks.ml
+++ b/infer/src/nullsafe/eradicateChecks.ml
@@ -681,13 +681,14 @@ let check_inheritance_rule_for_params
     (* Check the rule for each pair of base and overridden param *)
     List.iteri
       base_and_overridden_params
-      ~f:(fun index
-         ( AnnotatedSignature.
-             { param_annotated_type = { nullability = annotated_nullability_base } }
-         , AnnotatedSignature.
-             { mangled = overridden_param_name
-             ; param_annotated_type = { nullability = annotated_nullability_overridden }
-             } )
+      ~f:(fun
+           index
+           ( AnnotatedSignature.
+               { param_annotated_type = { nullability = annotated_nullability_base } }
+           , AnnotatedSignature.
+               { mangled = overridden_param_name
+               ; param_annotated_type = { nullability = annotated_nullability_overridden }
+               } )
          ->
         check_inheritance_rule_for_param
           analysis_data
diff --git a/infer/src/nullsafe/typeCheck.ml b/infer/src/nullsafe/typeCheck.ml
index 208798fd3..49ba5f82d 100644
--- a/infer/src/nullsafe/typeCheck.ml
+++ b/infer/src/nullsafe/typeCheck.ml
@@ -1336,8 +1336,9 @@ let clarify_ret_by_propagates_nullable
   let nullability_of_propagates_nullable_params =
     List.filter_map
       resolved_params
-      ~f:(fun EradicateChecks.
-                { is_formal_propagates_nullable; actual = _, inferred_nullability }
+      ~f:(fun
+           EradicateChecks.
+             { is_formal_propagates_nullable; actual = _, inferred_nullability }
          -> Option.some_if is_formal_propagates_nullable inferred_nullability)
   in
   match nullability_of_propagates_nullable_params with
diff --git a/compiler/lib/parse_bytecode.ml b/compiler/lib/parse_bytecode.ml
index 6e6a7fbeb..221c65864 100644
--- a/compiler/lib/parse_bytecode.ml
+++ b/compiler/lib/parse_bytecode.ml
@@ -150,10 +150,11 @@ end = struct
       let paths = read_paths ic @ includes in
       List.iter
         evl
-        ~f:(fun ({ ev_module
-                 ; ev_loc = { Location.loc_start = { Lexing.pos_fname; _ }; _ }
-                 ; _
-                 } as ev)
+        ~f:(fun
+             ({ ev_module
+              ; ev_loc = { Location.loc_start = { Lexing.pos_fname; _ }; _ }
+              ; _
+              } as ev)
            ->
           let unit =
             try Hashtbl.find units (ev_module, pos_fname) with
diff --git a/src/dune/build_system.ml b/src/dune/build_system.ml
index e9ef3c0d..b8eb50ec 100644
--- a/src/dune/build_system.ml
+++ b/src/dune/build_system.ml
@@ -761,8 +761,9 @@ end = struct
             List.fold_left
               (Appendable_list.to_list actions)
               ~init:(rules, Path.Set.empty)
-              ~f:(fun (rules, action_stamp_files)
-                 { Rules.Dir_rules.stamp; action; locks; context; loc; env }
+              ~f:(fun
+                   (rules, action_stamp_files)
+                   { Rules.Dir_rules.stamp; action; locks; context; loc; env }
                  ->
                 let path =
                   Path.Build.extend_basename
diff --git a/src/dune/install_rules.ml b/src/dune/install_rules.ml
index ec95fc95..60dd0a74 100644
--- a/src/dune/install_rules.ml
+++ b/src/dune/install_rules.ml
@@ -408,13 +408,14 @@ end = struct
               List.fold_left
                 entries
                 ~init:Lib_name.Map.empty
-                ~f:(fun acc
-                   { Dune_file.Deprecated_library_name.old_public_name =
-                       { public = old_public_name; _ }
-                   ; new_public_name = _, new_public_name
-                   ; loc
-                   ; _
-                   }
+                ~f:(fun
+                     acc
+                     { Dune_file.Deprecated_library_name.old_public_name =
+                         { public = old_public_name; _ }
+                     ; new_public_name = _, new_public_name
+                     ; loc
+                     ; _
+                     }
                    ->

Copy link
Copy Markdown
Collaborator

@emillon emillon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 that improves the diff on dune and irmin

@gpetiot gpetiot merged commit 9433331 into ocaml-ppx:master Aug 6, 2020
@gpetiot gpetiot deleted the indent-anon-fun-args branch August 6, 2020 14:45
emillon added a commit to emillon/opam-repository that referenced this pull request Aug 6, 2020
CHANGES:

#### Changes

  + Do not break inline elements such as `{i blah}` in docstrings (ocaml-ppx/ocamlformat#1346, @jberdine)

  + Distinguish hash-getter from hash-comparison infix operators. Operators of the form `#**#` or `#**.` where `**` can be 0 or more operator chars are considered getter operators and are not surrounded by spaces, as opposed to regular infix operators (ocaml-ppx/ocamlformat#1376, @gpetiot)

  + Type constraint on return type of functions is now always printed before the function body (ocaml-ppx/ocamlformat#1381, ocaml-ppx/ocamlformat#1397, @gpetiot)

#### Bug fixes

  + Restore previous functionality for pre-post extension points (ocaml-ppx/ocamlformat#1342, @jberdine)

  + Fix extra break before `function` body of a `fun` (ocaml-ppx/ocamlformat#1343, @jberdine)
    Indent further args of anonymous functions (ocaml-ppx/ocamlformat#1440, @gpetiot)

  + Do not clear the emacs `*compilation*` buffer on successful reformat (ocaml-ppx/ocamlformat#1350, @jberdine)

  + Fix disabling with attributes on OCaml < 4.08 (ocaml-ppx/ocamlformat#1322, @emillon)

  + Preserve unwrapped comments by not adding artificial breaks when `wrap-comments=false` and `ocp-indent-compat=true` are set to avoid interfering with ocp-indent indentation. (ocaml-ppx/ocamlformat#1352, @gpetiot)

  + Break long literal strings at the margin (ocaml-ppx/ocamlformat#1367, @gpetiot)

  + Break after a multiline argument in an argument list (ocaml-ppx/ocamlformat#1360, @gpetiot)

  + Remove unnecessary parens around object (ocaml-ppx/ocamlformat#1379, @gpetiot)

  + Fix placement of comments on constants (ocaml-ppx/ocamlformat#1383, @gpetiot)

  + Do not escape arguments of some Odoc tags (ocaml-ppx/ocamlformat#1391, 1408, @gpetiot, @Julow)
    The characters `[]{}` must not be escaped in the arguments of `@raise`, `@author`, `@version` and others.

  + Fix missing open line between multi-line let-binding with poly-typexpr (ocaml-ppx/ocamlformat#1372, @jberdine)

  + Remove trailing space after expression when followed by an attribute and break before attributes attached to multi-line phrases (ocaml-ppx/ocamlformat#1382, @gpetiot)

  + Do not add a space to minimal comments `(* *)`, `(** *)` and `(*$ *)` (ocaml-ppx/ocamlformat#1407, @gpetiot)

  + Fix attributes position in labelled arguments type (ocaml-ppx/ocamlformat#1434, @gpetiot)

  + Add missing parens around type annotation in anonymous function (ocaml-ppx/ocamlformat#1433, @gpetiot)

  + Fix alignment of 'then' keyword in parenthesised expression (ocaml-ppx/ocamlformat#1421, @gpetiot)

#### New features

  + Support quoted extensions (added in ocaml 4.11) (ocaml-ppx/ocamlformat#1405, @gpetiot)

  + Recognise eliom file extensions (ocaml-ppx/ocamlformat#1430, @jrochel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants