-
Notifications
You must be signed in to change notification settings - Fork 6
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 conventions for anonymous records (expressions and types) not explicitly given #8
Comments
Case A is indeed straightforward and is as you write (except that GR puts a space before the colon: Case B is thoroughly odd, and I'm inclined to say "do whatever, it won't come up at GR". However, for the sake of completeness, I'd probably format it as follows: let f
(x :
{|
x : int
y : AReallyLongTypeThatIsMuchLongerThan40Characters
|}
)
=
x although I am torn between that and: let f
(
x :
{|
x : int
y : AReallyLongTypeThatIsMuchLongerThan40Characters
|}
)
=
x Both options seem terrible. |
Another example: let internal sepSemi (ctx: Context) =
let { Config = { SpaceBeforeSemicolon = before
SpaceAfterSemicolon = after } } =
ctx What would you make of this @Smaug123? Likely to occur at GR? |
I'd say that's quite unlikely - we'd more explicitly let internal sepSemi (ctx : Context) =
let
{
Config =
{
SpaceBeforeSemicolon = before
SpaceAfterSemicolon = after
}
}
= ctx I'd probably go to almost any lengths to avoid doing this, though. We do have examples like: let foo
{
Bar = bar
Baz = baz
}
=
bar (if that compiles), although I suspect I wrote most of them personally; I wouldn't object too much to the following style: let foo
({
Config =
{
SpaceBeforeSemicolon = before
SpaceAfterSemicolon = after
}
} as ctx)
=
bar |
Basically I think there's no way to satisfy me that any possible options here are aesthetically pleasing, so I don't much mind what we do with them - I would resist allowing any examples through code review anyway :P |
The formatting conventions for records do not mention anonymous records. Personally I would assume the rules are the same for expressions as for records, but the case of types is left (I believe) ambiguous currently.
Consider the following use of anonymous records as types:
The case of
A
is rather straight-forward (leaving aside the code smell of giving an anonymous record a type alias) and follows the rules for normal records in the type position. The case forf
is a little more ambiguous and I believe requires clarification. See also this fantomas issue.The text was updated successfully, but these errors were encountered: