Liking cljdoc? Tell your friends :D

org.purefn.kurosawa.result

Option monad style exception handling.

Option monad style exception handling.
raw docstring

attemptclj

(attempt f & args)

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.
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`.
sourceraw docstring

branchclj

(branch result f g)

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.
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`.
sourceraw docstring

failclj

(fail ex)

The reason (Exception) for the failure.

The reason (Exception) for the failure.
sourceraw docstring

failureclj

(failure result)

Returns the exception wrapped by the Failure, or nil.

Returns the exception wrapped by the `Failure`, or nil.
sourceraw docstring

failure?clj

(failure? result)

Whether the value is a Failure.

Whether the value is a `Failure`.
sourceraw docstring

flatten-resultsclj

(flatten-results rs)

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.
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.
sourceraw docstring

proceedclj

(proceed result f & args)

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 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.
sourceraw docstring

proceed-allclj

(proceed-all result f & args)

Proceed with a computation after a multiple previous Successs.

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.
sourceraw docstring

recoverclj

(recover result f & args)

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.
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.
sourceraw docstring

resultclj

(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.
sourceraw docstring

result?clj

(result? result)

Whether the value is a Success or Failure.

Whether the value is a `Success` or `Failure`.
sourceraw docstring

succeedclj

(succeed value)

A successfully computed value.

A successfully computed value.
sourceraw docstring

successclj

(success result)

Returns the value wrapped by the Success, or nil.

Returns the value wrapped by the `Success`, or nil.
sourceraw docstring

success?clj

(success? result)

Whether the value is a Success.

Whether the value is a `Success`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close