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`.
(->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.
(->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
(<-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
(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
(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.
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
(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`
(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
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close