mirror of
https://github.com/github/semantic.git
synced 2025-01-02 12:23:08 +03:00
FreeAlgorithm is a monad.
This commit is contained in:
parent
c70ab9e9a4
commit
fa3be5108e
@ -73,4 +73,8 @@ public enum FreeAlgorithm<A, B> {
|
||||
public func map<Other>(transform: B -> Other) -> FreeAlgorithm<A, Other> {
|
||||
return analysis(ifPure: transform >>> FreeAlgorithm<A, Other>.Pure, ifRoll: { .Roll($0.map { $0.map(transform) }) })
|
||||
}
|
||||
|
||||
public func flatMap<C>(transform: B -> FreeAlgorithm<A, C>) -> FreeAlgorithm<A, C> {
|
||||
return analysis(ifPure: transform, ifRoll: { .Roll($0.map { $0.flatMap(transform) }) })
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user