Liking cljdoc? Tell your friends :D

ring-jwt-middleware.result

This ns provides a set of helpers to handle an abstraction similar to Either in Haskell.

The main goal is to provide a mechanism similar to the exceptions, albeit pure - without Java Exceptions.

When a function returns a Result - it either contains a result of a successful outcome or an error with a common error structure (JwtError).

The let-either macro provides a monadic syntax. Mainly:

(let-either [result-value-1 (fn-returning-a-result-1 ,,,)
             result-value-2 (fn-returning-a-result-2 ,,,)
             ,,,]
  ,,,)

if fn-returning-a-result-1 returns an error then we will not execute the rest of the let-either. And return the full result.

This ns provides a set of helpers to handle an abstraction similar to Either in Haskell.

The main goal is to provide a mechanism similar to the exceptions, albeit pure - without Java Exceptions.

When a function returns a `Result` - it either contains a result of a successful outcome or an error with a
common error structure (`JwtError`).

The `let-either` macro provides a monadic syntax.
Mainly:

```
(let-either [result-value-1 (fn-returning-a-result-1 ,,,)
             result-value-2 (fn-returning-a-result-2 ,,,)
             ,,,]
  ,,,)
```

if `fn-returning-a-result-1` returns an error then we will not execute the rest of the let-either.
And return the full `result`.
raw docstring

->errclj

(->err err-code err-description error-metas)

Inputs: [err-code :- s/Keyword err-description :- s/Str error-metas :- #:s{Any s/Any}] Returns: Result

build a Result that contain an error.

Inputs: [err-code :- s/Keyword err-description :- s/Str error-metas :- #:s{Any s/Any}]
Returns: Result

build a Result that contain an error.
sourceraw docstring

->pureclj

(->pure v)

Inputs: [v] Returns: Result

given a value build a result containing this value

Inputs: [v]
Returns: Result

given a value build a result containing this value
sourceraw docstring

<-resultclj

(<-result result)

Inputs: [result :- Result] Returns: s/Any

Either returns the value or the error contained in the Result

Inputs: [result :- Result]
Returns: s/Any

Either returns the value or the error contained in the Result
sourceraw docstring

error?clj

(error? m)

Inputs: [m :- Result] Returns: s/Bool

return true if the given result is an Error

Inputs: [m :- Result]
Returns: s/Bool

return true if the given result is an Error
sourceraw docstring

let-eithercljmacro

(let-either bindings & body)

To be used to handle cascading results that may depend on preceding values. If one of the function fail, we return the failed result. If all functions are successful we return the content of the body.

To be used to handle cascading results that may depend on preceding values.
If one of the function fail, we return the failed result.
If all functions are successful we return the content of the body.
sourceraw docstring

Resultclj

A result is similar to the Either in Haskell It represent either a value or an error

A result is similar to the Either in Haskell
It represent either a value or an error
sourceraw docstring

result-ofclj

(result-of s)

Inputs: [s]

Build a schema representing a result expecting succesful result with schema s

Inputs: [s]

Build a schema representing a result expecting succesful result with schema `s`
sourceraw docstring

success?clj

(success? m)

Inputs: [m :- Result] Returns: s/Bool

return true if the given result is not an Error

Inputs: [m :- Result]
Returns: s/Bool

return true if the given result is not an Error
sourceraw docstring

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

× close