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 Json.Decode.andThen simplifications #221

Closed lue-bird closed 9 months ago

lue-bird commented 9 months ago

Adds Json.Decode.andThen simplifications listed in #2 and more

Json.Decode.andThen f (Json.Decode.fail x)
--> Json.Decode.fail x

Json.Decode.andThen f (Json.Decode.succeed a)
--> f a

Json.Decode.andThen Json.Decode.succeed decoder
--> decoder

Json.Decode.andThen (\a -> Json.Decode.succeed b) decoder
--> Json.Decode.map (\a -> b) decoder

Bonus: Correcting one Task.andThen simplification in the summary

github-actions[bot] commented 9 months ago

The branch can be tried out by running:

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