The Maybe monad implementation and helpers functions for working with maybe related types.
(require '[cats.monad.maybe :as maybe])
(maybe/just 1)
;; => nil
The Maybe monad implementation and helpers functions for working with maybe related types. (require '[cats.monad.maybe :as maybe]) (maybe/just 1) ;; => nil
(cat-maybes coll)
Given a collection of maybes, return a sequence of the values that the just's contain.
Given a collection of maybes, return a sequence of the values that the just's contain.
(from-maybe mv)
(from-maybe mv default)
Return inner value from maybe monad.
This is a specialized version of cats.core/extract
for Maybe monad types that allows set up
the default value.
Let see some examples:
(from-maybe (just 1))
;=> 1
(from-maybe (nothing))
;=> nil
(from-maybe (nothing) 42)
;=> 42
Return inner value from maybe monad. This is a specialized version of `cats.core/extract` for Maybe monad types that allows set up the default value. Let see some examples: (from-maybe (just 1)) ;=> 1 (from-maybe (nothing)) ;=> nil (from-maybe (nothing) 42) ;=> 42
(just? v)
Returns true if v
is an instance
of Just
type.
Returns true if `v` is an instance of `Just` type.
(map-maybe mf coll)
Given a maybe-returning function and a collection, map the function over the collection returning the values contained in the just values of the resulting collection.
Given a maybe-returning function and a collection, map the function over the collection returning the values contained in the just values of the resulting collection.
(maybe default m f)
Given a default value, a maybe and a function, return the default if the maybe is a nothing; if its a just, apply the function to the value it contains and return the result.
Given a default value, a maybe and a function, return the default if the maybe is a nothing; if its a just, apply the function to the value it contains and return the result.
(maybe->seq m)
Given a maybe, return an empty seq if its nothing or a one-element seq with its value if its not.
Given a maybe, return an empty seq if its nothing or a one-element seq with its value if its not.
(maybe? v)
Return true in case of v
is instance
of Maybe monad.
Return true in case of `v` is instance of Maybe monad.
(nothing? v)
Returns true if v
is an instance
of Nothing
type or is nil.
Returns true if `v` is an instance of `Nothing` type or is nil.
(seq->maybe coll)
Given a collection, return a nothing if its empty or a just with its first element if its not.
Given a collection, return a nothing if its empty or a just with its first element if its not.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close