Turns a successful value into the error returned by a given partial function if it is in the partial function's domain.