tweag / topiary

https://topiary.tweag.io/
MIT License
575 stars 29 forks source link

Not enough indentation on multi-line type of a function argument #727

Closed Niols closed 2 months ago

Niols commented 2 months ago

As of 1720fa963fdf65e9c767edbe02132ccab4078f5a, Topiary formats

let foo
  (bar : 
    int ->
    string ->
    unit
  )
  ~(baz : 
    int ->
    string ->
    unit
  )
=
  bar baz

into

let foo
    (bar : int ->
    string ->
    unit)
    ~(baz : int ->
    string ->
    unit)
  =
  bar baz

The closing of parenthesis is inconsistent with the recent changes of style. More importantly, the fact that the beginning of the type is dangling after the named argument is a bit weird, and the indentation of the types at the same level as the argument they apply to is off.

Note that Tuareg/ocp-indent go for:

let foo
    (bar :
       int ->
     string ->
     unit
    )
    ~(baz :
        int ->
      string ->
      unit
     )
  =
  bar baz

so it seems to be an unusual case anyways. Somehow, I do have it regularly in my code.