times3 <- function(x, succeeds = TRUE) {
if (succeeds) success(x * 3)
else failure("func1 failed")
}
success(5) |> bind(times3) |> value()
success(5) |> bind(times3, succeeds = FALSE) |> is_failure()
failure("failed from the start") |> bind(times3) |> is_failure()
failure("failed from the start") |> bind(times3) |> value()
times3 <- function(x, succeeds = TRUE) {
if (succeeds) success(x * 3)
else failure("func1 failed")
}
success(5) |> then_try(times3) |> value()
success(5) |> then_try(times3, succeeds = FALSE) |> is_failure()
failure("failed from the start") |> then_try(times3) |> is_failure()
failure("failed from the start") |> then_try(times3) |> value()
Run the code above in your browser using DataLab