Replies: 6 comments
-
If a point to surface this call can be suggested then I can make the PR, trying to find where something similar is being surfaced... Any ideas @nojaf |
Beta Was this translation helpful? Give feedback.
-
Oh and if this is approved for implementation, @dsyme , Im getting ahead of myself :-) |
Beta Was this translation helpful? Give feedback.
-
So, what is your exact use case for this? Fantomas uses the Something like: let mkSynExprLambda (pats: SynPat list) (bodyExpr: SynExpr) =
SynExpr.Lambda(false, false, SynSimplePats.SimplePats([], zeroRange), unitExpr, Some(pats, bodyExpr), zeroRange, { ArrowRange = Some zeroRange }) this shape doesn't totally add up and is not what the parser creates. |
Beta Was this translation helpful? Give feedback.
-
The use case is only supplying the information needed to create the lambda. Im just recreating what the parser does in that the |
Beta Was this translation helpful? Give feedback.
-
The current design of FCS does not include helpers for creating syntax tree nodes. Given one of our goals is to stabilise the FCS API and make it binary compatible I don't think we'll be adding this in the near future. |
Beta Was this translation helpful? Give feedback.
-
I'll convert this to a discussion |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
During AST construction using the compiler lambda construction makes it easier to correctly define rather than duplicating info in the ast you can do a single ast construction call.
Describe the solution you'd like
The function
mkSynFunMatchLambdas
is callable from FCS:fsharp/src/fsharp/SyntaxTreeOps.fs
Line 449 in 2de4045
Describe alternatives you've considered
Internal reflection, doing this now, dont tell anyone!
Additional context
There are duplicate pieces to info in the
SynExpr.Lamba
patterns between the simple patterns that are generated by the compiler via the list of patterns grabbed from the parser:In this lambda snippet you can see the App section is duplicated in both the Some (pays, rhs) section, also the pats appear in the SimplePats section above. Using the compiler function you can just supply the pats in list form and the rhs and it will construct the nested lambda correctly. Doing this manually is ok but prone to error.
Beta Was this translation helpful? Give feedback.
All reactions