Skip to content
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

Plugin AST modification? #893

Closed
Thorium opened this issue Jun 5, 2020 · 4 comments
Closed

Plugin AST modification? #893

Thorium opened this issue Jun 5, 2020 · 4 comments

Comments

@Thorium
Copy link
Member

Thorium commented Jun 5, 2020

Would Fantomas to be open for AST-processing?
I'm kind of open to any solutions to Expression visitor in FSharp.Compiler.Service, but in similar issues Don has referred possible solution place to be first in Fantomas.

Is Fantomas OK to expose the types used for syntax trees?
For example SynExpr seems not to be internal.
Would it be enough to solve the issues?

  1. To user be able to parse existing ASTs to collect data (and custom ASTs).
  2. And also push the modified AST back to get the F# source code. So not (AST-> Unit), but (AST -> AST).
  3. ...and maybe even generate F# code from custom ASTs.
@jindraivanek
Copy link
Contributor

I think this is exactly what Myriad project is doing - AST->AST transformation, then use Fantomas to output source code.

Also note that Fantomas and Myriad use AST, but example in link (BasicPatterns.*) is for TAST.

@nojaf
Copy link
Contributor

nojaf commented Jun 6, 2020

I think, in general, this might be more relevant for the FsAST project.

Is Fantomas OK to expose the types used for syntax trees?

Fantomas uses everything that is part of the FSharp.Compiler.SyntaxTree module from the FCS.
So I'm not really sure what you mean here.

Don has referred possible solution place to be first in Fantomas.

That language suggestion where Don mentions Fantomas, is about AST -> string.
Which is something we have right now in our public API.

Would Fantomas to be open for AST-processing?

I'd prefer to keep Fantomas the AST -> string and (string -> AST) >> (AST -> string) solution to be honest. Other projects do other stuff with AST as well, I feel like your suggestion might be better suited over there.

@Thorium
Copy link
Member Author

Thorium commented Jun 6, 2020

How hard would it be for anyone to do a ReSharper for F#
but instead of OO-refactorings, focus on functional programming? (For example these.)

The interesting part is the AST optimization (some AST-optimizer sample here) but before that, we'd need a common (AST -> AST) transformation tool, and "AST back to code printer" tool (Fantomas).

Then use F# Analyzers SDK for VS Code and fix a corresponding VS2017/2019 solution for the editor IDE suggestions.

But turns out it cannot be done quickly, these existing projects don't yet play well together.

@nojaf
Copy link
Contributor

nojaf commented Jul 3, 2020

I'm going to close this as we don't wish to pursue this with Fantomas.

@nojaf nojaf closed this as completed Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants