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

[Formatter] Different infix operators might need to be printed differently #218

Closed
chenglou opened this issue Mar 26, 2016 · 6 comments
Closed

Comments

@chenglou
Copy link
Member

I'm ok with this:

let a = 1 + 2 + 
  3 + 4;

As it is currently, but for stuff like pipe it's probably better like this:

let a =
  bla1 1
  |> bla2 2
  |> bla3 3
@jordwalke
Copy link
Member

Does the first example actually happen?

@chenglou
Copy link
Member Author

That's how it's currently formatted (string for example).
I'm ok with nothing but the second form. I can make that change if we switch to it.

@jordwalke
Copy link
Member

We might actually just left align all infix operators by default (but that would be suboptimal for monadic infix operators which most people want to be written on the Right hand side).

@sztosz
Copy link

sztosz commented Jul 29, 2017

With pipe a long piece of code like this

let all_resources =
  ResourceMap.(
    empty
    |> add Resource1(module Resource1: Resource)
    |> add Resource1(module Resource2: Resource)
    |> add Resource3(module Resource3: Resource)
  )

get's converted by rfmt into this:

let all_resources =
  ResourceMap.(
    empty |> add Resource1 ((module Resource1): (module Resource)) |>
    add Resource1 ((module Resource2): (module Resource)) |>
    add Resource3 ((module Resource3): (module Resource))
  );

I think it's much more readable if the pipe stays at the beginning of the line it's piping to, rather than the end.

@hcarty
Copy link
Contributor

hcarty commented Jul 29, 2017

There's a PR working on this: #1259

@chenglou
Copy link
Member Author

This now converts exactly correctly.

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

No branches or pull requests

4 participants