mirror of
https://github.com/github/semantic.git
synced 2025-01-02 12:23:08 +03:00
Evaluation of FreeAlgorithm.
This commit is contained in:
parent
fa3be5108e
commit
346a39fafc
@ -77,4 +77,14 @@ public enum FreeAlgorithm<A, B> {
|
||||
public func flatMap<C>(transform: B -> FreeAlgorithm<A, C>) -> FreeAlgorithm<A, C> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user