Liking cljdoc? Tell your friends :D

monad-flow.core

MonadFlow: A library for idiomatic error handling using the Either monad. Functions should return a vector [val error], where val represents a successful result (the Right value), and error represents a failure (the Left value). If no error occurs, val contains the result, and error is nil. Functions not following this convention can be 'lifted' using the lift function.

MonadFlow: A library for idiomatic error handling using the Either monad.
Functions should return a vector [val error], where `val` represents a successful result 
(the Right value), and `error` represents a failure (the Left value). If no error occurs, 
`val` contains the result, and `error` is nil. Functions not following this convention 
can be 'lifted' using the `lift` function.
raw docstring

Eithercljprotocol

The Either monad interface, representing success (Right) or error (Left).

The Either monad interface, representing success (Right) or error (Left).

success?clj

(success? _)

Returns true if this is a Right value, indicating success.

Returns true if this is a Right value, indicating success.
sourceraw docstring

inspect-chain->cljmacro

(inspect-chain-> val body)

Inserts side-effecting operations into a try-chain-> flow for debugging or logging. The value :flow-value is replaced with the current computation value.

Example: (f/try-chain-> 10 (f/inspect-chain-> (println "initial value: " :flow-value)) inc (f/inspect-chain-> (println "intermediate value: " :flow-value)) inc (f/inspect-chain-> (println "not important")) inc (f/inspect-chain-> (println "final value: " :flow-value))) initial value: 10 intermediate value: 11 not important final value: 13 => Right{:value 13}

Inserts side-effecting operations into a `try-chain->` flow for debugging or logging.
 The value `:flow-value` is replaced with the current computation value.

Example:
  (f/try-chain-> 10
               (f/inspect-chain-> (println "initial value: " :flow-value))
               inc
               (f/inspect-chain-> (println "intermediate value: " :flow-value))
               inc
               (f/inspect-chain-> (println "not important"))
               inc
               (f/inspect-chain-> (println "final value: " :flow-value)))
  initial value:  10
  intermediate value:  11
  not important
  final value:  13
  => Right{:value 13}
sourceraw docstring

inspect-chain->>cljmacro

(inspect-chain->> body val)

Inserts side-effecting operations into a try-chain->> flow for debugging or logging. The value :flow-value is replaced with the current computation value.

Example: (f/try-chain->> 10 (f/inspect-chain->> (println "initial value: " :flow-value)) inc (f/inspect-chain->> (println "intermediate value: " :flow-value)) inc (f/inspect-chain->> (println "not important")) inc (f/inspect-chain->> (println "final value: " :flow-value))) initial value: 10 intermediate value: 11 not important final value: 13 => .Right{:value 13}

Inserts side-effecting operations into a `try-chain->>` flow for debugging or logging.
 The value `:flow-value` is replaced with the current computation value.

Example:
  (f/try-chain->> 10
                (f/inspect-chain->> (println "initial value: " :flow-value))
                inc
                (f/inspect-chain->> (println "intermediate value: " :flow-value))
                inc
                (f/inspect-chain->> (println "not important"))
                inc
                (f/inspect-chain->> (println "final value: " :flow-value)))
  initial value:  10
  intermediate value:  11
  not important
  final value:  13
  => .Right{:value 13}
sourceraw docstring

liftclj

(lift f)
(lift f error-fn)

Wraps a function f with error handling, returning a monadic value (Right on success, Left on error). Optionally, customize the error transformation with error-fn.

Wraps a function `f` with error handling, returning a monadic value 
(Right on success, Left on error). Optionally, customize the error transformation with `error-fn`.
sourceraw docstring

lift->cljmacro

(lift-> body)
(lift-> val body)

Helper for more readable error handling inside try-chain->. Automatically wraps expressions in a try block and returns a monadic value.

Example: (try-chain-> {:a "a value"} (lift-> :a)) => Right{:value "a value"}

Helper for more readable error handling inside `try-chain->`.
 Automatically wraps expressions in a try block and returns a monadic value.

Example:
   (try-chain-> {:a "a value"}
     (lift-> :a))
   => Right{:value "a value"}
sourceraw docstring

lift->>cljmacro

(lift->> body)
(lift->> body val)

Helper for more readable error handling inside try-chain->>. Automatically wraps expressions in a try block and returns a monadic value.

Example: (try-chain->> {:a "a value"} (lift->> :a)) => Right{:value "a value"}

Helper for more readable error handling inside `try-chain->>`.
Automatically wraps expressions in a try block and returns a monadic value.

Example:
  (try-chain->> {:a "a value"}
    (lift->> :a))
  => Right{:value "a value"}
sourceraw docstring

lift-valueclj

(lift-value x)

Wraps the plain value x into a monadic (Right, Left) value. If x is nil or a [nil error] pair, it returns a Left with an error message.

Wraps the plain value `x` into a monadic (Right, Left) value. 
If `x` is nil or a [nil error] pair, it returns a Left with an error message.
sourceraw docstring

try-chain->cljmacro

(try-chain-> expr & forms)

Attempts to thread the expression expr through forms, like ->, but handling errors monadically. Each function must return an Either value or a pair [val error] pair. If an error occurs (Left), it short-circuits the flow.

Example: (try-chain-> 1 (wrap inc)) => Right{:value 2}

(try-chain-> 1 (wrap inc) (wrap #(throw+ (str "error: " %)))) => Left{:error "error: 2"}

Attempts to thread the expression `expr` through forms, like `->`, but handling errors monadically.
Each function must return an Either value or a pair [val error] pair. If an error occurs (Left), it short-circuits the flow.

Example:
   (try-chain-> 1
     (wrap inc))
   => Right{:value 2}

   (try-chain-> 1
     (wrap inc)
     (wrap #(throw+ (str "error: " %))))
   => Left{:error "error: 2"}
sourceraw docstring

try-chain->>cljmacro

(try-chain->> expr & forms)

Similar to try-chain->, but uses the ->> threading model. The result of each function is passed as the last argument to the next form. Returns either a Right (success) or Left (error).

Example: (try-chain->> 1 (wrap inc) (wrap #(throw+ (str "error: " %)))) => Left{:error "error: 2"}

Similar to `try-chain->`, but uses the `->>` threading model. The result of each function is 
passed as the last argument to the next form. Returns either a Right (success) or Left (error).

Example:
  (try-chain->> 1
    (wrap inc)
    (wrap #(throw+ (str "error: " %))))
  => Left{:error "error: 2"}
sourceraw docstring

wrapclj

(wrap f)
(wrap f error-fn)

Alias for lift

Alias for `lift`
sourceraw docstring

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

× close