typed.clj.spec.subtype
A subtyping lattice for specs.
Usage:
See `direct-subtypes` and `direct-subtypes`.
Extending:
For new predicates, see `register-subs`.
For heterogeneous ops like collections and regexes,
see `direct-sub-op`.
args-direct-subs*
(args-direct-subs* process-args fcat args)
direct-sub-op
multimethod
Dispatches on the operation of a spec form (a `seq?`)
and returns a set of direct subtypes or supertypes of
the spec. Do not include the spec itself.
Map of options helps abstract over computing sub or supertypes.
The implementor can usually assume they are computing subtypes
(ie., the implementation will be called from a covariant context).
For finer control, see :direction.
Takes a map of options:
- :direction :sub if computing covariantly (should return subtypes),
:sup if computing contravariantly (should return supertypes)
- :direct-subtypes A function returning the set of direct subtypes
of the spec argument in a covariant context.
- :direct-supertypes A function returning the set of direct subtypes
of the spec argument in a covariant context.
direct-subtypes
(direct-subtypes upper)
Returns the set of known direct subtypes of upper, a spec form.
direct-supertypes
(direct-supertypes lower)
Returns the set of known direct subtypes of upper, a spec form.
register-distinct
(register-distinct s1 s2)
Register s1 and s2 as representing distinct values.
register-distincts
(register-distincts & specs)
Registers every combination of specs as distinct.
register-sub
(register-sub s1 s2)
Register s1 as an immediate subtype to s2.
register-subs
(register-subs & specs)
For each adjacent pair of specs s1 s2, registers
s1 as a subtype of s2. If either is a vector, registers
each s1 as a subtype of each s2.
rels
(rels)
Returns a map from relation name to value.
Relations:
::sub-rel (Map SpecForm (Set SpecForm))
Maps a spec to all its immediate supertypes
::sup-rel (Map SpecForm (Set SpecForm))
Maps a spec to all its immediate subtypes
::distinct-rel (Map SpecForm (Set SpecForm))
Maps a spec to known specs that represent distinct values.