(asks f & args)
Return the environment transformed by the function f, with extra args args.
Return the environment transformed by the function f, with extra args args.
(catch-error comp handler)
Try running the computation comp, calling the function handler if it is aborted by an error. The handler function will receive the error value as its argument.
Try running the computation comp, calling the function handler if it is aborted by an error. The handler function will receive the error value as its argument.
(censor f m)
Execute the computation m, returning the value it returns and modifying its log by the function f.
Execute the computation m, returning the value it returns and modifying its log by the function f.
(fail msg)
Abort the current computation, with the message msg (if supported).
Abort the current computation, with the message msg (if supported).
(lift inner)
Lift the computation inner up a level in the monad transformer stack.
Lift the computation inner up a level in the monad transformer stack.
(lift-m f)
(lift-m f m)
Transform a function a -> b into a monadic function m a -> m b.
Transform a function a -> b into a monadic function m a -> m b.
(listen comp)
Execute the computation comp, and return both its return value and the log it produces.
Execute the computation comp, and return both its return value and the log it produces.
(listens f m)
Execute the computation m, adding the result of calling f on its log to the its return value.
Execute the computation m, adding the result of calling f on its log to the its return value.
(local f comp)
Run the computation comp in an environment transformed by the function f.
Run the computation comp in an environment transformed by the function f.
(mdo & exprs)
Special syntax for monadic computations. An mdo
form contains one of three kinds of elements:
binding elements, which have the form destructure <- expression
;
plain elements, which are just expressions (except that they
cannot consist solely of the symbol <-
or the symbol let
;
let elements, which can be either
let destructure1 = expression1 destructure2 = expression2 ...
or
let [destructure1 expression1 destructure2 expression2 ...]
mdo
forms must end with a plain element.
These are rewritten into clojure.core/let expressions, and binding using >>= and anonymous functions. For instance (from treenumber.clj in examples):
(mdo num <- (number-node val) nt1 <- (number-tree left) nt2 <- (number-tree right) let [new-node (node num nt1 nt2)] (return new-node))
becomes
(>>= (number-node val) (fn [num] (>>= (number-tree left) (fn [nt1] (>>= (number-tree right) (fn [nt2] (let [new-node (node num nt1 nt2)] (return new-node))))))))
Note that plain elements can include arbitrary Clojure control or binding expressions (so let expressions don't actually need to be baked in); the above could also have been:
(mdo num <- (number-node val) nt1 <- (number-tree left) nt2 <- (number-tree right) (let [new-node (node num nt1 nt2)] (return new-node)))
Special syntax for monadic computations. An `mdo` form contains one of three kinds of elements: - binding elements, which have the form `destructure <- expression`; - plain elements, which are just expressions (except that they cannot consist solely of the symbol `<-` or the symbol `let`; - let elements, which can be either let destructure1 = expression1 destructure2 = expression2 ... or let [destructure1 expression1 destructure2 expression2 ...] `mdo` forms must end with a plain element. These are rewritten into clojure.core/let expressions, and binding using >>= and anonymous functions. For instance (from treenumber.clj in examples): (mdo num <- (number-node val) nt1 <- (number-tree left) nt2 <- (number-tree right) let [new-node (node num nt1 nt2)] (return new-node)) becomes (>>= (number-node val) (fn [num] (>>= (number-tree left) (fn [nt1] (>>= (number-tree right) (fn [nt2] (let [new-node (node num nt1 nt2)] (return new-node)))))))) Note that plain elements can include arbitrary Clojure control or binding expressions (so let expressions don't actually need to be baked in); the above could also have been: (mdo num <- (number-node val) nt1 <- (number-tree left) nt2 <- (number-tree right) (let [new-node (node num nt1 nt2)] (return new-node)))
(modify f & args)
Transform the current state by the function f, with extra args args.
Transform the current state by the function f, with extra args args.
(mplus left right)
Add the values of left and right. Required to be associative.
Add the values of left and right. Required to be associative.
The zero value for monadplus instances
The zero value for monadplus instances
(pass comp)
Execute the computation comp, which should return a value and a function, and return the value, applying the function to the log.
Execute the computation comp, which should return a value and a function, and return the value, applying the function to the log.
(put-state v)
Make the state be the value v.
Make the state be the value v.
(reify+ & signatures)
Like reify, except that one can conditionally decide what interfaces to implement, using "when".
The syntax of reify is extended to allow both
Protocol (method [] ...)
lines and also
(when condition Protocol2 (method2 [] ...))
If, at runtime, condition is truthy, the reified value will also support Protocol2.
Like reify, except that one can conditionally decide what interfaces to implement, using "when". The syntax of reify is extended to allow both Protocol (method [] ...) lines and also (when condition Protocol2 (method2 [] ...)) If, at runtime, condition is truthy, the reified value will also support Protocol2.
(tell w)
Add the value w to the log. Note that w must be a monoid.
Add the value w to the log. Note that w must be a monoid.
(throw-error e)
Abort the current computation, with the error e.
Abort the current computation, with the error e.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close