diff --git a/prototype/Doubt/Cofree.swift b/prototype/Doubt/Cofree.swift index 28b56ecea..17959ac7a 100644 --- a/prototype/Doubt/Cofree.swift +++ b/prototype/Doubt/Cofree.swift @@ -65,4 +65,14 @@ extension Cofree { } +// MARK: - Equality + +extension Cofree { + public static func equals(annotation annotation: (B, B) -> Bool, leaf: (A, A) -> Bool)(_ left: Cofree, _ right: Cofree) -> Bool { + return annotation(left.extract, right.extract) + && Syntax.equals(ifLeaf: leaf, ifRecur: Cofree.equals(annotation: annotation, leaf: leaf))(left.unwrap, right.unwrap) + } +} + + import Prelude