gleamunison/patch
Named update-propagation patches (Unison’s patch entity, our shape).
A patch is a named, content-addressed set of replacements old-ref → new-ref. Applying it rewrites every definition that references a replaced ref and re-hashes the result: the “rewrite dependents” wave, as data. Iterating to a fixpoint is the cascade.
Types
pub type Patch {
Patch(
name: String,
replacements: List(
#(identity.DefinitionRef, identity.DefinitionRef),
),
)
}
Constructors
-
Patch( name: String, replacements: List( #(identity.DefinitionRef, identity.DefinitionRef), ), )
pub type Rewrite {
Rewrite(
old_ref: identity.DefinitionRef,
new_ref: identity.DefinitionRef,
new_def: ast.Definition,
)
}
Constructors
-
Rewrite( old_ref: identity.DefinitionRef, new_ref: identity.DefinitionRef, new_def: ast.Definition, )
Values
pub fn add(
p: Patch,
old: identity.DefinitionRef,
new_ref: identity.DefinitionRef,
) -> Patch
pub fn apply_to_defs(
p: Patch,
defs: List(#(identity.DefinitionRef, ast.Definition)),
) -> ApplyResult
One propagation wave: rewrite every definition that references a replaced ref, re-hash each result. Idempotent for untouched defs.
pub fn dependents(
defs: List(#(identity.DefinitionRef, ast.Definition)),
target: identity.DefinitionRef,
) -> List(identity.DefinitionRef)
Which of these definitions reference target?
pub fn hash_of(p: Patch) -> identity.Hash
The patch is itself content-addressed: same replacements, same hash.
pub fn lookup(
p: Patch,
ref: identity.DefinitionRef,
) -> Result(identity.DefinitionRef, Nil)
pub fn rewrite_definition(
p: Patch,
def: ast.Definition,
) -> ast.Definition