Reusable utilities for TeGere.
Reusable utilities for TeGere.
(bind f [val err])
Call f on val if err is nil, otherwise return [nil err] See https://adambard.com/blog/acceptable-error-handling-in-clojure/.
Call f on val if err is nil, otherwise return [nil err] See https://adambard.com/blog/acceptable-error-handling-in-clojure/.
(deep-merge-with f & maps)
Like merge-with, but merges maps recursively, applying the given fn only when there's a non-map at a particular level. (deep-merge-with + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4} {:a {:b {:c 2 :d {:z 9} :z 3} :e 100}}) -> {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4} Taken from https://clojuredocs.org/clojure.core/merge-with.
Like merge-with, but merges maps recursively, applying the given fn only when there's a non-map at a particular level. (deep-merge-with + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4} {:a {:b {:c 2 :d {:z 9} :z 3} :e 100}}) -> {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4} Taken from https://clojuredocs.org/clojure.core/merge-with.
(err->> val & fns)
Thread-last val through all fns, each wrapped in bind. See https://adambard.com/blog/acceptable-error-handling-in-clojure/.
Thread-last val through all fns, each wrapped in bind. See https://adambard.com/blog/acceptable-error-handling-in-clojure/.
(just-then maybe just-fn)
(just-then [val error] just-fn nothing-fn)
Given a maybe ([just nothing]
) and a just function that returns a value given
the just
as input, return that value, or a nothing ([nil error]
) if
error
is truthy.
Given a maybe (`[just nothing]`) and a just function that returns a value given the `just` as input, return that value, or a nothing (`[nil error]`) if `error` is truthy.
(just-then-esc maybe)
(just-then-esc maybe just-fn)
(just-then-esc [val error] just-fn nothing-fn)
(maybe-reducer f)
Takes a reducing function and returns one that short-circuits on an accumulator argument that is a Nothing 2-vec, i.e., a vector with a non-nil second item.
Takes a reducing function and returns one that short-circuits on an accumulator argument that is a Nothing 2-vec, i.e., a vector with a non-nil second item.
(maybes->maybe maybes)
Convert a sequence of maybe Xs (2-vecs) to a single maybe sequence of Xs.
Convert a sequence of maybe Xs (2-vecs) to a single maybe sequence of Xs.
(nothing-then maybe nothing-fn)
(nothing-then [val error] nothing-fn then-fn)
Just like just-then except the nothing handler function is the only one required.
Just like just-then except the nothing handler function is the only one required.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close