Documentation

Lean.Elab.MatchExpr

match_expr alternative. Recall that it has the following structure.

| (ident "@")? ident binderIdent* => 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 auxiliary 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.

      Instances For

        Converts syntax representing a match_expr alternative into an Alt.

        Instances For

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

          Instances For

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

            Instances For

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

              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 _.

                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.

                  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.

                    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.

                      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.

                        Instances For
                          def Lean.Elab.Term.MatchExpr.main (discr : Term) (alts : Array Syntax) (elseAlt : Syntax) :
                          Instances For