1
1
mirror of https://github.com/github/semantic.git synced 2025-01-01 19:55:34 +03:00

Define Free hashing.

This commit is contained in:
Rob Rix 2015-10-02 14:35:07 -04:00
parent f14433871b
commit 2b5b85e0b4

View File

@ -65,3 +65,12 @@ extension Free {
public func == <A: Equatable, B: Equatable> (left: Free<A, B>, right: Free<A, B>) -> Bool {
return Free.equals(ifPure: ==, ifRoll: ==)(left, right)
}
// MARK: - Hashing
extension Free {
public func hash(ifPure ifPure: B -> Hash, ifRoll: A -> Hash) -> Hash {
return analysis(ifPure: ifPure, ifRoll: { $0.hash(ifLeaf: ifRoll, ifRecur: { $0.hash(ifPure: ifPure, ifRoll: ifRoll) }) })
}
}