diff --git a/prototype/Doubt/Algorithm.swift b/prototype/Doubt/Algorithm.swift
index 316d45c0c..ff1c650d2 100644
--- a/prototype/Doubt/Algorithm.swift
+++ b/prototype/Doubt/Algorithm.swift
@@ -94,3 +94,14 @@ extension FreeAlgorithm where A: Equatable {
return evaluate(==)
}
}
+
+
+func diff(a: Fix, _ b: Fix) -> FreeAlgorithm>> {
+ switch (a.out, b.out) {
+ case let (.Keyed(a), .Keyed(b)):
+ return .Roll(.ByKey(a, b, Syntax.Keyed >>> Free.Roll >>> FreeAlgorithm.Pure))
+
+ default:
+ return .Roll(.Recursive(a, b, FreeAlgorithm.Pure))
+ }
+}