|(require rebellion/base/result)||package: rebellion|
A result is a wrapper around a value that represents either a successful computation or a failed computation. Success results are constructed by wrapping a value with success, and failure results are constructed using failure. The result-case function provides a basic way to unwrap a result. Results are useful when it is difficult to guarantee whether a computation will succeed or fail and specifying a contract up front is either expensive or impossible, such as in filesystem operations, text parsers, or network requests. Wrapping returned values as a result instead of throwing exceptions pushes callers to confront the failure case in order to unwrap the value.
> (result-case (success 42) #:success add1 #:failure displayln)
> (result-case (failure "oh no!") #:success add1 #:failure displayln)
(result/c success-contract failure-contract) → chaperone-contract? success-contract : chaperone-contract? failure-contract : chaperone-contract?