Skip to content

Could I get access to mkSynFunMatchLambdas via FCS API?Β #13092

@7sharp9

Description

@7sharp9

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:

let mkSynFunMatchLambdas synArgNameGenerator isMember wholem ps arrow e =

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:

Lambda
                   (false, false,
                    SimplePats
                      ([Typed
                          (Id
                             (_arg1, None, true, false, false,
                              tmp.fsx (1,6--1,7)),
                           LongIdent (LongIdentWithDots ([SingleCaseDU], [])),
                           tmp.fsx (1,6--1,21))], tmp.fsx (1,5--1,22)),
                    Lambda
                      (false, true,
                       SimplePats
                         ([Typed
                             (Id
                                (value, None, false, false, false,
                                 tmp.fsx (1,24--1,29)),
                              LongIdent (LongIdentWithDots ([int], [])),
                              tmp.fsx (1,24--1,34))], tmp.fsx (1,23--1,35)),
                       App
                         (NonAtomic, false, Ident Single, Ident value,
                          tmp.fsx (1,39--1,51)), None, tmp.fsx (1,1--1,51),
                       { ArrowRange = Some tmp.fsx (1,36--1,38) }),
                    Some
                      ([Paren
                          (Typed
                             (Wild tmp.fsx (1,6--1,7),
                              LongIdent (LongIdentWithDots ([SingleCaseDU], [])),
                              tmp.fsx (1,6--1,21)), tmp.fsx (1,5--1,22));
                        Paren
                          (Typed
                             (Named (value, false, None, tmp.fsx (1,24--1,29)),
                              LongIdent (LongIdentWithDots ([int], [])),
                              tmp.fsx (1,24--1,34)), tmp.fsx (1,23--1,35))],
                       App
                         (NonAtomic, false, Ident Single, Ident value,
                          tmp.fsx (1,39--1,51))), tmp.fsx (1,1--1,51),
                    { ArrowRange = Some tmp.fsx (1,36--1,38) })

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions