-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
Description
Describe the bug
- use
ContentHashableto hash the content of anHashMap(directly or indirectly) - update my haskell packages. A new version of
hashableis released, which change thehashfunction. The order ofHashMapis hence changed, and my nicely content hashed object suddently change their hash.
See the instance for HashMap in the code, it uses toList, the order is unspecified.
https://github.com/tweag/funflow/blob/master/cas/hashable/src/Data/CAS/ContentHashable.hs#L361-L369
To Reproduce
main = do
print =<< contentHash $ HashMap.fromList [("hello", 10), ("goodbye", 20)]Run this code with different version of hashable (You may have to try different keys in the map, or a bigger map, in order to trigger the effect).
Expected behavior
It is impossible to guarantee that the hash won't change, but either:
- Do not expose an instance for a type when it is known that the hash will change systematically on each release of a library as fundamental as
hashable - (or) sort the values, at the cost of an
Ord, Eqconstraints on the keys of theHashMap.
Reactions are currently unavailable