Skip to content

feat: generalize basic Inhabited/Nonempty instances from Monad to Applicative#12041

Open
fgdorais wants to merge 3 commits intoleanprover:masterfrom
fgdorais:applicative-inhabited
Open

feat: generalize basic Inhabited/Nonempty instances from Monad to Applicative#12041
fgdorais wants to merge 3 commits intoleanprover:masterfrom
fgdorais:applicative-inhabited

Conversation

@fgdorais
Copy link
Copy Markdown
Contributor

@fgdorais fgdorais commented Jan 19, 2026

This PR generalizes basic derived Inhabited/Nonempty instances from Monad to Applicative.

Closes #12042

@fgdorais fgdorais changed the title refactor: move basic inhabited instances from Monad to Applicative feat: generalize basic Inhabited/Nonempty instances from Monad to Applicative Jan 19, 2026
@fgdorais fgdorais marked this pull request as ready for review January 19, 2026 10: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 Jan 19, 2026
@ghost
Copy link
Copy Markdown

ghost commented Jan 19, 2026

Mathlib CI status (docs):

  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2026-01-19 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2026-01-19 10:31:07)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-01-19 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-01-19 10:31:09)

Comment thread src/Init/Prelude.lean Outdated
Comment thread src/Init/Prelude.lean
seqLeft := fun a b => Seq.seq (Functor.map (Function.const _) a) b
seqRight := fun a b => Seq.seq (Functor.map (Function.const _ id) a) b

instance {α : Type u} {f : Type u → Type v} [Applicative f] : Inhabited (α → f α) where
Copy link
Copy Markdown
Contributor

@eric-wieser eric-wieser Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this forms a diamond with the instance below (and the instance that sets default = fun i => default for pi types).

It would probably be better to demote this to Nonempty to avoid this risk.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense but that would be a regression. I wouldn't do that without maintainer input.

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@fgdorais
Copy link
Copy Markdown
Contributor Author

changelog-library

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

Labels

changelog-library Library 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: generalize basic Inhabited/Nonempty instances from Monad to Applicative

3 participants