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

Dict.fromList & Set.fromList duplicate key merge #328

Merged
merged 3 commits into from
Dec 27, 2024

Conversation

lue-bird
Copy link
Collaborator

@lue-bird lue-bird commented Dec 22, 2024

implements #326 except for insert

Set.fromList [ a, a ] --> Set.fromList [ a ]
Dict.fromList [ ( a, v0 ), ( a, v1 ) ] --> Dict.fromList [ ( a, v1 ) ]

Honestly I'm surprised we didn't implement this already because it seems pretty useful.

The check for duplicates is n^2 but I guess that shouldn't be too bad because these explicit fromList calls are rare and usually not terribly long in non-codegen code.

@lue-bird lue-bird added the enhancement New feature or request label Dec 22, 2024
@@ -5998,6 +6004,69 @@ setFromListChecks =
[ intoFnCheckOnlyCall (emptiableFromListChecks setCollection)
, wrapperFromListSingletonChecks setCollection
, onSpecificFnCallReturnsItsLastArgCheck Fn.Set.toList
, intoFnCheckOnlyCall
(\checkInfo ->
if checkInfo.expectNaN then
Copy link
Owner

Choose a reason for hiding this comment

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

Later improvement: I guess we could do this check but only for literals if expectNaN is True.

@jfmengels
Copy link
Owner

This looks great, thanks @lue-bird!

@jfmengels jfmengels merged commit 25cc054 into jfmengels:main Dec 27, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants