From 889dab1df24ea932e29052171de6df7ecdc512b6 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 14 Oct 2015 10:52:27 -0400 Subject: [PATCH] Parameterized equality over Cofree. --- prototype/Doubt/Cofree.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) 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