mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Switch in Free.map
directly.
This commit is contained in:
parent
02af784036
commit
4f16ce62c3
@ -91,7 +91,12 @@ public enum Free<Leaf, Annotation, Value>: CustomDebugStringConvertible {
|
|||||||
// MARK: Functor
|
// MARK: Functor
|
||||||
|
|
||||||
public func map<C>(@noescape transform: Value throws -> C) rethrows -> Free<Leaf, Annotation, C> {
|
public func map<C>(@noescape transform: Value throws -> C) rethrows -> Free<Leaf, Annotation, C> {
|
||||||
return try analysis(ifPure: { try .Pure(transform($0)) }, ifRoll: { try .Roll($0, $1.map { try $0.map(transform) }) })
|
switch self {
|
||||||
|
case let .Pure(a):
|
||||||
|
return try .Pure(transform(a))
|
||||||
|
case let .Roll(annotation, syntax):
|
||||||
|
return try .Roll(annotation, syntax.map { try $0.map(transform) })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user