@@ -1,5 +1,5 @@
11module Dict (empty,singleton,insert,update
2− ,lookup,findWithDefault
2+ ,lookup,findWithDefault,equals
33 ,remove,member
44 ,foldl,foldr,map
55 ,union,intersect,diff
@@ -17,7 +17,7 @@ Insert, remove, and query operations all take *O(log n)* time.
1717@docs empty, singleton, insert, update, remove
1818
1919# Query
20−@docs member, lookup, findWithDefault
20+@docs member, lookup, findWithDefault, equals
2121
2222# Combine
2323@docs union, intersect, diff
@@ -112,6 +112,18 @@ member : comparable -> Dict comparable v -> Bool
112112-- Does t contain k?
113113member k t = isJust <| lookup k t
114114
115+{-| Check if the contents of all keys and values are equal.
116+-}
117+equals : Dict comparable v -> Dict comparable v -> Bool
118+equals a b =
119+ let go lists =
120+ case lists of
121+ (x::xs,y::ys) -> x == y && go (xs,ys)
122+ ([],[]) -> True
123+ _ -> False
124+ in
125+ go (toList a, toList b)
126+
115127ensureBlackRoot : Dict k v -> Dict k v
116128ensureBlackRoot t =
117129 case t of