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.andThen simplifications #164

Closed lue-bird closed 12 months ago

lue-bird commented 12 months ago

Task.andThen simplifications as hinted at in #2 and more. These are equivalent to Result.andThen with different type properties so effectively free.

Task.andThen f (Task.fail x)
--> Task.fail x
Task.andThen f (Task.succeed a)
--> f a
Task.andThen Task.succeed task
--> task
Task.andThen (\a -> Task.succeed b) task
--> Task.map (\a -> b) x

map and mapN are also effectively free. Same with onError (andThen with fail as wrap) and mapError (map with fail as wrap).

jfmengels commented 12 months ago

Nice, removing these from #2 :relaxed:

jfmengels commented 12 months ago

We should probably have an issue for the other Task functions, like map though. I'll try to do that later unless you want to do so first.