You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need FSharp.Compiler.SourceCodeServices.FSharpExprVisitor
There is an ExpressionVisitor in core dotnet (System.Linq.Expressions.dll).
That is the way to do meta-programming in C#. It can be used to visit, traversing, examining, copying and transforming LINQ-expressions, which are the default Abstract Syntax Tree (AST) for C#.
In F# there is no one default AST.
F# Query expressions are just a wrappers for LINQ-expressions. (You can use ExpressionVisitor like this.)
Quotations. ASTs are Expr-class. (There is no ExprVisior class, but a workaround is that you convert Expr to LINQ-expression, and use C# ExpressionVisitor. Ugly, but doable.)
FSharp.Compiler.SourceCodeServices.FSharpExpr and this is the problematic one. Expression visitor cannot be done, because type E is not publicly visible and you cannot easily create a new FSharpExpr AST. The visitor should be written to this type.
By searching GitHub for e.g. BasicPatterns.FastIntegerForLoop we can see that there would really be use for this, as the workaround for people has been that they are writing their own yet-another-ASTs to traverse FSharpExpr to something and then processing that. Or even worse, not everyone is an AST-expert, so they try to collect some results directly, losing the tree, and then struggling to handle the results later.
So basically one public method should be added to Exprs.fs (and corresponding Exprs.fsi), which would do something like this:
We need FSharp.Compiler.SourceCodeServices.FSharpExprVisitor
There is an ExpressionVisitor in core dotnet (System.Linq.Expressions.dll).
That is the way to do meta-programming in C#. It can be used to visit, traversing, examining, copying and transforming LINQ-expressions, which are the default Abstract Syntax Tree (AST) for C#.
In F# there is no one default AST.
By searching GitHub for e.g. BasicPatterns.FastIntegerForLoop we can see that there would really be use for this, as the workaround for people has been that they are writing their own yet-another-ASTs to traverse FSharpExpr to something and then processing that. Or even worse, not everyone is an AST-expert, so they try to collect some results directly, losing the tree, and then struggling to handle the results later.
So basically one public method should be added to Exprs.fs (and corresponding Exprs.fsi), which would do something like this:
The text was updated successfully, but these errors were encountered: