Monad related functionality, particularly free monads.
Monad related functionality, particularly free monads.
(and-finally m final-m)
Execute m, and always final-m, no matter if an exception occurs or not.
Execute m, and always final-m, no matter if an exception occurs or not.
(bind-except m handler f)
Evaluate m, and if an exception occurs continue with (handler exception), otherwise with (f value-of-m). Note that neither the handler result is to f, nor exceptions are caught in f.
Evaluate m, and if an exception occurs continue with (handler exception), otherwise with (f value-of-m). Note that neither the handler result is to f, nor exceptions are caught in f.
(call-cc f)
Construct a CallCC
(Accepts a function f
with one argument that
returns a monadic value. call-cc
packages the current continuation as a
function and passes it as an argument to f
. If the function is called
later, the continuation of that call will be discarded and instead reinstate
the continuation that was in effect when the function was created.) record.
f
: access via active.clojure.monad/call-cc-f
Construct a `CallCC` (Accepts a function `f` with one argument that returns a monadic value. `call-cc` packages the current continuation as a function and passes it as an argument to `f`. If the function is called later, the continuation of that call will be discarded and instead reinstate the continuation that was in effect when the function was created.) record. `f`: access via [[active.clojure.monad/call-cc-f]]
(call-cc-f rec__2590__auto__)
(call-cc-f data__2591__auto__ v__2592__auto__)
(call-cc-f rec__5416__auto__)
(call-cc-f data__5417__auto__ v__5418__auto__)
Lens for the f
field from a CallCC
record. See active.clojure.monad/call-cc
.
Lens for the `f` field from a [[CallCC]] record. See [[active.clojure.monad/call-cc]].
(call-cc? thing)
Is object a CallCC
record? See active.clojure.monad/call-cc
.
Is object a `CallCC` record? See [[active.clojure.monad/call-cc]].
Accepts a function f
with one argument that
returns a monadic value. call-cc
packages the current continuation as a
function and passes it as an argument to f
. If the function is called
later, the continuation of that call will be discarded and instead reinstate
the continuation that was in effect when the function was created.
Accepts a function `f` with one argument that returns a monadic value. `call-cc` packages the current continuation as a function and passes it as an argument to `f`. If the function is called later, the continuation of that call will be discarded and instead reinstate the continuation that was in effect when the function was created.
(combine-monad-command-configs & mccs)
Combine a sequence of monad-command configs into one. The earlier entries have precedence.
Combine a sequence of monad-command configs into one. The earlier entries have precedence.
(execute-free-reader-state-exception command-config m & [state])
Run monadic computation in a reader-state-exception monad, turning exceptions into Clojure exceptions.
command-config
is the configuration object for running commandsm
is the computation to runstate
is an optional initial state (from a previous run)Returns [result state].
Run monadic computation in a reader-state-exception monad, turning exceptions into Clojure exceptions. - `command-config` is the configuration object for running commands - `m` is the computation to run - `state` is an optional initial state (from a previous run) Returns [result state].
(execute-monadic-swiss-army command-config m & [state])
Run monadic computation in an almighty monad, turning exceptions into Clojure exceptions. See [[`run-monadic-swiss-army]].
command-config
is the configuration object for running commandsm
is the computation to runstate
is an optional initial state (from a previous run)Returns [result state].
Run monadic computation in an almighty monad, turning exceptions into Clojure exceptions. See [[`run-monadic-swiss-army]]. - `command-config` is the configuration object for running commands - `m` is the computation to run - `state` is an optional initial state (from a previous run) Returns [result state].
(free-bind mv f)
Bind/flatMap for the free monad.
Bind/flatMap for the free monad.
(free-bind-cont rec__2590__auto__)
(free-bind-cont data__2591__auto__ v__2592__auto__)
(free-bind-cont rec__5416__auto__)
(free-bind-cont data__5417__auto__ v__5418__auto__)
Lens for the cont
field from a Bind
record. See active.clojure.monad/make-free-bind
.
Lens for the `cont` field from a [[Bind]] record. See [[active.clojure.monad/make-free-bind]].
(free-bind-monad rec__2590__auto__)
(free-bind-monad data__2591__auto__ v__2592__auto__)
(free-bind-monad rec__5416__auto__)
(free-bind-monad data__5417__auto__ v__5418__auto__)
Lens for the monad
field from a Bind
record. See active.clojure.monad/make-free-bind
.
Lens for the `monad` field from a [[Bind]] record. See [[active.clojure.monad/make-free-bind]].
(free-bind? thing)
Is object a Bind
record? See active.clojure.monad/make-free-bind
.
Is object a `Bind` record? See [[active.clojure.monad/make-free-bind]].
(get-env-component name)
Retrieve a named component of a map-valued environment.
Retrieve a named component of a map-valued environment.
(get-state-component name)
Retrieve a named component of a map-valued state.
Retrieve a named component of a map-valued state.
(make-free-bind monad cont)
Construct a Bind
record.
monad
: access via active.clojure.monad/free-bind-monad
cont
: access via active.clojure.monad/free-bind-cont
Construct a `Bind` record. `monad`: access via [[active.clojure.monad/free-bind-monad]] `cont`: access via [[active.clojure.monad/free-bind-cont]]
(make-monad-command-config run-command env state)
Construct a MonadCommandConfig
(Configuration for supporting a set of monad commands.) record.
run-command
: access via active.clojure.monad/monad-command-config-run-command
env
: access via active.clojure.monad/monad-command-config-env
state
: access via active.clojure.monad/monad-command-config-state
Construct a `MonadCommandConfig` (Configuration for supporting a set of monad commands.) record. `run-command`: access via [[active.clojure.monad/monad-command-config-run-command]] `env`: access via [[active.clojure.monad/monad-command-config-env]] `state`: access via [[active.clojure.monad/monad-command-config-state]]
(monad-command-config-env rec__2590__auto__)
(monad-command-config-env data__2591__auto__ v__2592__auto__)
(monad-command-config-env rec__5416__auto__)
(monad-command-config-env data__5417__auto__ v__5418__auto__)
reader-monad initial environment represented as a mergable map
reader-monad initial environment represented as a mergable map
(monad-command-config-run-command rec__2590__auto__)
(monad-command-config-run-command data__2591__auto__ v__2592__auto__)
(monad-command-config-run-command rec__5416__auto__)
(monad-command-config-run-command data__5417__auto__ v__5418__auto__)
run-command
:: run-any env state comp -> (| [(| exception-value? val) state] unknown-command)
Where run-any
is a function for running any monad command of the signature
`env state comp -> (| [(| exception-value? val) state] unknown-command)
`run-command` :: run-any env state comp -> (| [(| exception-value? val) state] unknown-command) Where `run-any` is a function for running any monad command of the signature `env state comp -> (| [(| exception-value? val) state] unknown-command)
(monad-command-config-state rec__2590__auto__)
(monad-command-config-state data__2591__auto__ v__2592__auto__)
(monad-command-config-state rec__5416__auto__)
(monad-command-config-state data__5417__auto__ v__5418__auto__)
state-monad initial state represented as a mergable map
state-monad initial state represented as a mergable map
(monad-command-config? thing)
Is object a MonadCommandConfig
record? See active.clojure.monad/make-monad-command-config
.
Is object a `MonadCommandConfig` record? See [[active.clojure.monad/make-monad-command-config]].
Configuration for supporting a set of monad commands.
Configuration for supporting a set of monad commands.
(monadic & ?stmts)
Construct a monadic computation.
The syntax is (monadic <stmt> ...)
where <stmt>
is one of the following:
[<pat> <exp> ...]
which creates monadic bindings(let <bindings>)
which creates regular bindingsExample:
(monadic [first (ask "what's your first name?")
last (ask "what's your last name?")]
(let [s (str "Hello, " first " " last)])
(tell s))
Construct a monadic computation. The syntax is `(monadic <stmt> ...)` where `<stmt>` is one of the following: - `[<pat> <exp> ...]` which creates monadic bindings - `(let <bindings>)` which creates regular bindings - anything else is just a regular expression, expected to yield a monadic value. Example: (monadic [first (ask "what's your first name?") last (ask "what's your last name?")] (let [s (str "Hello, " first " " last)]) (tell s))
(null-monad-command-config env state)
Monad command-configuration with no commands except for reader/state/exception.
Monad command-configuration with no commands except for reader/state/exception.
(put-state-component! name value)
Set a named component of a map-valued state.
Set a named component of a map-valued state.
(reified? m)
Checks whether a monadic command is reified.
Checks whether a monadic command is reified.
(reify-as m reification)
Adds reification
meta data to m
that helps utilities (like the
mock runner for tests), to reify a composed command as something
comparable (and printable), for cases where the command itself is
not; e.g. it includes a bind
inside. See [[reify-command
]] to
extract the meta data again.
Adds `reification` meta data to `m` that helps utilities (like the mock runner for tests), to reify a composed command as something comparable (and printable), for cases where the command itself is not; e.g. it includes a `bind` inside. See [[`reify-command`]] to extract the meta data again.
(reify-command m)
Return the reification object of m
, if one was added
with [[reify-as
]], or m itself otherwise.
Return the reification object of `m`, if one was added with [[`reify-as`]], or m itself otherwise.
(run-free-reader-state-exception command-config m & [state])
Run monadic computation in a reader-state-exception monad.
command-config
is the configuration object for running commandsm
is the computation to runstate
an optional initial state (from a previous run) that is merged
into the one from command-config
Returns [result state]
Run monadic computation in a reader-state-exception monad. - `command-config` is the configuration object for running commands - `m` is the computation to run - `state` an optional initial state (from a previous run) that is merged into the one from `command-config` Returns [result state]
(run-monadic-swiss-army command-config m & [state])
Run a monadic computation in an almighty monad. Same as
[[run-free-reader-state-exception
]] with the addition of call-cc
.
command-config
is the configuration object for running commandsm
is the computation to runstate
an optional initial state (from a previous run) that is merged
into the one from command-config
Returns [result state]
Run a monadic computation in an almighty monad. Same as [[`run-free-reader-state-exception`]] with the addition of `call-cc`. - `command-config` is the configuration object for running commands - `m` is the computation to run - `state` an optional initial state (from a previous run) that is merged into the one from `command-config` Returns [result state]
(run-no-commands run-any env state m)
For use in make-monad-command-config
when there are no commands.
For use in [[make-monad-command-config]] when there are no commands.
(sequ ms)
Evaluate each action in the sequence from left to right, and collect the results.
Evaluate each action in the sequence from left to right, and collect the results.
(sequ_ ms)
Evaluate each action in the sequence from left to right, and ignore the results.
Evaluate each action in the sequence from left to right, and ignore the results.
Marker that command functions can return to signal they don't recognize a command.
Marker that command functions can return to signal they don't recognize a command.
(update-state-component! name f & args)
Calls f with the current value of the component and puts back return value as the new component.
Calls f with the current value of the component and puts back return value as the new component.
(with-env-component key f m)
Transform a keyed component of a map-valued environment.
Transform a keyed component of a map-valued environment.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close