Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Proposing new syntax for zero-cost unwrapping options/results

$
0
0

not sure it’s been addressed in this thread, however:

what if there are, say two different errors, that can occur:

let? r = myFunc()

let’s say I can handle and recover ErrorA but not ErrorB? in case of ErrorA i want to do something, but in case of ErrorB i want it to propagate and early-return:

let r = switch getConn() {
| Ok(x) => x
| Error(ErrorA) =>
  reconnectAndGetConn() // hypothetical recover
| Error(ErrorB) =>
  return Error(ErrorB) // not possible?
}

how does this proposal handle the above scenario?


Viewing all articles
Browse latest Browse all 2592

Trending Articles