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

Add ++ case for listGetElements #283

Closed morteako closed 8 months ago

morteako commented 8 months ago

Add case for ++ in listGetElements.

This enables simplifications such as

List.member b ([a,b] ++ rest)
--> True

Set.isEmpty (Set.fromList ([a,b] ++ rest))
--> False

Examples in docs

I am not sure about which/how many cases I should add in the documentation for this change. I added one for the two cases above, but there are many more that are now included. Not sure how to generalize it. Maybe the examples also are a bit complex, and this change doesn't really need any doc examples?

Multiple fixes

This can lead to multiple fixes, at least when writing tests.

List.member a ([a,b] ++ [c,d])
--> True
and
--> List.member a ([a,b,c,d])

I guess this is unavoidable and also happens for a lot of other rules and that this is fine, but the solutions is probably just write tests that avoid this issue?