precept.util
add-to-unique-index!
(add-to-unique-index! fact ks)
Prepreds :unique to keyseq path in second argument. Overwrites existing value and returns it if found.
any-Tuple?
(any-Tuple? x)
check-unique-conflict
(check-unique-conflict fact ks)
clara-tups->maps
(clara-tups->maps tups)
Takes seq of ms with keys :?e :?a :?v, joins on :?e and returns vec of ms (one m for each entity)
conflicting-logical-fact-error
(conflicting-logical-fact-error facts to-insert to-retract)
conform-insertions-and-retractions!
(conform-insertions-and-retractions! facts)
dissoc-in
(dissoc-in m [k & ks :as keys])
Dissociates an entry from a nested associative structure returning a new nested structure. keys is a sequence of keys. Any empty maps that result will not be present in the new structure.
entity-map->Tuples
(entity-map->Tuples m)
Transforms entity map to Tuple record {a1 v1 a2 v2 :db/id eid} -> [(Tuple eid a1 v1 t)…]
entity-Tuples->entity-maps
(entity-Tuples->entity-maps coll)
fact-index-path
(fact-index-path fact)
Returns path to store and access a fact in fact-index according to the fact’s cardinality, uniqueness
fact-index-paths
(fact-index-paths fact)
Returns all index paths for a given fact as [[]…]
find-sub-by-name
(find-sub-by-name name)
gen-Tuples-from-map
(gen-Tuples-from-map m)
get-index-of
(get-index-of coll x not-found-idx)
guid
(guid)
insert
(insert session facts)
Inserts facts from outside rule context. Accepts [e a v]
, [[e a v]...]
, {}
, [{}...]
, where {}
is a Datomic-style entity map
insert!
(insert! facts)
Insert facts logically within rule context
insert-unconditional!
(insert-unconditional! facts)
Insert facts unconditionally within rule context
insertable
(insertable x)
Arguments can be any mixture of vectors and records Ensures [], [[]…], Tuple, ’(Tuple …) conform to Tuple record instances.
key-by
(key-by f coll)
make-activation-group-fn
(make-activation-group-fn default-group)
Reads from optional third argument to rule. :super
- boolean :group
- keyword :salience
- number Rules marked :super
are given the highest priority.
make-activation-group-sort-fn
(make-activation-group-sort-fn groups default-group)
make-ancestors-fn
(make-ancestors-fn)
(make-ancestors-fn hierarchy)
(make-ancestors-fn hierarchy root-fact-type)
Returns a set. To be used when defining a session. Stored in atom for auto truth maintenance and schema enforcement.
map->tuples
(map->tuples m)
Transforms entity map to vector of tuples {a1 v1 a2 v2 :db/id eid} -> [[eid a1 v1]…]
map-of-refs?
(map-of-refs? schemas x)
Returns true if every k is db.type/ref according to a schema
next-fact-id!
(next-fact-id!)
record->map
(record->map x)
record->vec
(record->vec r)
remove-fact-from-index!
(remove-fact-from-index! fact)
(remove-fact-from-index! fact paths)
Removes fact from all indexed locations according to schema if the indexed value is identical to the fact
argument. Returns [bool...]
indicating successful removal from each indexed location.
remove-from-fact-index!
(remove-from-fact-index! fact ks)
Removes fact from single path in index, returning a retract instruction if an exact match was found
remove-rulegen-facts
(remove-rulegen-facts xs)
reset-fact-id!
(reset-fact-id!)
retract
(retract session facts)
Retract from outside rule context.
retract!
(retract! facts)
Wrapper around Clara’s retract!
. Use within RHS of rule only. Requires a fact that includes a fact-id produced by matching on a whole fact. e.g. ?fact
in [?fact <- [?e :attr ?v]
rulegen-fact-nses
rulegen-fact?
(rulegen-fact? a)
rules-in-ns
(rules-in-ns ns-sym)
schema-enforcement-dto
(schema-enforcement-dto inserted retracted index-path)
split-head-body
(split-head-body rule)
Takes macro body of a define and returns map of :head, :body
third
(third xs)
trace
(trace & args)
tuple-entity->hash-map-entity
(tuple-entity->hash-map-entity tuples)
Takes list of tuples for a single entity and returns single map
Tuples->maps
(Tuples->maps xs)
(Tuples->maps xs ancestry)
tuplize-into-vec
(tuplize-into-vec x)
Returns [[]…]. Arg may be {} [{}…] [] [[]…]
unknown-ancestry-error
(unknown-ancestry-error fact ancestry)
update-index!
(update-index! fact)
(update-index! fact ks)
Primary function that updates fact-index. Requires fact to index. Generates key-seq to path in index.
update-unique-index!
(update-unique-index! fact ks)
upsert-fact-index!
(upsert-fact-index! fact ks)
Writes value to path in ks. Returns existing fact to retract if overwriting.
upsert-unique-index!
(upsert-unique-index! fact ks)
vec->record
(vec->record vec)