Giter Club home page Giter Club logo

Comments (10)

dungpa avatar dungpa commented on July 19, 2024

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.

dungpa avatar dungpa commented on July 19, 2024

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.

ovatsus avatar ovatsus commented on July 19, 2024

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.

ovatsus avatar ovatsus commented on July 19, 2024

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.

dungpa avatar dungpa commented on July 19, 2024

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.

ovatsus avatar ovatsus commented on July 19, 2024

Yes, but I'll probably be only able to pick this up by the end of next week

from fantomas.

dungpa avatar dungpa commented on July 19, 2024

I plan to upload a new version of VS extension next week. Do you have time to work on this feature?

from fantomas.

ovatsus avatar ovatsus commented on July 19, 2024

No, I'll probably only have time for fantomas again in September

from fantomas.

dungpa avatar dungpa commented on July 19, 2024

Take your time. I have vacation next week, so I have more time to work on the project.

from fantomas.

dsyme avatar dsyme commented on July 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.