Put long multiline constrained SRTP on separate lines.#2263
Conversation
This is ok |
| when ^T: (static member (+): ^T * ^T -> ^T) | ||
| and ^T: (static member DivideByInt: ^T * int -> ^T) | ||
| and ^T: (static member Zero: ^T) | ||
| """ |
There was a problem hiding this comment.
Historically I would have indented this further considering the when as part of the type , rather than part of the declaration. I'm not sure if this will cause problems. For example it could be like this:
val inline average:
array: ^T[] -> ^T
when ^T: (static member (+): ^T * ^T -> ^T)
and ^T: (static member DivideByInt: ^T * int -> ^T)
and ^T: (static member Zero: ^T)
I suppose this PR should add some examples of multi-line types (curried, tupled arguments) to check things are ok?
There was a problem hiding this comment.
Hmm, yes looking at https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting#formatting-types-in-signatures
val inline average:
array: ^T[] -> ^T
when ^T: (static member (+): ^T * ^T -> ^T)
and ^T: (static member DivideByInt: ^T * int -> ^T)
and ^T: (static member Zero: ^T)does make more sense.
|
@dsyme, I've added some more tests. |
|
Looks good!! |
Could you please review @dsyme if this is in line with the style guide?
I do notice that Fantomas doesn't put a space before the colon in
when ^T :.Is this by design for constraints?
Fixes #2230.