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
How to deal with multiline expressions in parens #12
Comments
I'm pretty sure the offside rule allows you to write this without the round brackets... Something like: foo x =
case x of
Just a ->
a
_ ->
7
|> toString I prefer my pipelines aligned, rather than indented anyway. |
This isn't exactly it, but I think there must be cases where the parens are required: foo x =
CtorWithTwoParams
( case x of
Just a ->
a
_ ->
7
)
"second param" |
Yes, a case as a parameter will need to be wrapped in parentheses I guess. I'm ok this the style from your example. You simply shouldn't use case expressions there, so the formatter punishes you by giving an ugly piece of code (that's still very readable). |
Following this proposed rule, all I'd change would be removing the space after the open paren: foo x =
(case x of
Just a ->
a
_ ->
7
)
|> toString Neither of them looks great, but this has the benefit of the rule being simpler to explain. 😉 |
Using no space leads to: multilineParenthesizedExpressions =
(if range == 0 then
0.1
else
toFloat range
) where the |
Following this idea would solve this too: foo x =
(
case x of
Just a ->
a
_ ->
7
)
|> toString |
We'll go with #20 for now. The it ended up working, the following case will actually keep multilineParenthesizedExpressions =
(if range == 0 then
0.1
else
toFloat range
) |
How should the following be formatted?
The text was updated successfully, but these errors were encountered: