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 Task.onError simplifications #165

Closed lue-bird closed 12 months ago

lue-bird commented 12 months ago

Task.onError, the andThen for failing tasks (that I wish result etc had as well).

Task.onError f (Task.succeed a)
--> Task.succeed a

Task.onError f (Task.fail x)
--> f x

Task.onError Task.fail task
--> task

Task.onError (\x -> Task.fail y) task
--> Task.mapError (\x -> y) x

Bonus: Minor improvements to the tests of Result.andThen and Task.andThen