Comments (10)
I like the second option.
But it's tricky to make it safe. For example, you can't remove paretheses in the following pattern
List.map (fun (x, y) -> x + y)
There might be an issue with removing parentheses because we rely on matching tokens to insert comments and compiler directives in the post-processing step. I think we should keep the first option default for now.
from fantomas.
Brainstorming for this proposal:
Where can we remove parentheses safely?
- Around simple values or literals in functional application e.g.
Console.WriteLine(x)
- Around tuple construction and deconstruction e.g.
let (x, y) = (1, 2)
- Around tuples in patterns e.g.
match (x, y) with (1, 2) -> ...
Where should we NOT remove parentheses?
- Around pattern matching of complex expressions e.g.
let (Ident x) = y
- Around inline pattern matching of anonymous functions e.g.
fun (x, y) -> x + y
- Around nested parentheses of units e.g.
member x.Yield(()) = ...
This may suffer from unmatched token issues as #42 but it is easier to bypass (some workarounds have been implemented).
from fantomas.
We can also remove parentheses safely in DU constructors with only one field:
let y = Some(x)
->let y = Some x
->math x with | Some(y) -> y
->math x with | Some y -> y
from fantomas.
This is specially important when you're generating code manually, and to be safe put parenthesis around everything, so you might get stuff like let x = (if true then "foo" else "bar")
from fantomas.
I agree it's a nice addition.
Can you take a look at this? I will take care of formatting around cursor position (part of #54).
from fantomas.
Yes, but I'll probably be only able to pick this up by the end of next week
from fantomas.
I plan to upload a new version of VS extension next week. Do you have time to work on this feature?
from fantomas.
No, I'll probably only have time for fantomas again in September
from fantomas.
Take your time. I have vacation next week, so I have more time to work on the project.
from fantomas.
In the (long) process of integrating Fantomas into FCS I will close enhancement requests like this - once things are in shape we can start to take enhancement request issues in either Microsoft\visualfsharp or FCS repo
from fantomas.
Related Issues (20)
- Invalid location of comma when using named parameters for a class HOT 2
- Insertion of a newline changes precedence of the `||>` operator HOT 1
- Incorrect indentation of compiler-conditional accessibility modifier for module definition HOT 2
- [Stroustrup] Comment above the record bracket beaks formatting when `MultilineBracketStyle` is `Stroustrup`
- Fantomas strips quotes from quoted type-parameters HOT 2
- Tupled parameter wrapped in conditional directive
- Online formatter URLs do not remember stroustrup HOT 2
- Unary operator spacing inconsistent between veriable and literal
- Option for consistent indentation style of all pattern matching branches HOT 1
- Trivia after infix operator is not restored correctly
- Missing space before arrow
- Idempotency problem when reformatting type declaration with large when clause HOT 13
- [Feature request] Smarter ignore folder check HOT 3
- Setter is also private HOT 1
- Private keyword is lost from getter with unit
- Inline keyword is missing in property
- Xml doc on properties is missing HOT 1
- [max_line_length] does not work HOT 3
- `fsharp_max_function_binding_width` docs sample is just a copy of `fsharp_max_value_binding_width` HOT 4
- Additional newline for interface in object expression
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.