Skip to content

Indentation of fun arguments is inconsistent #2397

@Julow

Description

@Julow

Function arguments are indented in different ways depending on context:

let _ =
 fun (module Store : Irmin.Generic_key.S with type repo = repo)
     (module Store : Irmin.Generic_key.S with type repo = repo) ->
  body

let _ =
  f
    (fun
      (module Store : Irmin.Generic_key.S with type repo = repo)
      (module Store : Irmin.Generic_key.S with type repo = repo)
      -> body )

let f (module Store : Irmin.Generic_key.S with type repo = repo)
    (module Store : Irmin.Generic_key.S with type repo = repo) =
  body

This example contains a regression: (red is 0.25.1)

@@ -8,7 +8,7 @@ let _ =
     (fun
       (module Store : Irmin.Generic_key.S with type repo = repo)
       (module Store : Irmin.Generic_key.S with type repo = repo)
-    -> body )
+      -> body )
 
 let f (module Store : Irmin.Generic_key.S with type repo = repo)
     (module Store : Irmin.Generic_key.S with type repo = repo) =

I propose the following formatting:

  • Arguments are indented 2 more than the body.
    Helps to distinguish where the body starts.
  • The arrow/equal is on the right of the last argument.
  • Body of fun passed as argument is aligned with the keyword.
    This applies to fun wrapped in parentheses.
  • Dock the fun keyword when it's the body of a let.
    Gets rid of the 1-indented fun and is more consistent with the sugared form.
let _ = fun
    (module Store : Irmin.Generic_key.S with type repo = repo)
    (module Store : Irmin.Generic_key.S with type repo = repo) ->
  body

let _ =
  f
    (fun
       (module Store : Irmin.Generic_key.S with type repo = repo)
       (module Store : Irmin.Generic_key.S with type repo = repo) ->
     body )

let f
    (module Store : Irmin.Generic_key.S with type repo = repo)
    (module Store : Irmin.Generic_key.S with type repo = repo) =
  body

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions