mirror of
https://github.com/github/semantic.git
synced 2024-11-29 11:02:26 +03:00
Parameterized hashing over Cofree.
This commit is contained in:
parent
3dcfbc0d38
commit
db57734586
@ -79,4 +79,13 @@ public func == <A: Equatable, B: Equatable> (left: Cofree<A, B>, right: Cofree<A
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - Hashing
|
||||||
|
|
||||||
|
extension Cofree {
|
||||||
|
public func hash(annotation annotation: B -> Hash, leaf: A -> Hash) -> Hash {
|
||||||
|
return .Ordered([ annotation(extract), unwrap.hash(ifLeaf: leaf, ifRecur: { $0.hash(annotation: annotation, leaf: leaf) }) ])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
Loading…
Reference in New Issue
Block a user