mirror of
https://github.com/github/semantic.git
synced 2025-01-02 12:23:08 +03:00
Express flatMap
with analysis
.
This commit is contained in:
parent
b4479e3854
commit
e4d0a41093
@ -32,12 +32,7 @@ public enum Free<A, B> {
|
||||
// MARK: Monad
|
||||
|
||||
public func flatMap<C>(@noescape transform: B -> Free<A, C>) -> Free<A, C> {
|
||||
switch self {
|
||||
case let .Pure(b):
|
||||
return transform(b)
|
||||
case let .Roll(s):
|
||||
return .Roll(s.map { $0.flatMap(transform) })
|
||||
}
|
||||
return analysis(ifPure: transform, ifRoll: { .Roll($0.map { $0.flatMap(transform) }) })
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user