mirror of
https://github.com/github/semantic.git
synced 2024-11-29 11:02:26 +03:00
Use discardNullTerms to compute both states.
This commit is contained in:
parent
321622d553
commit
8a9f74a0ff
@ -103,29 +103,11 @@ extension Free where B: PatchConvertible, B.Info == A {
|
||||
}
|
||||
|
||||
public var before: Term? {
|
||||
return map { $0.patch.state.before }.iterate {
|
||||
switch $0 {
|
||||
case let .Leaf(a):
|
||||
return .In(.Leaf(a))
|
||||
case let .Indexed(a):
|
||||
return .In(.Indexed(a.flatMap(id)))
|
||||
case let .Keyed(a):
|
||||
return .In(.Keyed(Dictionary(elements: a.flatMap { k, v in v.map { (k, $0) } })))
|
||||
}
|
||||
}
|
||||
return map { $0.patch.state.before }.iterate(self.discardNullTerms)
|
||||
}
|
||||
|
||||
public var after: Term? {
|
||||
return map { $0.patch.state.after }.iterate {
|
||||
switch $0 {
|
||||
case let .Leaf(a):
|
||||
return .In(.Leaf(a))
|
||||
case let .Indexed(a):
|
||||
return .In(.Indexed(a.flatMap(id)))
|
||||
case let .Keyed(a):
|
||||
return .In(.Keyed(Dictionary(elements: a.flatMap { k, v in v.map { (k, $0) } })))
|
||||
}
|
||||
}
|
||||
return map { $0.patch.state.after }.iterate(self.discardNullTerms)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user