1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 21:43:07 +03:00

Parameterized JSON conversion for Cofree.

This commit is contained in:
Rob Rix 2015-10-14 10:59:41 -04:00
parent e70cbe4235
commit 8f86f9ab76

View File

@ -94,4 +94,16 @@ extension Cofree where A: Hashable, B: Hashable {
} }
// MARK: - JSON
extension Cofree {
public func JSON(annotation annotation: B -> Doubt.JSON, leaf: A -> Doubt.JSON) -> Doubt.JSON {
return [
"extract": annotation(extract),
"unwrap": unwrap.JSON(ifLeaf: leaf, ifRecur: { $0.JSON(annotation: annotation, leaf: leaf) })
]
}
}
import Prelude import Prelude