Skip to content

[Merged by Bors] - style: prefer some/none over .some/.none#27896

Closed
JovanGerb wants to merge 5 commits intoleanprover-community:masterfrom
JovanGerb:Jovan-some-none
Closed

[Merged by Bors] - style: prefer some/none over .some/.none#27896
JovanGerb wants to merge 5 commits intoleanprover-community:masterfrom
JovanGerb:Jovan-some-none

Conversation

@JovanGerb
Copy link
Copy Markdown
Contributor

@JovanGerb JovanGerb commented Aug 3, 2025

The notation .some and .none are very useful when working with other inductive types such as LOption which have fields names some and/or none. But for Option, we prefer to simply write some/none.

#mathlib4 > style: `.some`/`.none` vs `some`/`none`


Open in Gitpod

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 3, 2025

PR summary f0f1d7c49b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@eric-wieser
Copy link
Copy Markdown
Member

This might need a zulip thread if this is a new style decision, or a pointer to a core style guide if lean itself has already adopted this.

I'm been bitten one too many times by | none matching everything under a variable called none, so personally prefer to always use the . version.

@JovanGerb
Copy link
Copy Markdown
Contributor Author

I don't understand what you mean with | none matching everything under a variable named none. I don't think this is possible in a match statement (although it is possible with let, as in let none := 5).

def foo (n : Nat) : Nat :=
  match n with
  | none => 4

throws an error.

@alreadydone
Copy link
Copy Markdown
Contributor

reassigning to maintainer @eric-wieser since most of the code is in the meta part of the library which I'm not familiar with.

@eric-wieser
Copy link
Copy Markdown
Member

Thanks @JovanGerb, indeed I must have been remembering the behavior of let.

@kmill, do you know if core has a preference here?

@eric-wieser eric-wieser assigned kmill and unassigned eric-wieser Aug 11, 2025
@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 26, 2025
@mathlib4-merge-conflict-bot
Copy link
Copy Markdown
Collaborator

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 26, 2025
@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 29, 2025
@mathlib4-merge-conflict-bot
Copy link
Copy Markdown
Collaborator

This pull request has conflicts, please merge master and resolve them.

@kmill
Copy link
Copy Markdown
Contributor

kmill commented Aug 30, 2025

@eric-wieser I don't think core has any advice, though let some is a couple orders of magnitude more common than let .some. Seeing .some/.none for Option does give me pause, so the change seems reasonable to me.

@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 30, 2025
@kmill
Copy link
Copy Markdown
Contributor

kmill commented Aug 30, 2025

bors r+

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Aug 30, 2025
mathlib-bors bot pushed a commit that referenced this pull request Aug 30, 2025
The notation `.some` and `.none` are very useful when working with other inductive types such as `LOption` which have fields names `some` and/or `none`. But for `Option`, we prefer to simply write `some`/`none`.

[#mathlib4 > style: &#96;.some&#96;/&#96;.none&#96; vs &#96;some&#96;/&#96;none&#96;](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/style.3A.20.60.2Esome.60.2F.60.2Enone.60.20vs.20.60some.60.2F.60none.60)

Co-authored-by: Jovan Gerbscheid <jovan.gerbscheid@gmail.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 30, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title style: prefer some/none over .some/.none [Merged by Bors] - style: prefer some/none over .some/.none Aug 30, 2025
@mathlib-bors mathlib-bors bot closed this Aug 30, 2025
CBirkbeck pushed a commit to CBirkbeck/mathlib4 that referenced this pull request Sep 8, 2025
…y#27896)

The notation `.some` and `.none` are very useful when working with other inductive types such as `LOption` which have fields names `some` and/or `none`. But for `Option`, we prefer to simply write `some`/`none`.

[#mathlib4 > style: &leanprover-community#96;.some&leanprover-community#96;/&leanprover-community#96;.none&leanprover-community#96; vs &leanprover-community#96;some&leanprover-community#96;/&leanprover-community#96;none&leanprover-community#96;](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/style.3A.20.60.2Esome.60.2F.60.2Enone.60.20vs.20.60some.60.2F.60none.60)

Co-authored-by: Jovan Gerbscheid <jovan.gerbscheid@gmail.com>
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Oct 2, 2025
…y#27896)

The notation `.some` and `.none` are very useful when working with other inductive types such as `LOption` which have fields names `some` and/or `none`. But for `Option`, we prefer to simply write `some`/`none`.

[#mathlib4 > style: &leanprover-community#96;.some&leanprover-community#96;/&leanprover-community#96;.none&leanprover-community#96; vs &leanprover-community#96;some&leanprover-community#96;/&leanprover-community#96;none&leanprover-community#96;](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/style.3A.20.60.2Esome.60.2F.60.2Enone.60.20vs.20.60some.60.2F.60none.60)

Co-authored-by: Jovan Gerbscheid <jovan.gerbscheid@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants