Parsing0.Diffing_with_keysWhen diffing lists where each element has a distinct key, we can refine the diffing patch by introducing two composite edit moves: swaps and moves.
Swaps exchange the position of two elements. Swap cost is set to 2 * change - epsilon. Moves change the position of one element. Move cost is set to delete + addition - epsilon.
When the cost delete + addition is greater than change and with those specific weights, the optimal patch with Swaps and Moves can be computed directly and cheaply from the original optimal patch.
let with_pos: list('a) => list(with_pos('a));type change('l, 'r, 'diff) = | Change(mismatch('l, 'r, 'diff))| Swap of {}| Move of {}| Insert of {}| Delete of {};This specialized version of changes introduces two composite changes: Move and Swap
let prefix: Format.formatter => change('l, 'r, 'diff) => unit;module Define: (D: Diffing.Defs with type eq := unit) => { ... };