Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird Indent when using anonymous function with pipe operator #2385

Closed
dawee opened this issue Apr 16, 2019 · 2 comments
Closed

Weird Indent when using anonymous function with pipe operator #2385

dawee opened this issue Apr 16, 2019 · 2 comments
Labels
Printer things that have to do with turning an AST into Reason code

Comments

@dawee
Copy link

dawee commented Apr 16, 2019

refmt choose to end a processing function like List.filter at the same column where the function started. It makes sense, but everytime I'm using a pipe operator with anonymous functions I'm getting this kind of results:

let result =
  list
  |> List.filter(
       fun
       | `data => true
       | `error => false,
     )
  |> List.length;

It's bugging me a bit everytime I read it because it doesn't align well with the flow. Specially when you're in an editor like VSCode, it feels like the function is not at its place:

Screen Shot 2019-04-16 at 4 50 12 PM

Personally I would have expected this:

let result =
  list
  |> List.filter(
    fun
    | `data => true
    | `error => false,
  )
  |> List.length;

So that every line starts at a modulo of 2:

Screen Shot 2019-04-16 at 4 55 16 PM

@dawee
Copy link
Author

dawee commented Apr 17, 2019

@yawaramin proposed another approach:

let result = list
  |> List.filter(fun
    | `data => true
    | `error => false)
  |> List.length;

It also works for me because it fixes the alignment of always starting on a "modulo 2 column". Plus it seems to be fairly close to what ocamlformat would do.

@davesnx davesnx added the Printer things that have to do with turning an AST into Reason code label Nov 16, 2022
@anmonteiro
Copy link
Member

discussing this in #2675

@anmonteiro anmonteiro closed this as not planned Won't fix, can't repro, duplicate, stale Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Printer things that have to do with turning an AST into Reason code
Projects
None yet
Development

No branches or pull requests

3 participants