ShotUn.Trace (shot_un v0.1.9)

Copy Markdown View Source

Decision-tree trace produced by ShotUn.unify/3, ShotUn.match/2 and ShotUn.pattern_unify/2 when invoked with vis: true. Each node records the rule applied, the resulting work-list, the accumulated substitutions and the deferred flex-flex pairs (pre-formatted as strings). Render the tree with ShotUn.Trace.Mermaid.render/2.

The traces returned by the public entry points are pre-pruned to the paths from the root to a :solution leaf — failed branches and dead-end intermediate steps are dropped. Use prune_to_solutions/1 directly if you have an unpruned trace from a lower-level call.

Summary

Functions

Returns a trace that retains only the nodes lying on a path from the root to a :solution leaf. The root node is always preserved (even if no solution was reached) so the diagram still shows the initial state.

Types

algorithm()

@type algorithm() :: :pre_unification | :matching | :pattern

t()

@type t() :: %ShotUn.Trace{algorithm: algorithm(), root: ShotUn.Trace.Node.t() | nil}

Functions

prune_to_solutions(trace)

@spec prune_to_solutions(t()) :: t()

Returns a trace that retains only the nodes lying on a path from the root to a :solution leaf. The root node is always preserved (even if no solution was reached) so the diagram still shows the initial state.