Liking cljdoc? Tell your friends :D

active.clojure.monad

Monad related functionality, particularly free monads.

Monad related functionality, particularly free monads.
raw docstring

and-finallyclj/s

(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.
sourceraw docstring

bind-exceptclj/s

(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.
sourceraw docstring

call-ccclj/s

(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]]
sourceraw docstring

call-cc-fclj/s≠

clj
(call-cc-f rec__3650__auto__)
(call-cc-f data__3651__auto__ v__3652__auto__)
cljs
(call-cc-f rec__3306__auto__)
(call-cc-f data__3307__auto__ v__3308__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]].
sourceraw docstring

call-cc?clj/s

(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]].
sourceraw docstring

combine-monad-command-configsclj/s

(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.
sourceraw docstring

execute-free-reader-state-exceptionclj/s

(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 commands
  • m is the computation to run
  • state 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].
sourceraw docstring

execute-monadicclj/s

(execute-monadic command-config m & [state])

Run monadic computation in an almighty monad, turning exceptions into Clojure exceptions. See [[run-monadic]].

  • 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].

Run monadic computation in an almighty monad, turning exceptions
into Clojure exceptions.  See [[`run-monadic`]].

- `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].
sourceraw docstring

free-bindclj/s

(free-bind mv f)

Bind/flatMap for the free monad.

Bind/flatMap for the free monad.
sourceraw docstring

free-bind-contclj/s≠

clj
(free-bind-cont rec__3650__auto__)
(free-bind-cont data__3651__auto__ v__3652__auto__)
cljs
(free-bind-cont rec__3306__auto__)
(free-bind-cont data__3307__auto__ v__3308__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]].
sourceraw docstring

free-bind-monadclj/s≠

clj
(free-bind-monad rec__3650__auto__)
(free-bind-monad data__3651__auto__ v__3652__auto__)
cljs
(free-bind-monad rec__3306__auto__)
(free-bind-monad data__3307__auto__ v__3308__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]].
sourceraw docstring

free-bind?clj/s

(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]].
sourceraw docstring

get-env-componentclj/s

(get-env-component name)

Retrieve a named component of a map-valued environment.

Retrieve a named component of a map-valued environment.
sourceraw docstring

get-state-componentclj/s

(get-state-component name)

Retrieve a named component of a map-valued state.

Retrieve a named component of a map-valued state.
sourceraw docstring

intermediate-result-resumeclj/s≠

clj
(intermediate-result-resume rec__3650__auto__)
(intermediate-result-resume data__3651__auto__ v__3652__auto__)
cljs
(intermediate-result-resume rec__3306__auto__)
(intermediate-result-resume data__3307__auto__ v__3308__auto__)

Lens for the resume field from a [[IntermediateResult]] record. See active.clojure.monad/make-intermediate-result.

Lens for the `resume` field from a [[IntermediateResult]] record. See [[active.clojure.monad/make-intermediate-result]].
sourceraw docstring

intermediate-result-thingclj/s≠

clj
(intermediate-result-thing rec__3650__auto__)
(intermediate-result-thing data__3651__auto__ v__3652__auto__)
cljs
(intermediate-result-thing rec__3306__auto__)
(intermediate-result-thing data__3307__auto__ v__3308__auto__)

Lens for the thing field from a [[IntermediateResult]] record. See active.clojure.monad/make-intermediate-result.

Lens for the `thing` field from a [[IntermediateResult]] record. See [[active.clojure.monad/make-intermediate-result]].
sourceraw docstring

intermediate-result?clj/s

(intermediate-result? thing)

Is object a IntermediateResult record? See active.clojure.monad/make-intermediate-result.

Is object a `IntermediateResult` record? See [[active.clojure.monad/make-intermediate-result]].
sourceraw docstring

make-free-bindclj/s

(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]]
sourceraw docstring

make-intermediate-resultclj/s

(make-intermediate-result thing resume)

Construct a IntermediateResult (Possible return value for run-monadic, when monadic program wants to pause calculation. Call intermediate-result-resume with a value [[v]] to resume the paused calculation with [[v]].) record.

thing: access via active.clojure.monad/intermediate-result-thing resume: access via active.clojure.monad/intermediate-result-resume

Construct a `IntermediateResult` (Possible return value
  for [[run-monadic]], when monadic program wants to [[pause]]
  calculation.  Call [[intermediate-result-resume]] with a value [[v]] to resume
  the paused calculation with [[v]].) record.

`thing`: access via [[active.clojure.monad/intermediate-result-thing]]
`resume`: access via [[active.clojure.monad/intermediate-result-resume]]
sourceraw docstring

make-monad-command-configclj/s

(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]]
sourceraw docstring

monad-command-config-envclj/s≠

clj
(monad-command-config-env rec__3650__auto__)
(monad-command-config-env data__3651__auto__ v__3652__auto__)
cljs
(monad-command-config-env rec__3306__auto__)
(monad-command-config-env data__3307__auto__ v__3308__auto__)

reader-monad initial environment represented as a mergable map

reader-monad initial environment represented as a mergable map
sourceraw docstring

monad-command-config-run-commandclj/s≠

clj
(monad-command-config-run-command rec__3650__auto__)
(monad-command-config-run-command data__3651__auto__ v__3652__auto__)
cljs
(monad-command-config-run-command rec__3306__auto__)
(monad-command-config-run-command data__3307__auto__ v__3308__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)
sourceraw docstring

monad-command-config-stateclj/s≠

clj
(monad-command-config-state rec__3650__auto__)
(monad-command-config-state data__3651__auto__ v__3652__auto__)
cljs
(monad-command-config-state rec__3306__auto__)
(monad-command-config-state data__3307__auto__ v__3308__auto__)

state-monad initial state represented as a mergable map

state-monad initial state represented as a mergable map
sourceraw docstring

monad-command-config?clj/s

(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]].
sourceraw docstring

monadicclj/smacro

(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 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))
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))
sourceraw docstring

null-monad-command-configclj/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.
sourceraw docstring

pauseclj/s

(pause thing)

Construct a Pause (Accepts a arbitrary value thing that can be used to mark the type of the [[IntermediateResult]]. pause can be used to pause the current monadic calculation and return an [[Intermediate Result]].) record.

thing: access via active.clojure.monad/pause-thing

Construct a `Pause` (Accepts a arbitrary value `thing` that can be used
  to mark the type of the [[IntermediateResult]].  `pause` can be used to pause
  the current monadic calculation and return an [[Intermediate Result]].) record.

`thing`: access via [[active.clojure.monad/pause-thing]]
sourceraw docstring

pause-thingclj/s≠

clj
(pause-thing rec__3650__auto__)
(pause-thing data__3651__auto__ v__3652__auto__)
cljs
(pause-thing rec__3306__auto__)
(pause-thing data__3307__auto__ v__3308__auto__)

Lens for the thing field from a [[Pause]] record. See active.clojure.monad/pause.

Lens for the `thing` field from a [[Pause]] record. See [[active.clojure.monad/pause]].
sourceraw docstring

pause?clj/s

(pause? thing)

Is object a Pause record? See active.clojure.monad/pause.

Is object a `Pause` record? See [[active.clojure.monad/pause]].
sourceraw docstring

put-state-component!clj/s

(put-state-component! name value)

Set a named component of a map-valued state.

Set a named component of a map-valued state.
sourceraw docstring

reduce-mclj/s

(reduce-m m-fn acc xs)

Like reduce, but takes a monadic function m-fn for folding the results. Returns the final result.

Like reduce, but takes a monadic function `m-fn` for folding the
results.  Returns the final result.
sourceraw docstring

reified?clj/s

(reified? m)

Checks whether a monadic command is reified.

Checks whether a monadic command is reified.
sourceraw docstring

reify-asclj/s

(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.

Note that reify-as does not work on binds like for example composed monadic programs with monadic. Because the reification meta data sticks at the first bind that is handled by run-monadic and friends above -- and not by the command runners that are mocked away by the mock runner. To improve on that we might either need to add the awareness of mocking into run-monadic and friends above or copy their implementation into to mock namespace and include mocking of binds there.

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.

Note that `reify-as` does not work on `bind`s like for example composed
monadic programs with `monadic`.  Because the reification meta data sticks at
the first `bind` that is handled by `run-monadic` and friends above -- and not
by the command runners that are mocked away by the mock runner.  To improve on
that we might either need to add the awareness of mocking into `run-monadic`
and friends above or copy their implementation into to `mock` namespace and
include mocking of binds there.
sourceraw docstring

reify-commandclj/s

(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.
sourceraw docstring

returnclj/s

source

run-free-reader-state-exceptionclj/s

(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 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 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]
sourceraw docstring

run-monadicclj/s

(run-monadic 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 and pause.

  • 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 a monadic computation in an almighty monad.  Same as
[[`run-free-reader-state-exception`]] with the addition of `call-cc`
and `pause`.

- `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]
sourceraw docstring

run-no-commandsclj/s

(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.
sourceraw docstring

scan-mclj/s

(scan-m m-fn acc xs)

Like reduce-m, but returns a sequence of each intermediate result. The actual result is the last element of that sequence.

(last (scan-m f zero xs)) = (reduce-m f zero xs) holds.

Like `reduce-m`, but returns a sequence of each intermediate
result.  The actual result is the last element of that sequence.

`(last (scan-m f zero xs)) = (reduce-m f zero xs)` holds.
sourceraw docstring

sequclj/s

(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.
sourceraw docstring

sequ_clj/s

(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.
sourceraw docstring

throw-illegal-argument-exceptionclj/s

(throw-illegal-argument-exception msg)
source

unknown-commandclj/s

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.
sourceraw docstring

update-state-component!clj/s

(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.
sourceraw docstring

with-env-componentclj/s

(with-env-component key f m)

Transform a keyed component of a map-valued environment.

Transform a keyed component of a map-valued environment.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close