(step* forms & {:keys [restrict]})(stepdef k & forms)Defines a spec that validates a step as-per the transitions specified in forms. A step is a tuple of [state action state'].
Forms are of the shape:
(:in-between/state ::drink (:in-between/state :empty/state) ::fill (:in-between/state :full/state))
where all keywords are registered specs.
Optionally, the second argument can be a map of options that accepts the keys :extra-defs and :data-def, detailed below.
:extra-defs - A vector of bindings of key => step restriction key.
This outputs the extra defs as specs with the specified restriction.
Restriction keys are as follows:
:no-state' - [state action] :only-states - [state state'] :only-action - [action]
For example:
(stepdef ::step {:extra-defs [::state-action :no-state' ::states :only-states ::action :only-action]} (:in-between/state ::drink (:in-between/state :empty/state) ::fill (:in-between/state :full/state)) (:empty/state ::fill (:in-between/state)) (:full/state ::drink (:in-between/state)))
will define ::step, ::state-action, ::states, and ::action specs.
:data-def - A symbol that will define a map representation of forms.
For example:
(stepdef ::step {:data-def step-data} (:in-between/state ::drink (:in-between/state :empty/state) ::fill (:in-between/state :full/state)) (:empty/state ::fill (:in-between/state)) (:full/state ::drink (:in-between/state)))
will define both the ::step spec and
(def step-data {:in-between/state {::drink #{:in-between/state :empty/state} ::fill #{:in-between/state :full/state}} :empty/state {::fill #{:in-between/state}} :full/state {::drink #{:in-between/state}}})
Defines a spec that validates a step as-per the transitions
specified in forms. A step is a tuple of [state action state'].
Forms are of the shape:
(:in-between/state
::drink (:in-between/state :empty/state)
::fill (:in-between/state :full/state))
where all keywords are registered specs.
Optionally, the second argument can be a map of options that accepts the
keys :extra-defs and :data-def, detailed below.
:extra-defs - A vector of bindings of key => step restriction key.
This outputs the extra defs as specs with the specified restriction.
Restriction keys are as follows:
:no-state' - [state action]
:only-states - [state state']
:only-action - [action]
For example:
(stepdef ::step
{:extra-defs [::state-action :no-state'
::states :only-states
::action :only-action]}
(:in-between/state
::drink (:in-between/state :empty/state)
::fill (:in-between/state :full/state))
(:empty/state
::fill (:in-between/state))
(:full/state
::drink (:in-between/state)))
will define ::step, ::state-action, ::states, and ::action specs.
:data-def - A symbol that will define a map representation of forms.
For example:
(stepdef ::step
{:data-def step-data}
(:in-between/state
::drink (:in-between/state :empty/state)
::fill (:in-between/state :full/state))
(:empty/state
::fill (:in-between/state))
(:full/state
::drink (:in-between/state)))
will define both the ::step spec and
(def step-data
{:in-between/state
{::drink #{:in-between/state :empty/state}
::fill #{:in-between/state :full/state}}
:empty/state
{::fill #{:in-between/state}}
:full/state
{::drink #{:in-between/state}}})
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |