-
Notifications
You must be signed in to change notification settings - Fork 789
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
Format most of FSharp.Core #13150
Format most of FSharp.Core #13150
Conversation
Oh boy 😆 |
To have this in smaller chunks, you could negate some ignored files using |
assert | ||
(match res with | ||
| NewAnonymousObject _ -> true | ||
| _ -> false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too, looks a bit weird, I thing oneliner looked more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matches are never in one line in Fantomas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nojaf Can we keep existing one liner if they are short enough to fit on the line (or use some other metric)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could have a setting for this, to control the max-width to print it as a one-liner.
At first glance, using max_line_length won't work for everyone.
Sounds like a reasonable thing to add to the style guide though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I look at cases like this as places where the original code needs improvement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a tricky case though. People do certainly use one line matches for this purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lack of one line formatting for match union with A -> true | B -> false
is a general concern for the style guide, as there is no other way to implement an union.IsA
property or check, and that is very common - one of the reasons we don't expose the IsA
properties has always been that implementing them is just a trivial match, but now there is a larger penalty for that
So I do wonder whether this shouls be a special case for fantomas, at least until the IsA properties are exposed to F#
Looks like a fantomas bug here:
|
src/FSharp.Core/collections.fs
Outdated
let inline NonStructural<'T when 'T: (static member (<): 'T * 'T -> bool) and 'T: (static member (>): | ||
'T * 'T -> bool)> : IComparer<'T> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should line breaks instead be aligned with and
and only then :
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this looks a little dodgy. @nojaf similar question to above - will constraint formatting affect this? thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, reported fsprojects/fantomas#2267.
src/FSharp.Core/event.fs
Outdated
type Event<'Delegate, 'Args when 'Delegate: delegate<'Args, unit> and 'Delegate :> System.Delegate and 'Delegate: not struct> | ||
() = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it expected to have constructor moved to new line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so. I mean it's at column 133 and it needs a break :)
@nojaf will the adjusted constraint formatting change this? e.g.
type Event<'Delegate, 'Args
when 'Delegate: delegate<'Args, unit>
and 'Delegate :> System.Delegate
and 'Delegate: not struct> () =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess that's what I meant, is if it's possible, to have line breaks at the and
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, probably not. I created fsprojects/fantomas#2266.
.Append("; ") | ||
.Append(txt2) | ||
.Append("]") | ||
.ToString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/dotnet/fsharp/pull/13156/files#diff-0947e2727d6bad8cd0ac4122f5314bb5b04e337393075bc4b5ef143b17fcbd5bR8 may help this (setting fsharp_max_dot_get_expression_width
wider)
I have to say, looking through the files I'm finding it hard to spot additional problems - and there are many improvements. |
@vzarytovskii @nojaf It feels like the only outstanding issue here is the constrained type parameter declarations. We could
I guess (1) ? I'd sort of be OK for (2) but probably better to do (1) |
I might be able to take a look tomorrow. |
@nojaf thanks! Yes I expect will be very similar |
* update fantomas (#13206) * Format most of FSharp.Core (#13150) * modify fantomasignore * fix setting * no single line functions in FSHarp.Core * update fantomas * apply formatting * Format src/Compiler/Driver (#13195) * adjust settings * adjust code * adjust settings * adjust code * fix code before formatting * remove unnecessary yield * manual pre-formatting * preadjust code * preadjust code * preadjust code * preadjust code * adjust settings" * adjust settings" * adjust settings * adjust settings * fix build * adjust settings * adjust code * adjust code * adjust code * update fantomas * apply formatting * apply formatting (fix build) (#13209) * preformat * apply formatting Co-authored-by: Don Syme <[email protected]>
From the compiler code cleanup session last night, this applies auto-formatting to most implementation files in FSharp.Core
There are a lot of changes so we might want to do this in smaller chunks we can review carefully, and possibly make some preliminary adjustments to reduce the diff
+8,971 −5,300 - 120 width
+8,641 −5,286 - 140 width