Hello,
The current style guide does not give any guidance on where to put the when expression in match clauses.
Some examples:
match x with
| Y y when isOdd y -> "y is odd"
| Z z -> z
In small expressions, it makes sense to put the when expr after the pattern.
There is a bit of a problem when the when expr is getting large or contains multiple lines.
Some samples
My personal view on this is if you have a multiline when expression, you should probably refactor it to a partial active pattern and encapsulate your logic there.
Regardless, what advice should be given when this problem arises?
I'm interested in the position of the when keyword, newlines and/or indentations of the multiline expression and the position of the -> arrow.
Thoughts @dsyme and community?
Hello,
The current style guide does not give any guidance on where to put the
whenexpression in match clauses.Some examples:
In small expressions, it makes sense to put the
when exprafter the pattern.There is a bit of a problem when the
when expris getting large or contains multiple lines.Some samples
My personal view on this is if you have a multiline
whenexpression, you should probably refactor it to a partial active pattern and encapsulate your logic there.Regardless, what advice should be given when this problem arises?
I'm interested in the position of the
whenkeyword, newlines and/or indentations of the multiline expression and the position of the->arrow.Thoughts @dsyme and community?