Cascade.PoolSourceA mutable pool of CSS rules in cascade order, supporting near-constant merging and O(1) precedence queries.
This is the working representation for the incremental rule merger (after Hague, Lin & Hong, "CSS Minification via Constraint Solving", TOPLAS 2019):
Order_maintenance, so "does rule A come before rule B?" stays O(1) as rules are inserted and removed;pool.ml), so combining two rules is near-constant and a handle to an original rule still resolves to its current merged representative.Loop drives the greedy, priority-ordered merging over this pool; its interface documents that design and the simpler batch-fixpoint alternative.
A node is a stable handle to one live rule. Combining or removing a node invalidates it; the surviving node keeps the merged rule.
A mutable pool of rules.
A stable handle to one rule in the pool.
of_rules rs builds a pool holding rs in order.
to_rules t returns the live rules in cascade order.
rule n is n's current rule (resolving through any merges).
id n is a stable integer identity, unique in the pool and invariant under edits elsewhere, suitable for keying a priority queue of nodes.
set n r replaces n's rule in place (e.g. a rule whose declarations shrank after factoring).
val combine :
t ->
node ->
node ->
(Stylesheet.rule -> Stylesheet.rule -> Stylesheet.rule) ->
nodecombine t a b f merges b into a: the union-find classes are unioned, the surviving rule is f (rule a) (rule b) kept at a's position, and b is removed from the order. Returns the surviving node (a's identity). a must precede b.
insert_after t n r inserts a fresh rule r just after n (e.g. a shared factored rule) and returns its handle.
insert_before t n r inserts a fresh rule r just before n (e.g. a shared factored rule placed ahead of the run it was hoisted from).