Should have blank line before else clauses, as shown in the 0.17 guide:
after : Int -> Task x ()
after backoff =
if backoff < 1 then
Task.succeed ()
else
Process.sleep (toFloat (10 * 2 ^ backoff))
Cool! I've never tried coding in this style, but I appreciate the newlines in case expressions, and it makes sense that they'd be nice in if expressions as well.
I vote for no, the else feels disconnected.
What if if-else has no space, but if-else if-else if-else chains have a space? The thinking is that chains are like case, but when they're two it's just one unit.
Here are a couple of snippets:
foo =
let
value1 =
if True then
"Value 1"
else
"Value 2"
value2 =
"Value"
in
value1 ++ value2
And with space;
foo =
let
value1 =
if True then
"Value 1"
else
"Value 2"
value2 =
"Value"
in
value1 ++ value2
I get the impression that the space above else dilutes the code too much.
@mgold you mean like this?
foo =
let
value1 =
if x == 1 then
"Value 1"
else if x == 2 then
"Value 2"
else if x == 3 then
"Value 3"
else
"Value 4"
That actually looks pretty decent!
A variation of that could be that the last else doesn't have the empty line above it, but I wouldn't do that.
This was implemented in 0.8.0, at specific request from Evan.
Most helpful comment
Here are a couple of snippets:
And with space;
I get the impression that the space above else dilutes the code too much.