Documentation

Lean.Elab.MatchExpr

match_expr alternative. Recall that it has the following structure.

| (ident "@")? ident bindeIdent* => rhs

Example:

| c@Eq _ a b => f c a b
  • var? : Option Ident

    some c if there is a variable binding to the function symbol being matched. c is the variable name.

  • funName : Ident

    Function being matched.

  • pvars : List (Option Ident)

    Pattern variables. The list uses none for representing _, and some a for pattern variable a.

  • rhs : Syntax

    right-hand-side for the alternative.

  • k : Ident

    Store the auxliary continuation function for each right-hand-side.

  • actuals : List Term

    Actual value to be passed as an argument.

Instances For

    match_expr else-alternative. Recall that it has the following structure.

    | _ => rhs
    
    Instances For

      Converts syntax representing a match_expr else-alternative into an ElseAlt.

      Equations
        Instances For

          Converts syntax representing a match_expr alternative into an Alt.

          Equations
            Instances For

              Returns the function names of alternatives that do not have any pattern variable left.

              Equations
                Instances For

                  Returns true if there is at least one alternative whose next pattern variable is not a _.

                  Equations
                    Instances For

                      Returns the first alternative whose function name is funName and does not have pattern variables left to match.

                      Equations
                        Instances For

                          Removes alternatives that do not have any pattern variable left to be matched. For the ones that still have pattern variables, remove the first one, and save actual if the removed pattern variable is not a _.

                          Equations
                            Instances For

                              Creates a fresh identifier for representing the continuation function used to execute the RHS of the given alternative, and stores it in the field k.

                              Equations
                                Instances For
                                  def Lean.Elab.Term.MatchExpr.getParams (alt : Alt) :
                                  MacroM (Array (TSyntax `Lean.Parser.Term.bracketedBinder))

                                  Generates parameters for the continuation function used to execute the RHS of the given alternative.

                                  Equations
                                    Instances For

                                      Generates the actual arguments for invoking the auxiliary continuation function associated with the given alternative. The arguments are the actuals stored in alt. discr is also an argument if alt.var? is not none.

                                      Equations
                                        Instances For
                                          Equations
                                            Instances For
                                              def Lean.Elab.Term.MatchExpr.generate (discr : Term) (alts : List Alt) (elseAlt : ElseAlt) :

                                              Generates an if-then-else tree for implementing a match_expr with discriminant discr, alternatives alts, and else-alternative elseAlt.

                                              Equations
                                                Instances For
                                                  partial def Lean.Elab.Term.MatchExpr.generate.loop (kElse : TSyntax `term) (discr : Term) (alts : List Alt) :
                                                  def Lean.Elab.Term.MatchExpr.main (discr : Term) (alts : Array Syntax) (elseAlt : Syntax) :
                                                  Equations
                                                    Instances For
                                                      Equations
                                                        Instances For
                                                          Equations
                                                            Instances For