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 `List.repeat 1 --> List.singleton` simplification #152

Closed lue-bird closed 12 months ago

lue-bird commented 12 months ago

Implements #133 + tests:

List.repeat 1 x
--> List.singleton x

Interestingly, there was previously a test that explicitly required List.repeat 1 x to not be simplified. Do you still know about why you added it?

jfmengels commented 12 months ago

Yeah I think I know why, and it's not for a good reason. Seems like at some point I fixed List.repeat 1 list to list when it should have been [ list ]. I noticed the error a bit later and fixed it (in 489b5c6db256f43442f3a6c2f6ce90d003747156) bit did not think about fixing it to use List.singleton or wrapping it in [].