Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashable instances fix #111

Merged

Conversation

phadej
Copy link
Contributor

@phadej phadej commented Sep 24, 2015

Should be ready to review.

Doesn't pass as instance Hashable (HashMap k v) violates

    (x == y) ==> hashWithSalt salt x == hashWithSalt salt y

property.
@phadej
Copy link
Contributor Author

phadej commented Sep 24, 2015

Resolves #78

pHashable xs is salt =
x == y ==> hashWithSalt salt x === hashWithSalt salt y
where
ys = L.map snd . L.sort . L.zip (is ++ [L.maximum (0:is) + 1..]) $ xs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment what this line is trying to achieve (e.g. would it be better to randomly shuffle ys)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually to randomly shuffle xs into ys, I'll give that shuffle stuff a name and a comment

@phadej
Copy link
Contributor Author

phadej commented Sep 29, 2015

Clarified the test. I don't know better way to have a list and randomly shuffled version of it for the property.

@phadej
Copy link
Contributor Author

phadej commented Sep 29, 2015

@tibbe Is there something still needing a fix or an improvement?

go :: Int -> [HashMap k v] -> Int
go s [] = s
go s (Leaf _ l : tl) = s `hashLeafWithSalt` l `go` tl
-- For collisions we hashmix hash value, and then array of values' hashes sorted
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep line length <= 80 chars. Here and elsewhere.

@phadej
Copy link
Contributor Author

phadej commented Oct 2, 2015

All lines are under 80 characters now.

tibbe added a commit that referenced this pull request Oct 5, 2015
@tibbe tibbe merged commit 97a3d51 into haskell-unordered-containers:master Oct 5, 2015
@phadej phadej deleted the hashable-instances-fix branch October 5, 2015 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants