Namespace for constructing and using realms to describe the shape of data.
Also has contains?
for dispatch on realms.
It also defines, via the compile
function, a shorthand
notation for realms, that is available in most places a realm is expected,
i.e. in realm combinators and realm syntax.
Namespace for constructing and using realms to describe the shape of data. Also has [[contains?]] for dispatch on realms. It also defines, via the [[compile]] function, a shorthand notation for realms, that is available in most places a realm is expected, i.e. in realm combinators and realm syntax.
Realm containing all Clojure values.
Realm containing all Clojure values.
(compile shorthand)
Compile a realm shorthand into a realm object.
This is called by most realm constructors and macros that generate realms from source code.
Shorthand notation includes:
sequence-of
that realm.tuple
of those realms.set-of
that realm.map-of
of those realms.map-with-keys
of its keys and value realms.active.data.record
or [[active.data.realm-record]] denote the corresponding record realm.active.data.struct
denote the corresponding record realm.Compile a realm shorthand into a realm object. This is called by most realm constructors and macros that generate realms from source code. Shorthand notation includes: * A one-element vector containing a realm denotes a [[sequence-of]] that realm. * Any vector that does not have length 1 containing realms denotes a [[tuple]] of those realms. * A one-element set containing a realm denotes a [[set-of]] that realm. * A map containing one entry, whose key and value are both realms, denotes a [[map-of]] of those realms. * Any other map denotes a [[map-with-keys]] of its keys and value realms. * Record types from [[active.data.record]] or [[active.data.realm-record]] denote the corresponding record realm. * Struct types from [[active.data.struct]] denote the corresponding record realm.
(contains? realm x)
Does a realm contain a value?
Note this is intended for dispatch, not validation:
It only does a shallow check that runs in constant time, and does not perform full validation.
Does a realm contain a value? Note this is intended for dispatch, not validation: It only does a shallow check that runs in constant time, and does not perform full validation.
(delay realm-expression)
Delay the evaluation of a realm.
Its operand must be an expression evaluating to a realm.
This is for generating recursive realms.
Delay the evaluation of a realm. Its operand must be an expression evaluating to a realm. This is for generating recursive realms.
(enum & values)
Creates a realm containing the values in values
.
Creates a realm containing the values in `values`.
(field name realm getter)
Create a record-field descriptor.
name
is a symbol naming the fieldrealm
is the realm for the field valuesgetter
is the selector for that fieldCreate a record-field descriptor. * `name` is a symbol naming the field * `realm` is the realm for the field values * `getter` is the selector for that field
(from-predicate desc pred)
Make a realm from a predicate and a prescription.
Don't use this if you don't have to, as the predicate is by its nature opaque and not suitable for e.g. generation.
Make a realm from a predicate and a prescription. Don't use this if you don't have to, as the predicate is by its nature opaque and not suitable for e.g. generation.
(function & shorthand)
Shorthand for function realms with a single arity.
Here are the different forms:
(function r1 r2 r3 & (rs) -> r)
for rest arguments(function r1 r2 r3 & [rr1 rr2]) -> r)
for 2 optional args(function r1 r2 r3 & {:a ra :b rb :c rc} -> r)
for optional keyword argsShorthand for function realms with a single arity. Here are the different forms: * `(function r1 r2 r3 -> r) for fixed arity * `(function r1 r2 r3 & (rs) -> r)` for rest arguments * `(function r1 r2 r3 & [rr1 rr2]) -> r)` for 2 optional args * `(function r1 r2 r3 & {:a ra :b rb :c rc} -> r)` for optional keyword args
(function-cases & cases)
Create a realm for functions with several cases.
Typically applied to the return values of function
.
Create a realm for functions with several cases. Typically applied to the return values of `function`.
(integer-from from)
Create a realm for integers above a lower bound.
from
is inclusive.
Create a realm for integers above a lower bound. `from` is inclusive.
(integer-from-to from to)
Create realm for integer range.
from
and to
are both inclusive.
Create realm for integer range. `from` and `to` are both inclusive.
(integer-to to)
Create a realm for integers below an upper bound.
to
is inclusive.
Create a realm for integers below an upper bound. `to` is inclusive.
(intersection realm)
(intersection realm1 realm2)
(intersection realm1 realm2 & realms-rest)
Creates an intersection realm of its arguments.
The returned realm contains the values that are contained by all the argument realms.
Creates an intersection realm of its arguments. The returned realm contains the values that are contained by all the argument realms.
(map-of key-realm value-realm)
Create realm containing uniform maps, where keys and value are each from a fixed realm.
key-realm
is the realm of the keys,
value-realm
is the realm of the values.
Create realm containing uniform maps, where keys and value are each from a fixed realm. `key-realm` is the realm of the keys, `value-realm` is the realm of the values.
(map-with-keys keys-realm-map)
Create realm containing certain keys and a different realm for the value associated with each key.
keys-realm-map
is map from keys to the realms of their values.
Create realm containing certain keys and a different realm for the value associated with each key. `keys-realm-map` is map from keys to the realms of their values.
(map-with-tag key value)
Create realm for maps containing a tag.
I.e. a certain key
mapping to a certain value
.
Create realm for maps containing a tag. I.e. a certain `key` mapping to a certain `value`.
(named name realm)
Name a realm.
Returns a realm that describes the same values as realm
.
The name intended is for printing in polymorphic realms.
Name a realm. Returns a realm that describes the same values as `realm`. The name intended is for printing in polymorphic realms.
Realm containing all natural numbers.
I.e. all integers >= 0.
Realm containing all natural numbers. I.e. all integers >= 0.
(real-range lr1 lr2)
(real-range clusive-left left right clusive-right)
Create a realm containg a real range.
With the four-argument version, the four arguments specify:
clusive-left
is one of the keywords :in
, :ex
, specifying
whether the lower bound is inclusive or exclusive.left
is the lower boundright
is the upper boundclusive-right
is one of the keywords :in
, :ex
, specifying
whether the upper bound is inclusive or exclusive.The two-argument version can be called as follows:
(real-range :in lower-bound)
for a real range with inclusive lower bound(real-range :ex lower-bound)
for a real range with exclusive lower bound(real-range upper-bound :in)
for a real range with inclusive upper bound(real-range upper-bound :ex)
for a real range with exclusive upper boundCreate a realm containg a real range. With the four-argument version, the four arguments specify: * `clusive-left` is one of the keywords `:in`, `:ex`, specifying whether the lower bound is inclusive or exclusive. * `left` is the lower bound * `right` is the upper bound * `clusive-right` is one of the keywords `:in`, `:ex`, specifying whether the upper bound is inclusive or exclusive. The two-argument version can be called as follows: * `(real-range :in lower-bound)` for a real range with inclusive lower bound * `(real-range :ex lower-bound)` for a real range with exclusive lower bound * `(real-range upper-bound :in)` for a real range with inclusive upper bound * `(real-range upper-bound :ex)` for a real range with exclusive upper bound
(record name constructor pred fields)
Create a record realm.
name
is a symbol naming the recordconstructor
is a positional constructorpred
is a prediucate for the recordfields
is a sequence of field
sCreate a record realm. * `name` is a symbol naming the record * `constructor` is a positional constructor * `pred` is a prediucate for the record * `fields` is a sequence of [[field]]s
(restricted realm pred predicate-description)
Restrict a realm with a predicate.
The resulting realm contains only those values of the input
realm for which pred
(a unary function) returns a true value.
Only use this if you have to, as it forfeits inspectability.
Restrict a realm with a predicate. The resulting realm contains only those values of the input realm for which `pred` (a unary function) returns a true value. Only use this if you have to, as it forfeits inspectability.
(sequence-of realm)
Create realm containing uniform sequences.
realm
is the realm of the elements of the sequences.
Create realm containing uniform sequences. `realm` is the realm of the elements of the sequences.
(set-of realm)
Create realm containing uniform sets.
realm
is the realm of the elements of the sets.
Create realm containing uniform sets. `realm` is the realm of the elements of the sets.
(tuple & realms)
Create realm for tuples.
These are sequences of a fixed length.
realms
is a sequence of the realms of the elements
of the tuples.
Create realm for tuples. These are sequences of a fixed length. `realms` is a sequence of the realms of the elements of the tuples.
(with-metadata realm key data)
Return a new realm with added or changed metadata for one key.
Return a new realm with added or changed metadata for one key.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close