<| is commonly used to introduce multiline expressions, which leads to odd formatted:
foo x =
Html.div []
<| case x of
Just data ->
fn data
Nothing ->
Html.text ""
Instead, let's special case <| to be at the end of the line:
foo x =
Html.div [] <|
case x of
Just data ->
fn data
Nothing ->
Html.text ""
For multiline left side:
foo x =
(if isLink then
Html.a []
else
Html.div []
)
<|
case x of
Just data ->
fn data
Nothing ->
Html.text ""
cc @rtfeldman
Sweet! 😃
Not sure how things should be handled when there's a chain of operators, with <| interspersed among other operators
What should this be if we implement this:
foo x =
fn
++ " "
<| a 1
<| b 2
++ " "
<| c 3
I guess it should be
foo x =
fn ++ " " <|
a 1 <|
b 2 ++ " " <|
c 3
Are there operators that have higher precedence than <| for which this wouldn't make sense?
What about chains of multiline <| ?
Multiline should maybe be this:
foo x =
fn
++ " "
<|
a 1
<|
b 2
++ " "
<|
c 3
I would expect it to do this:
foo x =
fn
++ bar <|
a 1 <|
b 2
++ baz <|
c 3
like <| in a multline context means "go down a line and indent, then proceed as normal"
I think your example would come out like this, then:
foo x =
fn
++ bar
<|
a 1 <|
b 2
++ baz
<|
c 3
ah, assuming they put a newline _before_ the <| - got it!
I'm pretty much fine with this...this seems like one of those cases where "you're doing a crazy thing and it's gonna look crazy" should be a fine default until someone drops by with a use case where they're trying to do something reasonable and it ends up doing something undesirable. 😄
Okay, now to see if this can actually be done the way that infix operators are parsed...
@fresheyeball would you mind opening a separate issue for that? This one has an intentionally narrow scope!
Just want to confirm that this would work as follows when anonymous functions are involved:
foo =
something blah
[ another thing <|
foo bar <|
\arg1 arg2 ->
baz
]
Is the above how I should expect that to be formatted?
I would expect the lambda to be indented:
foo =
something blah
[ another thing <|
foo bar <|
\arg1 arg2 ->
baz
]
Ah, gotcha!
On Sun, Jun 12, 2016, 2:57 PM Ɛərɪn VonderHaar [email protected]
wrote:
I would expect the lambda to be indented:
foo =
something blah
[ another thing <|
foo bar <|
\arg1 arg2 ->
baz
]—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/avh4/elm-format/issues/196#issuecomment-225462980,
or mute the thread
https://github.com/notifications/unsubscribe/ABCxwHv3na27QTBv-m5nlZDueAr2mmNeks5qLIDagaJpZM4IxYWD
.
Implemented in b7d14c5...8ec981b.
Looks like this:
foo x =
Html.div [] <|
case x of
Just data ->
fn data
Nothing ->
Html.text ""
foo =
something blah
[ another thing <|
foo bar <|
\arg1 arg2 ->
baz
]
foo x =
fn
++ bar
<|
a 1 <|
b 2
++ baz
<|
c 3