hugr
hugr copied to clipboard
Implement TryHash on `Replacement`
For rewriting we must be able to detect (and discard) duplicate rewrites. A field-by-field equality for SimpleReplacement and Replacement is not what we want, as e.g. two rewrites only differing in the node labelling of the replacement graph are equivalent.
Ideally, try_hash would satisfy: r1(G) = r2(G) $\Leftrightarrow$ try_hash(r1) = try_hash(r2).
- it's fine if it's slightly weaker than that
- it's fine if hashing fails (because parts of r1/r2 are not hashable).
In those cases, deduplication would fail and that's ok.