The Either monad implementation and helper functions for working with either related types.
Also commonly known as Error monad.
(require '[cats.monad.either :as either])
(either/right 1)
;; => nil
(either/left 1)
;; => nil
The Either monad implementation and helper functions for working with either related types. Also commonly known as Error monad. (require '[cats.monad.either :as either]) (either/right 1) ;; => nil (either/left 1) ;; => nil
(branch e lf rf)
Given an either value and two functions, if the either is a left apply the first function to the value it contains; if the either is a right apply the second function to its value.
Given an either value and two functions, if the either is a left apply the first function to the value it contains; if the either is a right apply the second function to its value.
(branch-left e lf)
Given an either value and a function, if the either is a left, apply the function to the value it contains; if the either is a right, return it.
Given an either value and a function, if the either is a left, apply the function to the value it contains; if the either is a right, return it.
(branch-right e rf)
Either-specific synonym for #'cats.core/bind
Given an either value and a function, if the either is a right, apply the function to the value it contains; if the either is a left, return it.
Either-specific synonym for #'cats.core/bind Given an either value and a function, if the either is a right, apply the function to the value it contains; if the either is a left, return it.
(either? v)
Return true in case of v
is instance
of Either monad.
Return true in case of `v` is instance of Either monad.
Given a collection of either, return the first value that is left
Given a collection of either, return the first value that is left
Given a collection of either, return the first value that is right
Given a collection of either, return the first value that is right
(invert e)
Convert a left to a right or viceversa, preserving content.
Convert a left to a right or viceversa, preserving content.
(left? v)
Return true if v
is an instance
of Left type.
Return true if `v` is an instance of Left type.
Given a collection of eithers, return only the values that are left.
Given a collection of eithers, return only the values that are left.
(right? v)
Return true if v
is an instance
of Right type.
Return true if `v` is an instance of Right type.
Given a collection of eithers, return only the values that are right.
Given a collection of eithers, return only the values that are right.
(try-either & body)
Try to evalute the body and return the result as an either. If an exception is thrown return the exception as a left, otherwise return the result as a right.
Try to evalute the body and return the result as an either. If an exception is thrown return the exception as a left, otherwise return the result as a right.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close