diff --git a/prototype/Doubt/Algorithm.swift b/prototype/Doubt/Algorithm.swift index 752d6c472..945236067 100644 --- a/prototype/Doubt/Algorithm.swift +++ b/prototype/Doubt/Algorithm.swift @@ -77,4 +77,14 @@ public enum FreeAlgorithm { public func flatMap(transform: B -> FreeAlgorithm) -> FreeAlgorithm { return analysis(ifPure: transform, ifRoll: { .Roll($0.map { $0.flatMap(transform) }) }) } + + public func evaluate(equals: (A, A) -> Bool) -> B { + switch self { + case let .Pure(b): + return b + + case let .Roll(r): + return r.evaluate(equals).evaluate(equals) + } + } }