Option monad style exception handling.
Option monad style exception handling.
(attempt f & args)
Attempt a computation which may fail by throwing Exceptions.
Apply the function f
to the given arguments args
.
Success
.Failure
.Attempt a computation which may fail by throwing Exceptions. Apply the function `f` to the given arguments `args`. - If successful, returns the resulting value wrapped in a `Success`. - If an exception occurs, returns the exception wrapped in a `Failure`.
(branch result f g)
Continue computation after a previous Success
or Failure
.
If result
is:
Failure
, return the result of applying the function f
to the
exception wrapped in the Failure.Success
, return the result of applying the g
function to the value
wrapped in the Success
.Continue computation after a previous `Success` or `Failure`. If `result` is: - a `Failure`, return the result of applying the function `f` to the exception wrapped in the Failure. - a `Success`, return the result of applying the `g` function to the value wrapped in the `Success`.
(fail ex)
The reason (Exception) for the failure.
The reason (Exception) for the failure.
(failure result)
Returns the exception wrapped by the Failure
, or nil.
Returns the exception wrapped by the `Failure`, or nil.
(failure? result)
Whether the value is a Failure
.
Whether the value is a `Failure`.
(flatten-results rs)
Convert a sequence of Results into a Result containing a sequence.
Failure
, then the values
for each of the failures will be returned in a seq inside a single Failure
object. Otherwise a Success
will be returned containing the unwrapped
(all successful) elements.Convert a sequence of Results into a Result containing a sequence. - If any of the elements of the sequence are a `Failure`, then the values for each of the failures will be returned in a seq inside a single Failure object. Otherwise a `Success` will be returned containing the unwrapped (all successful) elements.
(proceed result f & args)
Proceed with a computation after a previous Success
.
If the result
is:
Failure
, return it as-is.Success
, return the results of applying the function f
to the value
wrapped in the Success
along with any additional args
provided.Proceed with a computation after a previous `Success`. If the `result` is: - a `Failure`, return it as-is. - a `Success`, return the results of applying the function `f` to the value wrapped in the `Success` along with any additional `args` provided.
(proceed-all result f & args)
Proceed with a computation after a multiple previous Success
s.
In addition to the result
, one or more of the additional arguments args
may also be a Result type. The computation will only proceed if all of these
Result values are a Success
. If any is a Failure
, the first encountered
will be returned as-is. Otherwise, all values wrapped in a Success
will
be extracted and the results of applying the function f
to these values
will be returned.
Proceed with a computation after a multiple previous `Success`s. In addition to the `result`, one or more of the additional arguments `args` may also be a Result type. The computation will only proceed if all of these Result values are a `Success`. If any is a `Failure`, the first encountered will be returned as-is. Otherwise, all values wrapped in a `Success` will be extracted and the results of applying the function `f` to these values will be returned.
(recover result f & args)
Recover from a previous Failure
.
If the result
is:
Failure
, return the result of applying the function f
to the
exception wrapped in the Failure
along with any additional arguments
args
provided.Success
, return it as-is.Recover from a previous `Failure`. If the `result` is: - a `Failure`, return the result of applying the function `f` to the exception wrapped in the `Failure` along with any additional arguments `args` provided. - a `Success`, return it as-is.
(result result)
Returns the value wrapped by the Success
, the exception wrapped by
the Failure
, or nil.
Returns the value wrapped by the `Success`, the exception wrapped by the `Failure`, or nil.
(result? result)
Whether the value is a Success
or Failure
.
Whether the value is a `Success` or `Failure`.
(succeed value)
A successfully computed value.
A successfully computed value.
(success result)
Returns the value wrapped by the Success
, or nil.
Returns the value wrapped by the `Success`, or nil.
(success? result)
Whether the value is a Success
.
Whether the value is a `Success`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close