File: .lake/packages/lean4/src/lean/Lean/Elab/MatchExpr.lean

full_name: Lean.Elab.Term.MatchExpr.Alt
code: /--
`match_expr` alternative. Recall that it has the following structure.
```
| (ident "@")? ident bindeIdent* => rhs
```

Example:
```
| c@Eq _ a b => f c a b
```
-/
structure Alt where
  /--
  `some c` if there is a variable binding to the function symbol being matched.
  `c` is the variable name.
  -/
  var?    : Option Ident
  /-- Function being matched. -/
  funName : Ident
  /-- Pattern variables. The list uses `none` for representing `_`, and `some a` for pattern variable `a`. -/
  pvars   : List (Option Ident)
  /-- right-hand-side for the alternative. -/
  rhs     : Syntax
  /-- Store the auxliary continuation function for each right-hand-side. -/
  k       : Ident := ⟨.missing⟩
  /-- Actual value to be passed as an argument. -/
  actuals : List Term := []
goal: Type

full_name: Lean.Elab.Term.MatchExpr.Alt.pvars
code: /--
`match_expr` alternative. Recall that it has the following structure.
```
| (ident "@")? ident bindeIdent* => rhs
```

Example:
```
| c@Eq _ a b => f c a b
```
-/
structure Alt where
  /--
  `some c` if there is a variable binding to the function symbol being matched.
  `c` is the variable name.
  -/
  var?    : Option Ident
  /-- Function being matched. -/
  funName : Ident
  /-- Pattern variables. The list uses `none` for representing `_`, and `some a` for pattern variable `a`. -/
  pvars   : List (Option Ident)
  /-- right-hand-side for the alternative. -/
  rhs     : Syntax
  /-- Store the auxliary continuation function for each right-hand-side. -/
  k       : Ident := ⟨.missing⟩
  /-- Actual value to be passed as an argument. -/
  actuals : List Term := []
goal: List (Option Lean.Ident)

full_name: Lean.Elab.Term.MatchExpr.Alt.funName
code: /--
`match_expr` alternative. Recall that it has the following structure.
```
| (ident "@")? ident bindeIdent* => rhs
```

Example:
```
| c@Eq _ a b => f c a b
```
-/
structure Alt where
  /--
  `some c` if there is a variable binding to the function symbol being matched.
  `c` is the variable name.
  -/
  var?    : Option Ident
  /-- Function being matched. -/
  funName : Ident
  /-- Pattern variables. The list uses `none` for representing `_`, and `some a` for pattern variable `a`. -/
  pvars   : List (Option Ident)
  /-- right-hand-side for the alternative. -/
  rhs     : Syntax
  /-- Store the auxliary continuation function for each right-hand-side. -/
  k       : Ident := ⟨.missing⟩
  /-- Actual value to be passed as an argument. -/
  actuals : List Term := []
goal: Lean.Ident

full_name: Lean.Elab.Term.MatchExpr.Alt.k
code: /--
`match_expr` alternative. Recall that it has the following structure.
```
| (ident "@")? ident bindeIdent* => rhs
```

Example:
```
| c@Eq _ a b => f c a b
```
-/
structure Alt where
  /--
  `some c` if there is a variable binding to the function symbol being matched.
  `c` is the variable name.
  -/
  var?    : Option Ident
  /-- Function being matched. -/
  funName : Ident
  /-- Pattern variables. The list uses `none` for representing `_`, and `some a` for pattern variable `a`. -/
  pvars   : List (Option Ident)
  /-- right-hand-side for the alternative. -/
  rhs     : Syntax
  /-- Store the auxliary continuation function for each right-hand-side. -/
  k       : Ident := ⟨.missing⟩
  /-- Actual value to be passed as an argument. -/
  actuals : List Term := []
goal: Lean.Ident

full_name: Lean.Elab.Term.MatchExpr.Alt.actuals
code: /--
`match_expr` alternative. Recall that it has the following structure.
```
| (ident "@")? ident bindeIdent* => rhs
```

Example:
```
| c@Eq _ a b => f c a b
```
-/
structure Alt where
  /--
  `some c` if there is a variable binding to the function symbol being matched.
  `c` is the variable name.
  -/
  var?    : Option Ident
  /-- Function being matched. -/
  funName : Ident
  /-- Pattern variables. The list uses `none` for representing `_`, and `some a` for pattern variable `a`. -/
  pvars   : List (Option Ident)
  /-- right-hand-side for the alternative. -/
  rhs     : Syntax
  /-- Store the auxliary continuation function for each right-hand-side. -/
  k       : Ident := ⟨.missing⟩
  /-- Actual value to be passed as an argument. -/
  actuals : List Term := []
goal: List Lean.Term

full_name: Lean.Elab.Term.MatchExpr.Alt.var?
code: /--
`match_expr` alternative. Recall that it has the following structure.
```
| (ident "@")? ident bindeIdent* => rhs
```

Example:
```
| c@Eq _ a b => f c a b
```
-/
structure Alt where
  /--
  `some c` if there is a variable binding to the function symbol being matched.
  `c` is the variable name.
  -/
  var?    : Option Ident
  /-- Function being matched. -/
  funName : Ident
  /-- Pattern variables. The list uses `none` for representing `_`, and `some a` for pattern variable `a`. -/
  pvars   : List (Option Ident)
  /-- right-hand-side for the alternative. -/
  rhs     : Syntax
  /-- Store the auxliary continuation function for each right-hand-side. -/
  k       : Ident := ⟨.missing⟩
  /-- Actual value to be passed as an argument. -/
  actuals : List Term := []
