mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Free is indeed a Monad.
This commit is contained in:
parent
97686157f3
commit
0a64dc8741
@ -17,4 +17,13 @@ public enum Free<A, B> {
|
||||
return .Roll(s.map { $0.map(transform) })
|
||||
}
|
||||
}
|
||||
|
||||
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) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user