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
19 stars 9 forks source link

Add tuple access on tuple map simplifications #225

Closed lue-bird closed 1 year ago

lue-bird commented 1 year ago
Tuple.first (Tuple.mapSecond changeFirst tuple)
--> Tuple.first tuple

Tuple.first (Tuple.mapBoth changeFirst changeSecond tuple)
--> Tuple.first (Tuple.mapFirst changeFirst tuple)

Tuple.second (Tuple.mapFirst changeSecond tuple)
--> Tuple.second tuple

Tuple.second (Tuple.mapBoth changeFirst changeSecond tuple)
--> Tuple.second (Tuple.mapSecond changeSecond tuple)

including composition checks.

Note that this PR doesn't include e.g.

Tuple.second (Tuple.mapSecond changeSecond tuple)
--> changeSecond (Tuple.first tuple)

as I'm still a bit unsure how to fix it.

github-actions[bot] commented 1 year ago

The branch can be tried out by running:

elm-review --template jfmengels/elm-review-simplify/preview