Skip to content
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

Formatting of multi-constrained SRTP functions needs improvement #2230

Closed
1 of 3 tasks
dsyme opened this issue May 6, 2022 · 1 comment · Fixed by #2263
Closed
1 of 3 tasks

Formatting of multi-constrained SRTP functions needs improvement #2230

dsyme opened this issue May 6, 2022 · 1 comment · Fixed by #2263

Comments

@dsyme
Copy link
Contributor

dsyme commented May 6, 2022

The formatting of the F# library source for signature files for functions like Array.averageBy needs improvement before we can adopt Fantomas on those files.

The multiple SRTP constraints need to be lined up vertically I think, anything else is problematic.

For example see below

Issue created from fantomas-online

Code

    /// Throws <c>ArgumentException</c>
    /// </example>
    [<CompiledName("Average")>]
    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)

Result

/// Throws <c>ArgumentException</c>
/// </example>
[<CompiledName("Average")>]
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)

Problem description

Please describe here the Fantomas problem you encountered.
Check out our Contribution Guidelines.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas master branch at 2022-05-04T06:20:06Z - 0e036ac

Default Fantomas configuration

Signature file

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

@nojaf
Copy link
Contributor

nojaf commented May 7, 2022

Looking at the style guide the example isn't explicitly mentioned, so that might be interesting to have there.

Would the expected outcome be something like:

/// Throws <c>ArgumentException</c>
/// </example>
[<CompiledName("Average")>]
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)

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants