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: set priority in monadic class instances #6725

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

Conversation

JovanGerb
Copy link
Contributor

This PR changes the priority of some instances with monad transformers, most notably adding high priority to MonadExceptOf ε (ExceptT ε m). This means that in ExceptT α MetaM, throw will now throw the α instead of the Exception.

These instances now have high priority:

  • MonadReaderOf ρ (ReaderT ρ m)
  • MonadWithReaderOf ρ (ReaderT ρ m)
  • MonadStateOf σ (StateT σ m)
  • MonadStateOf σ (EStateT ε σ m)
  • MonadExceptOf ε (ExceptT ε m)
  • MonadExceptOf ε (EStateT ε σ m)
  • MonadExceptOf ε (ExceptCpsT ε m)
  • MonadCallStackOf κ (CallStackT κ m)
  • MonadCycleOf κ (CycleT κ m)

And these instance now have low priority:

  • MonadExceptOf Unit (OptionT m)
  • [MonadExcept ε m] {α : Type v} : OrElse (m α)

The last one makes sure that the OrElse instance has lower priority than instOrElseOfAlternative (this change doesn't affect the synthesis order, because the order of the files in which the instances were declared was already 'correct').

In Prelude.lean, instead of setting the priority to high or low, it has to be set to 10000 or 100, which is the same.

The increased priority of MonadExceptOf ε (ExceptT ε m) affected a few files that had to be fixed.

Closes #4212

@JovanGerb JovanGerb requested a review from tydeu as a code owner January 21, 2025 13:13
@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 Jan 21, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jan 21, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 21, 2025
@JovanGerb
Copy link
Contributor Author

!bench

@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Jan 21, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR 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: type class synthesis order when outParam has multiple possible values
2 participants