fix order of Task.sequence

This commit is contained in:
Luke Boswell 2024-07-29 20:31:22 +10:00
parent aabe75ff87
commit 78304a14c7
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0

View file

@ -205,10 +205,12 @@ batch = \current -> \next ->
##
seq : List (Task ok err) -> Task (List ok) err
seq = \tasks ->
List.walkBackwards tasks (ok []) \state, task ->
value <- task |> await
state |> map \values -> List.append values value
init = ok (List.withCapacity (List.len tasks))
List.walkBackwards tasks init \state, task ->
await task \value ->
map state \values -> List.prepend values value
## Apply a task repeatedly for each item in a list
##