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)
;; => #<Right [1]>
(either/left 1)
;; => #<Left [1]>
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) ;; => #<Right [1]> (either/left 1) ;; => #<Left [1]>
The Exception monad.
Also known as Try monad, popularized by Scala.
It represents a computation that may either result in an exception or return a successfully computed value. Is very similar to Either monad, but is semantically different.
It consists in two types: Success and Failure. The Success type is a simple wrapper like Right of Either monad. But the Failure type is slightly different from Left, because it is forced to wrap an instance of Throwable (or Error in cljs).
The most common use case of this monad is for wrap third party libraries that uses standard Exception based error handling. In normal circumstances you should use Either instead.
The types defined for Exception monad (Success and Failure) also implementes the clojure IDeref interface which facilitates libraries developing using monadic composition without forcing a user of that library to use or understand monads.
That is because when you will dereference the failure instance, it will reraise the containing exception.
The Exception monad. Also known as Try monad, popularized by Scala. It represents a computation that may either result in an exception or return a successfully computed value. Is very similar to Either monad, but is semantically different. It consists in two types: Success and Failure. The Success type is a simple wrapper like Right of Either monad. But the Failure type is slightly different from Left, because it is forced to wrap an instance of Throwable (or Error in cljs). The most common use case of this monad is for wrap third party libraries that uses standard Exception based error handling. In normal circumstances you should use Either instead. The types defined for Exception monad (Success and Failure) also implementes the clojure IDeref interface which facilitates libraries developing using monadic composition without forcing a user of that library to use or understand monads. That is because when you will dereference the failure instance, it will reraise the containing exception.
The Maybe monad implementation and helpers functions for working with maybe related types.
(require '[cats.monad.maybe :as maybe])
(maybe/just 1)
;; => #<Just [1]>
The Maybe monad implementation and helpers functions for working with maybe related types. (require '[cats.monad.maybe :as maybe]) (maybe/just 1) ;; => #<Just [1]>
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close