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

Improvements to fromList key deduplication simplification #329

Merged
merged 24 commits into from
Jan 6, 2025

Conversation

jfmengels
Copy link
Owner

I noticed there was a bug where some entries would be removed: We did Dict.fromList [ ( key, a ), thing, ( key, b ) ] -> Dict.fromList [ ( key, b ) ] which is incorrectly removing thing.

Other improvements:

  • The allDifferent checks now aborts early when finding an error
  • Normalization is done only once instead of once for each comparison with a prior key and once for when it's compared to later keys.

PR can be reviewed commit by commit.

@@ -365,6 +365,26 @@ a = Dict.fromList [ ( key, v0 ), ( key, v1 ) ]
|> Review.Test.whenFixed """module A exposing (..)
import Dict
a = Dict.fromList [ ( key, v1 ) ]
"""
]
, test "should replace Dict.fromList [ ( key, v0 ), thing, ( key, v1 ) ] by Dict.fromList [ thing, ( key, v1 ) ]" <|
Copy link
Collaborator

@lue-bird lue-bird Dec 28, 2024

Choose a reason for hiding this comment

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

Really good refactors and fixes.
I keep missing cases like that so I'll try to test on more examples next time :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

No worries, I only discovered it while refactoring the code and thinking something was odd. Think of what you can, and we can fix based on feedback if necessary 🙂

@jfmengels jfmengels merged commit 8dc0fab into main Jan 6, 2025
2 checks passed
@jfmengels jfmengels deleted the from-list-duplicate-improvements branch January 6, 2025 19:58
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