Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add string singleton comparison operators to scala.compiletime.ops.string.#24748

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
wtetzner wants to merge1 commit intoscala:main
base:main
Choose a base branch
Loading
fromwtetzner:string-singleton-comparisons

Conversation

@wtetzner
Copy link

The numeric singleton types already have comparison operators, but for some reason this was still missing for singleton String types.

This enables a lot of potential valuable type-level computations, but one in particular is the ability to sort a named tuple, which means that if you're commonly adding/removing entries from a named tuple, this provides a way to normalize them, so two named tuples that were constructed in a different order can still be treated as equivalent types.

Test results:https://gist.github.com/wtetzner/6f38842c5d06a5d70ba5eea2cf7ce298

He-Pin reacted with thumbs up emoji
@wtetznerwtetzner requested a review froma team as acode ownerDecember 14, 2025 02:59
…ring.The numeric singleton types already have comparison operators, but forsome reason this was still missing for singleton String types.This enables a lot of potential valuable type-level computations, butone in particular is the ability to sort a named tuple, which means thatif you're commonly adding/removing entries from a named tuple, thisprovides a way to normalize them, so two named tuples that wereconstructed in a different order can still be treated as equivalenttypes.
@wtetznerwtetznerforce-pushed thestring-singleton-comparisons branch from881ae82 tof5d3a15CompareDecember 14, 2025 05:28
@bishabosha
Copy link
Member

bishabosha commentedDec 15, 2025
edited
Loading

i wonder if its generally useful to also have tuple sorting itself as a type operation - perhaps it can have a binary op "comparator" argument as well (so< et all can still be added) - of course you do need to remember the order of the pairs of key, value so i guess you pair, sort and then unzip (which it looks like your demo does)

@ritschwumm
Copy link

not sure this makes sense: there is no single lexicographic order for strings, thisalways depends on the locale.

bishabosha reacted with confused emoji

@wtetzner
Copy link
Author

wtetzner commentedDec 15, 2025
edited
Loading

not sure this makes sense: there is no single lexicographic order for strings, thisalways depends on the locale.

Are you sure? I don't think Java's default String comparison depends on locale, and I believe that's what Scala's comparison operators use. It's case folding that needs locale, and we're not doing that here.

I think you need to useCollator for locale-dependent sorting.

@tgodziktgodzik added the needs-minor-releaseThis PR cannot be merged until the next minor release labelDec 17, 2025
@GedochaoGedochao added the stat:feature freezeIssues and PRs waiting for the feature freeze to be lifted. labelDec 17, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

needs-minor-releaseThis PR cannot be merged until the next minor releasestat:feature freezeIssues and PRs waiting for the feature freeze to be lifted.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@wtetzner@bishabosha@ritschwumm@tgodzik@Gedochao

[8]ページ先頭

©2009-2025 Movatter.jp