[style-guide] Multiline application in patterns
- Dominant language
- F#
- Stars
- 557
- Forks
- 149
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 2
Description
Hello,
What should the guidance be for multiline (function?) applications in patterns?
Example:
```fsharp
match myString with
| Regex @"^(\w+) can fly (\d+) km/s for (\d+) seconds, but then must rest for (\d+) seconds\.$" [ name; speed; flyTime; restTime ] ->
()
```
Imagine this pattern doesn't respect the `max_line_length`, how should it be formatted multiline?
This
```fsharp
match myString with
| Regex
@"^(\w+) can fly (\d+) km/s for (\d+) seconds, but then must rest for (\d+) seconds\.$"
[ name; speed; flyTime; restTime ] ->
()
```
comes to mind.
Related, patterns do seem to have some funky offset rules from time to time.
The same example wrapped in a record:
```fsharp
match myString with
| { X = Regex
@"^(\w+) can fly (\d+) km/s for (\d+) seconds, but then must rest for (\d+) seconds\.$"
[ name
speed
flyTime
restTime ] } ->
()
```
Notice that:
```fsharp
match myString with
| { X =
Regex
@"^(\w+) can fly (\d+) km/s for (\d+) seconds, but then must rest for (\d+) seconds\.$"
[ name
speed
flyTime
restTime ] } ->
()
```
is invalid F# code. ([online tool](https://fsprojects.github.io/fantomas-tools/#/ast?data=N4KABGBEAmCmBmBLAdrAzpAXFSAacUiaAYmolmPAIYA2as%2BEkAxgPZwWQC2VALswAswXAJ4BlXgCcUAczAB3RLwEAdSSuQAfMMDAANMAF4wAJVgzYADzBqNEew-sABFZAB6AChUr5AagCUYMxUyJQ0ImBeKtABYADWXAD0aJSskpHeMYH0bMjQaLhgAEYArrxgyrChXCVo5ZLo5fBpGdGxOax5aN4AdAAkrjbqoY6jANpgyFRcsLYjo6NoAA6wsNBzCwvw4QAqiDMbm44NdXszYAC6YAC%2BYAC0AHyHEB7%2Bc3M8-EKiEtLIcoplHNtLoDMZno4zBZrBDNi53FE-IFgqFthEoll4kkUs10hj2rBcvlCqVypVqrV6o1UnjMgSid0VP1BrCFhMpgdhkdHMtVusudz7GizrMBYKwCdeCLLjd7k8xZF-JAQNcgA))
Another interesting case is:
```fsharp
match myString with
| X(
Regex
@"^(\w+) can fly (\d+) km/s for (\d+) seconds, but then must rest for (\d+) seconds\.$"
[ name
speed
flyTime
restTime ]
) ->
()
```
This is valid code, thought the closing `)` needs to be aligned with the `X` column.
@dsyme any thoughts on this?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.