Comments (7)
It is mentioned in the style guide. Guess this is possible.
from fantomas.
Hi there,
I believe it would be better if there was a new line between each member, this would make the code more consistent. I think that if all the member are single line then not having a new line is fine.
This is a topic for the style guide.
Also, the placement of the trailing } is not always placed on a new line.
In helpers
, }
is placed on a new line because it had a blank line before it. That was preserved from the original code. This works as expected.
from fantomas.
In
helpers
,}
is placed on a new line because it had a blank line before it. That was preserved from the original code. This works as expected.
You say that }
is placed on a new line because there is blank line before however the following snippet results in the same formatting:
let helpers =
{ new IEncoderHelpers<JToken> with
member _.encodeUInt32 value = JValue(box value) }
let helpers2 =
{ new IEncoderHelpers<JToken> with
member _.encodeUInt32 value = JValue(box value)
}
Result
let helpers =
{ new IEncoderHelpers<JToken> with
member _.encodeUInt32 value = JValue (box value)
}
let helpers2 =
{ new IEncoderHelpers<JToken> with
member _.encodeUInt32 value = JValue (box value)
}
In both cases the }
is pushed to a new line under the leading {
.
Options
[*.{fs,fsx}]
max_line_length = 80
fsharp_space_before_uppercase_invocation = true
fsharp_alternative_long_member_definitions = true
fsharp_multi_line_lambda_closing_newline = true
fsharp_bar_before_discriminated_union_declaration = true
fsharp_multiline_bracket_style = stroustrup
fsharp_keep_max_number_of_blank_lines = 2
from fantomas.
Oh, I see. Your original report did not mention fsharp_multiline_bracket_style = stroustrup
.
Stroustrup cannot be applied in absolutely every situation. I was convinced that
let x = { new System.IDisposable with
member _.Dispose () = ()
}
was invalid code. (Producing an offset error).
In certain situations it can lead to invalid code.
This does not seem the case.
I am pretty sure we decided against this for object expressions.
@josh-degraw does this ring a bell?
So, we could double-check whether is indeed possible for object expressions.
If so, someone adds support for it. If not, we document that stroustrup cannot be used absolutely everywhere.
from fantomas.
Yeah that's sounds correct to me as far as what we did. However, wouldn't something like this be valid if we wanted to more strictly apply Stroustrup here?
let x = {
new System.IDisposable with
member _.Dispose () = ()
}
This would be how I would expect Stroustrup style to be applied here.
from fantomas.
If it always leads to valid code, I'd be ok with this.
It really rings a bell that this wasn't the case.
Can't immediately find any prior art though.
from fantomas.
Oh, I see. Your original report did not mention
fsharp_multiline_bracket_style = stroustrup
.
Ah yes sorry, I have a hard time finding which settings I have setup locally and not in the online tool.
from fantomas.
Related Issues (20)
- [Feature request] Make newline experience consistent across match branches HOT 1
- Make Fantomas AOT compatible HOT 12
- cannot determine if Expr AppSingleParenArg Fantomas.Core.SyntaxOak+ExprAppSingleParenArgNode is uppercase or lowercase HOT 1
- cannot determine if Expr AppSingleParenArg Fantomas.Core.SyntaxOak+ExprAppSingleParenArgNode is uppercase or lowercase HOT 2
- [Feature request] Keep `interface end` on a single line HOT 1
- Regression since 6.3.5: Shorthand lambda pushes args far out right with name-sensitive alignment; discrepancy with normal lambda HOT 1
- Stroustrup formatting breaks array containing just empty line or comment HOT 1
- [Feature request] Set custom fantomas path on Fantomas.Client HOT 2
- Idempotency problem when adding members to a single case union without a pipe HOT 15
- Allow "--check" to differ with line-endings style
- Fantomas.Client does not respect DOTNET_CLI_HOME env variable HOT 5
- F# Range Operator (..) with negative numbers produces invalid F# code and idempotent HOT 2
- Weird break after Some instead of binary operator
- Project Update
- Fantomas deletes attributes from getter HOT 1
- Fantomas deletes attributes from getters HOT 1
- Indentation misses a space after boolean operator when multi-line HOT 3
- Idempotency problem when _.Property shorthand with record value
- Tupled member does not have return type at next line
- Active patterns with defined with otherwise invalid name is incorrectly re-formatted HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fantomas.