reason icon indicating copy to clipboard operation
reason copied to clipboard

refmt: keep new line characters when using infix operators

Open anisjonischkeit opened this issue 6 years ago • 1 comments

It is often more readable to have line breaks when using infix operators.

example 1

thing |> doFirstThing |> doSecondThing |> doThirdThing  |> doFourthThing;

// vs

thing
|> doFirstThing
|> doSecondThing
|> doThirdThing
|> doFourthThing;

example 2:

thing >>= doFirstThing >>= doSecondThing >>= doThirdThing >>= doFourthThing;

// vs

thing
>>= doFirstThing
>>= doSecondThing
>>= doThirdThing
>>= doFourthThing;

refmt currently forces you into the first example when there are less than 80 characters on the line. I'd like to allow both styles.

anisjonischkeit avatar Oct 10 '19 15:10 anisjonischkeit

Agreed! I think it makes sense to split into new lines when there are more than one operator and consider them a sequence.

Granted, this is a rather subjective subject.. 😄

E.g.

"hello" |> Foo.bar |> Foo.baz

would be:

"hello" 
|> Foo.bar 
|> Foo.baz;

lessp avatar Oct 11 '19 14:10 lessp