Skip to content

Commit a96c742

Browse files
authored
Simplify race (#53)
1 parent ae4668f commit a96c742

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ConcurrentTask.elm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,10 +848,13 @@ race task tasks =
848848
toRacer =
849849
mapError RaceError >> andThen (Winner >> fail)
850850
in
851-
List.map toRacer (task :: tasks)
852-
|> batch
853-
-- This makes the types match up but will never be run, as one of the sub task will always `fail` with a `Winner`.
854-
|> andThen (List.head >> Maybe.map succeed >> Maybe.withDefault (toRacer task))
851+
map2
852+
(\h _ ->
853+
-- This makes the types match up but will never be run, as one of the sub task will always `fail` with a `Winner`.
854+
never h
855+
)
856+
(toRacer task)
857+
(batch (List.map toRacer tasks))
855858
|> onError
856859
(\e ->
857860
case e of

0 commit comments

Comments
 (0)