1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 02:44:36 +03:00

Name Free’s piecewise JSON functions after the type parameters.

This commit is contained in:
Rob Rix 2015-10-22 10:43:42 -04:00
parent b7a341b8b1
commit 831f8dcbae
2 changed files with 6 additions and 6 deletions

View File

@ -189,18 +189,18 @@ public func == <Term: CofreeType where Term.Leaf: Equatable> (left: Free<Term.Le
// MARK: - JSON
extension Free {
public func JSON(ifPure ifPure: Value -> Doubt.JSON, ifLeaf: Leaf -> Doubt.JSON) -> Doubt.JSON {
public func JSON(pure pure: Value -> Doubt.JSON, leaf: Leaf -> Doubt.JSON) -> Doubt.JSON {
return analysis(
ifPure: ifPure,
ifPure: pure,
ifRoll: {
$0.JSON(ifLeaf: ifLeaf, ifRecur: { $0.JSON(ifPure: ifPure, ifLeaf: ifLeaf) })
$0.JSON(ifLeaf: leaf, ifRecur: { $0.JSON(pure: pure, leaf: leaf) })
})
}
}
extension Free where Leaf: CustomJSONConvertible {
public func JSON(ifPure: Value -> Doubt.JSON) -> Doubt.JSON {
return JSON(ifPure: ifPure, ifLeaf: { $0.JSON })
public func JSON(pure: Value -> Doubt.JSON) -> Doubt.JSON {
return JSON(pure: pure, leaf: { $0.JSON })
}
}

View File

@ -55,7 +55,7 @@ func diffAndSerialize(a aString: String, b bString: String, to: String) throws {
[
"a": .String(aString),
"b": .String(bString),
"diff": diff.JSON(ifPure: { $0.JSON { $0.JSON(annotation: range, leaf: { $0.JSON }) } }, ifLeaf: { $0.JSON }),
"diff": diff.JSON(pure: { $0.JSON { $0.JSON(annotation: range, leaf: { $0.JSON }) } }, leaf: { $0.JSON }),
]
}