Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improved export command, namespace aliases #6393

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Dec 15, 2024

This PR gives the export command the ability to create aliases to namespaces, in addition to its current ability to create aliases to individual declarations. It adds a number of open-like variations to the syntax.

  • export NS1 ... NSn makes the current namespace be an alias for the provided namespaces.
  • export NS (def1 ... defn) has the same meaning as before, but if any NS.defi is a namespace then the alias also serves as a namespace alias. For example, if one were to do
    namespace MyNS
    export Lean (Name)
    end MyNS
    then not only is MyNS.Name available as an alias for Name, but now additionally MyNS.Name.str is an alias for Lean.Name.str.
  • export NS hiding def1 ... defn is like export NS, but the given names def1 through defn in NS do not get aliases.
  • export NS renaming def1 -> def1', ..., defn -> defn' creates aliases for the given names def1 through defn, but the aliases respectively use the names def1' through defn'.

Closes #6394 (RFC)

This PR gives the `export` command the ability to create aliases to namespaces,
in addition to its current ability to create aliases to individual declarations.
It adds a number of `open`-like variations to the syntax.
* `export NS1 ... NSn` makes the current namespace be an alias for the provided namespaces.
* `export NS (def1 ... defn)` has the same meaning as before, but if any `NS.defi` is a namespace
  then the alias also serves as a namespace alias. For example, if one were to do
  ```lean
  namespace MyNS
  export _root_ (Nat)
  end MyNS
  ```
  then not only is `MyNS.Nat` available as an alias for `Nat`,
  but additionally `MyNS.Nat.succ` is now an alias for `Nat.succ`.
* `export NS hiding def1 ... defn` is like `export NS`, but the given names in `NS` do not get aliases.
* `export NS renaming def1 -> def1', ..., defn -> defn'` creates aliases for the given names `def1` through `defn`,
  but the aliases respectively use the names `def1'` through `defn'`.
@kmill kmill added the changelog-language Language features, tactics, and metaprograms label Dec 15, 2024
@kmill kmill requested a review from mhuisi as a code owner December 15, 2024 22:11
@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 Dec 15, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Dec 15, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Dec 15, 2024
@leanprover-community-bot leanprover-community-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Dec 15, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Dec 15, 2024

Mathlib CI status (docs):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan changelog-language Language features, tactics, 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: Let export create namespace aliases
2 participants