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 compose into record access of known field checks #210

Closed lue-bird closed 11 months ago

lue-bird commented 11 months ago

Completes #162 except the parenthesized composition which will be done together with #209

.field << (\a -> { field = b, other = other })
--> (\a -> b)

.field << (\a -> { record | field = b, other = other })
--> (\a -> b)

.field << (\a -> { record | otherField = b })
--> (\a -> record.field)

Note that your original proposal was

.field << (\a -> { record | otherField = b })
--> .field << (\a -> record)

If you prefer that, I'll change it.

github-actions[bot] commented 11 months ago

The branch can be tried out by running:

elm-review --template jfmengels/elm-review-simplify/preview
jfmengels commented 11 months ago

I think your simplication version is very nice and will likely lead to better simplifications :+1: Nice work :+1: