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

[ base ] Deprecate toList functions for sorted sets and maps #3392

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

Conversation

buzden
Copy link
Contributor

@buzden buzden commented Sep 23, 2024

Description

Both Data.SortedMap and Data.SortedSet have specialised toList functions.

For Data.SortedSet, I think this is a historical curious case, since its signature and semantics completely copies toList from Prelude, namely from Foldable, which is implemented by SortedSet. I suggest to remove this completely in the future, but suggest now to deprecate this function in favor of prelude's one for backward compatibility.

For Data.SortedMap, toList has different meaning comparing to the one from Foldable, while Foldable is indeed implemented by SortedMap, having Prelude.toList to list all the values, while SortedMap.toList listing all key-value pairs stored in the map. I think having two functions with the same name having different meaning is not a good thing, plus you need to specify namespace each time you use toList for maps (whichever you use). I suggest to introduce a new function for listing key-value pairs list, namely kvList, and to deprecate special key-value toList function in favor of the new one.

To be clear: this PR is a backward-compatible change, but it adds several deprecation warnings, and I suggest the breaking change after the next release (namely, removing deprecated functions).

Should this change go in the CHANGELOG?

  • If this is a fix, user-facing change, a compiler change, or a new paper
    implementation, I have updated CHANGELOG_NEXT.md (and potentially also
    CONTRIBUTORS.md).

For sorted maps a `kvList` should be used instead,
for sorted sets use `toList` from `prelude`.
@dunhamsteve
Copy link
Contributor

There is a fromList which does the opposite of SortedMap.toList. Should we change the name of that (and maybe fromListWith too)?

@buzden
Copy link
Contributor Author

buzden commented Sep 23, 2024

There is a fromList which does the opposite of SortedMap.toList. Should we change the name of that (and maybe fromListWith too)?

I thought about that but 1) I didn't come up with a better name 2) I thought this may be a too much change which would probably be discarded because of the size. For instance, this would change even the Show instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants