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:
parent
e70cbe4235
commit
8f86f9ab76
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user