1
1
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:
Rob Rix 2015-10-14 10:56:25 -04:00
parent 3dcfbc0d38
commit db57734586

View File

@ -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