Liking cljdoc? Tell your friends :D

org.purefn.kurosawa.util

Miscellaneous utility functions.

Miscellaneous utility functions.
raw docstring

chainclj

(chain & steps)

Returns a function that when executed will perform a reversable process composed of a sequence of steps.

  • steps A sequence of 1 argument functions with side effects.

On success, each step function should return a vector [result revert-fn] where:

  • result If non-nil, the value passed to the next step in the process.
  • revert-fn If non-nil, a no-arg function which when executed will reverse the side effects of the step function.

The chain process proceeds by executing the first step function with the initial value. If the result part of the return value is non-nil, this value will be used as the argument for the next step function in the sequence. This repeats until all step functions have been executed successfully.

If during this process the a step function fails, the revert-fn function for all previous steps will be called in the reverse order of execution. This way all side effects of the entire process will be safely undone. Any previous step's revert-fn who's value is nil will be ignored.

A step function is considered to have failed if:

  • The result portion of the value returned by the step function is nil.
  • The entire return value of the step function is nil.
  • The step function throws an exception.

The function returned will take the following arguments:

  • initial The value passed to the first step.
  • opts Optional arguments: :debug true turns on verbose logging.

When executed, it will return the result portion of the last successful step or nil if there is a failure and the process is reverted.

Returns a function that when executed will perform a reversable process 
composed of a sequence of steps.

- `steps`   A sequence of 1 argument functions with side effects.

On success, each step function should return a vector `[result revert-fn]`
where:

- `result`    If non-nil, the value passed to the next step in the process.
- `revert-fn` If non-nil, a no-arg function which when executed will 
              reverse the side effects of the step function.

The chain process proceeds by executing the first step function with the 
`initial` value.  If the `result` part of the return value is non-nil, 
this value will be used as the argument for the next step function in the
sequence.  This repeats until all step functions have been executed 
successfully. 

If during this process the a step function fails, the `revert-fn` function
for all previous steps will be called in the reverse order of execution.
This way all side effects of the entire process will be safely undone. Any 
previous step's `revert-fn` who's value is nil will be ignored.

A step function is considered to have failed if: 

- The `result` portion of the value returned by the step function is nil.
- The entire return value of the step function is nil.
- The step function throws an exception. 

The function returned will take the following arguments: 

- `initial` The value passed to the first step.
- `opts`    Optional arguments: `:debug true` turns on verbose logging.

When executed, it will return the `result` portion of the last successful 
step or nil if there is a failure and the process is reverted.
sourceraw docstring

defprintercljmacro

(defprinter c f)

Overrides the print methods of class c with function f.

Useful for avoiding the printing of large defrecords in logs and the REPL.

Overrides the print methods of class `c` with function `f`.

Useful for avoiding the printing of large `defrecord`s in logs and the REPL.
sourceraw docstring

flipclj

(flip f)

Returns a function which applies its arguments in reversed order from the original function f.

(= ((flip vector) 1 2 3) [3 2 1])

Returns a function which applies its arguments in reversed order from the
original function `f`.

```(= ((flip vector) 1 2 3) [3 2 1])```
sourceraw docstring

revertibleclj

(revertible apply-fn revert-fn)

Takes an application function and revert function, and returns a revertible function suitable for use as part of a chain.

Takes an application function and revert function, and returns a
revertible function suitable for use as part of a `chain`.
sourceraw docstring

step?clj

source

unary?clj

source

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

× close