Turns any success whose underlying value doesn't validate the specified predicate into a failure.
Turns any success whose underlying value doesn't validate the specified predicate into a failure.
This is useful when not all successes are interesting. One might receive, for example, a success containing an int, but need to further reduce its domain to positive ints and turn any other into a failure.
Returns the result of applying the specified predicate to the underlying value if a success, false
otherwise.
Returns the result of applying the specified predicate to the underlying value if a success, false
otherwise.
Applies the specified procedure on the underlying value if a success, does nothing otherwise.
Applies the specified procedure on the underlying value if a success, does nothing otherwise.
This is useful when one wants to have side-effects that depend on the success' value - print it, for example.
Returns the underlying value if a success, throws an exception otherwise.
Returns the underlying value if a success, the specified default value otherwise.
Returns true
if the result is a success.
Returns the specified default value if a failure, does nothing otherwise.
Turns any failure whose value is defined for specified partial function into a success with the corresponding value.
Turns any failure whose value is defined for specified partial function into a success with the corresponding value.
This is useful when some error conditions are actually valid answers - one could imagine, for instance, that
failure to parse a boolean could be turned into a successful parsing of false
.
Turns any failure whose value is defined for specified partial function into the corresponding value.
Turns any failure whose value is defined for specified partial function into the corresponding value.
This is useful when some error conditions have fallback solutions - one could imagine, for instance, that failure to parse a file because it does not exist can be retried on a secondary possible location for the file.
Turns a success into a singleton list and a failure into an empty list.
Returns the underlying value if a success, the result of applying the specified function to the failure value otherwise.
Returns the underlying value if a success, the result of applying the specified function to the failure value otherwise.
This is typically useful when one needs to provide a default value that depends on how an operation failed.
Returns true
if the result is a failure.
Represents the result of a decode operation
This is very similar to
Either
, with a few more bells and whistles and a more specific type. It's also much more convenient to use in for-comprehensions, as it has proper map and flatMap methods.