goal: Option Lean.Ident

full_name: Lean.Elab.Term.MatchExpr.Alt.rhs
code: /--
`match_expr` alternative. Recall that it has the following structure.
```
| (ident "@")? ident bindeIdent* => rhs
```

Example:
```
| c@Eq _ a b => f c a b
```
-/
structure Alt where
  /--
  `some c` if there is a variable binding to the function symbol being matched.
  `c` is the variable name.
  -/
  var?    : Option Ident
  /-- Function being matched. -/
  funName : Ident
  /-- Pattern variables. The list uses `none` for representing `_`, and `some a` for pattern variable `a`. -/
  pvars   : List (Option Ident)
  /-- right-hand-side for the alternative. -/
  rhs     : Syntax
  /-- Store the auxliary continuation function for each right-hand-side. -/
  k       : Ident := ⟨.missing⟩
  /-- Actual value to be passed as an argument. -/
  actuals : List Term := []
goal: Lean.Syntax

full_name: Lean.Elab.Term.MatchExpr.ElseAlt.rhs
code: /--
`match_expr` else-alternative. Recall that it has the following structure.
```
| _ => rhs
```
-/
structure ElseAlt where
  rhs : Syntax
goal: Lean.Syntax

full_name: Lean.Elab.Term.MatchExpr.ElseAlt
code: /--
`match_expr` else-alternative. Recall that it has the following structure.
```
| _ => rhs
```
-/
structure ElseAlt where
  rhs : Syntax
goal: Type

full_name: Lean.Elab.Term.MatchExpr.toElseAlt?
code: /--
Converts syntax representing a `match_expr` else-alternative into an `ElseAlt`.
-/
def toElseAlt? (stx : Syntax) : Option ElseAlt 
goal: Option Lean.Elab.Term.MatchExpr.ElseAlt

full_name: Lean.Elab.Term.MatchExpr.toAlt?
code: /--
Converts syntax representing a `match_expr` alternative into an `Alt`.
-/
def toAlt? (stx : Syntax) : Option Alt 
goal: Option Lean.Elab.Term.MatchExpr.Alt

full_name: Lean.Elab.Term.MatchExpr.getFunNamesToMatch
code: /--
Returns the function names of alternatives that do not have any pattern variable left.
-/
def getFunNamesToMatch (alts : List Alt) : List Ident 
goal: List Lean.Ident

full_name: Lean.Elab.Term.MatchExpr.shouldSaveActual
code: /--
Returns `true` if there is at least one alternative whose next pattern variable is not a `_`.
-/
def shouldSaveActual (alts : List Alt) : Bool 
goal: Bool

full_name: Lean.Elab.Term.MatchExpr.getAltFor?
code: /--
Returns the first alternative whose function name is `funName` **and**
does not have pattern variables left to match.
-/
def getAltFor? (alts : List Alt) (funName : Ident) : Option Alt 
goal: Option Lean.Elab.Term.MatchExpr.Alt

full_name: Lean.Elab.Term.MatchExpr.next
code: /--
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 `_`.
-/
def next (alts : List Alt) (actual : Term) : List Alt 
goal: List Lean.Elab.Term.MatchExpr.Alt

full_name: Lean.Elab.Term.MatchExpr.initK
code: /--
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`.
-/
def initK (alt : Alt) : MacroM Alt 
goal: Lean.MacroM Lean.Elab.Term.MatchExpr.Alt

full_name: Lean.Elab.Term.MatchExpr.getParams
code: /--
Generates parameters for the continuation function used to execute
the RHS of the given alternative.
-/
def getParams (alt : Alt) : MacroM (Array (TSyntax ``bracketedBinder)) 
goal: Lean.MacroM (Array (Lean.TSyntax `Lean.Parser.Term.bracketedBinder))

full_name: Lean.Elab.Term.MatchExpr.getActuals
code: /--
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.
-/
def getActuals (discr : Term) (alt : Alt) : MacroM (Array Term) 
goal: Lean.MacroM (Array Lean.Term)

full_name: Lean.Elab.Term.MatchExpr.toDoubleQuotedName
code: def toDoubleQuotedName (ident : Ident) : Term 
goal: Lean.Term

full_name: Lean.Elab.Term.MatchExpr.generate.loop
code: /--
Generates an `if-then-else` tree for implementing a `match_expr` with discriminant `discr`,
alternatives `alts`, and else-alternative `elseAlt`.
-/
partial def generate (discr : Term) (alts : List Alt) (elseAlt : ElseAlt) : MacroM Syntax 
goal: Lean.MacroM Lean.Term

full_name: Lean.Elab.Term.MatchExpr.generate
code: /--
Generates an `if-then-else` tree for implementing a `match_expr` with discriminant `discr`,
alternatives `alts`, and else-alternative `elseAlt`.
-/
partial def generate (discr : Term) (alts : List Alt) (elseAlt : ElseAlt) : MacroM Syntax 
goal: Lean.MacroM Lean.Syntax

full_name: Lean.Elab.Term.MatchExpr.main
code: def main (discr : Term) (alts : Array Syntax) (elseAlt : Syntax) : MacroM Syntax 
goal: Lean.MacroM Lean.Syntax

full_name: Lean.Elab.Term.expandMatchExpr
code: @[builtin_macro Lean.Parser.Term.matchExpr] def expandMatchExpr : Macro 
goal: Lean.Macro

full_name: Lean.Elab.Term.expandLetExpr
code: @[builtin_macro Lean.Parser.Term.letExpr] def expandLetExpr : Macro 
goal: Lean.Macro