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.reverse [ a ] --> [ a ] #143

Closed lue-bird closed 12 months ago

lue-bird commented 1 year ago

sort, sortBy, sortWith already have a simple check for returning the list unchanged when it's a singleton list.

List.reverse [ a ]
--> [ a ]

-- not shown in summary
List.reverse (List.singleton a)
--> List.singleton a

-- not shown in summary
List.reverse << List.singleton
--> List.singleton
jfmengels commented 12 months ago

We can do the same for String.reverse when we see String.reverse (String.fromChar c)