Skip to content

feat: dotParam widget to control dot notation#6267

Draft
kmill wants to merge 1 commit intoleanprover:masterfrom
kmill:feat_1629
Draft

feat: dotParam widget to control dot notation#6267
kmill wants to merge 1 commit intoleanprover:masterfrom
kmill:feat_1629

Conversation

@kmill
Copy link
Copy Markdown
Collaborator

@kmill kmill commented Nov 30, 2024

This PR introduces the dotParam marker to indicate which parameter should be used for generalized field notation ("dot notation"). If a function has a dotParam parameter, then this will be used instead of any other argument. Example application:

class A (α : Type _) where
  a : α → Nat

def A.get {α : Type _} [A α] (self : dotParam α) : Nat := a self

structure B where
  b : Nat

instance : A B := ⟨B.b⟩

namespace B
export A (get)
end B

#check fun (b : B) => b.get
-- b.get : Nat

The pretty printing code is modified to support the export-resolved dot notation introduced in #6189.

Closes #1629, closes #5482

This PR introduces the `dotParam` marker to indicate which parameter should be used for generalized field notation ("dot notation"). Example:
```
class A (α : Type _) where
  a : α → Nat

def A.get {α : Type _} [A α] (self : dotParam α) : Nat := a self

structure B where
  b : Nat

instance : A B := ⟨B.b⟩

namespace B
export A (get)
end B

#check fun (b : B) => b.get
-- b.get : Nat
```
The pretty printing code is modified to support the `export`-resolved dot notation introduced in leanprover#6189.

Closes leanprover#1629, closes leanprover#5482
@kmill kmill added the changelog-language Language features and metaprograms label Nov 30, 2024
@kmill kmill marked this pull request as draft November 30, 2024 22:25
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Nov 30, 2024
@ghost
Copy link
Copy Markdown

ghost commented Nov 30, 2024

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase ca96922b4be5d395f6e3102ed3c8950e18982be7 --onto 86f303774a7fbf38406ae13bd4b66f2753643a45. (2024-11-30 22:41:55)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Enhancing the extended field notation (dot notation) Dot notation problem for functions and a suggested improvement

1 participant