An important part of the interface of a function is the parameter names, for making used of named arguments. This PR makes the parameter names print in a reliable way. The parameters of the type now appear as hygienic names if they cannot be used as named arguments. Modifies the heuristic for how parameters are chosen to appear before or after the colon. The rule is now that parameters start appearing after the colon at the first non-dependent non-instance-implicit parameter that has a name unusable as a named argument. This is a refinement of #2846. Fixes the issue where consecutive hygienic names pretty print without a space separating them, so we now have `(x✝ y✝ : Nat)` rather than `(x✝y✝ : Nat)`. Breaking change: `Lean.PrettyPrinter.Formatter.pushToken` now takes an additional boolean `ident` argument, which should be `true` for identifiers. Used to insert discretionary space between consecutive identifiers. Closes #5810
68 lines
1.6 KiB
Text
68 lines
1.6 KiB
Text
def Option_map (f : α → β) : Option α → Option β
|
||
| none => none
|
||
| some x => some (f x)
|
||
|
||
/--
|
||
info: equations:
|
||
theorem Option_map.eq_1.{u_1, u_2} : ∀ {α : Type u_1} {β : Type u_2} (f : α → β), Option_map f none = none
|
||
theorem Option_map.eq_2.{u_1, u_2} : ∀ {α : Type u_1} {β : Type u_2} (f : α → β) (x_1 : α),
|
||
Option_map f (some x_1) = some (f x_1)
|
||
-/
|
||
#guard_msgs in
|
||
#print equations Option_map
|
||
|
||
/--
|
||
info: Option_map.eq_def.{u_1, u_2} {α : Type u_1} {β : Type u_2} (f : α → β) (x✝ : Option α) :
|
||
Option_map f x✝ =
|
||
match x✝ with
|
||
| none => none
|
||
| some x => some (f x)
|
||
-/
|
||
#guard_msgs in
|
||
#check Option_map.eq_def
|
||
|
||
/--
|
||
info: Option_map.eq_unfold.{u_1, u_2} :
|
||
@Option_map = fun {α} {β} f x =>
|
||
match x with
|
||
| none => none
|
||
| some x => some (f x)
|
||
-/
|
||
#guard_msgs in
|
||
#check Option_map.eq_unfold
|
||
|
||
def answer := 42
|
||
|
||
/-- info: answer.eq_unfold : answer = 42 -/
|
||
#guard_msgs in
|
||
#check answer.eq_unfold
|
||
|
||
-- structural recursion
|
||
def List_map (f : α → β) : List α → List β
|
||
| [] => []
|
||
| x::xs => f x :: List_map f xs
|
||
/--
|
||
info: List_map.eq_unfold.{u_1, u_2} :
|
||
@List_map = fun {α} {β} f x =>
|
||
match x with
|
||
| [] => []
|
||
| x :: xs => f x :: List_map f xs
|
||
-/
|
||
#guard_msgs in
|
||
#check List_map.eq_unfold
|
||
|
||
-- wf recursion
|
||
def List_map2 (f : α → β) : List α → List β
|
||
| [] => []
|
||
| x::xs => f x :: List_map2 f xs
|
||
termination_by l => l
|
||
|
||
/--
|
||
info: List_map2.eq_unfold.{u_1, u_2} :
|
||
@List_map2 = fun {α} {β} f x =>
|
||
match x with
|
||
| [] => []
|
||
| x :: xs => f x :: List_map2 f xs
|
||
-/
|
||
#guard_msgs in
|
||
#check List_map2.eq_unfold
|