During the following discussion in the 'print error if file not found' topic, it came up that maybe we should reconsider Task.onFail's behavior or name. Or perhaps add one or both of these two Ttask helpers
|> File.readUtf8
|> Task.onFail (\e ->
_ <- Stderr.line "oops" |> Task.await
Task.fail e
)
|> Task.await
|> File.readUtf8
|> Task.onFail (\_ -> Task.succeed "Some alternate value")
|> Task.await
@Brendan Hansknecht wrote
So the current implementation of onFail doesn't work the way we expected here.
I guess onFail is really "if I fail, try to recover and continue by doing this".
You want, "if I fail, do this, but stay as a failure".
Seems like a generally useful Task function that we are missing. Also a possible naming confusion/conflict.
Last updated: Jun 16 2026 at 16:19 UTC