jfmengels / elm-review-simplify

Provides elm-review rules to simplify your Elm code
https://package.elm-lang.org/packages/jfmengels/elm-review-simplify/latest/
BSD 3-Clause "New" or "Revised" License
20 stars 9 forks source link

Filter out duplicate keys in Set./Dict.fromList #136

Open lue-bird opened 1 year ago

lue-bird commented 1 year ago

Additional simplifications similar to how determineSize with fromList works:

for Set

always

Set.fromList [ 1, b, 1 ]
--> Set.fromList [ b, 1 ]

with expectNaN disabled

Set.fromList [ a, b, a ]
--> Set.fromList [ a, b ]

for Dict

always

Dict.fromList [ ( 1, x ), b, ( 1, y ) ]
--> Dict.fromList [ b, ( 1, y ) ]

with expectNaN disabled

Dict.fromList [ a, b, a ]
--> Dict.fromList [ a, b ]

Dict.fromList [ ( a, x ), b, ( a, y ) ]
--> Dict.fromList [ b, ( a, y ) ]
jfmengels commented 1 year ago

Did you mean?

Dict.fromList [ ( 1, x ), b, ( 1, y ) ]
--> Dict.fromList [ b, ( 1, y ) ]

For the last one, we probably want to have Dict.fromList [ b, ( a, y ) ], we don't want to change the order of insertion.

Maybe we want to remove the earlier items for Set as well, though in practice that should not matter at all :thinking:

lue-bird commented 1 year ago

we probably want to have Dict.fromList [ b, ( a, y ) ], we don't want to change the order of insertion.

Good spot, edited.