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

Lazy variant of Hashed? #155

Open
mikeplus64 opened this issue Apr 11, 2018 · 1 comment
Open

Lazy variant of Hashed? #155

mikeplus64 opened this issue Apr 11, 2018 · 1 comment

Comments

@mikeplus64
Copy link

mikeplus64 commented Apr 11, 2018

This would be useful for me for a type (living in a TVar) that:

  • updates frequently
  • has an expensive hash function
  • needs to check hashes infrequently

The implementation should be exactly the same as 'Hashed' without the {-# UNPACK #-} !Int. Maybe have a typeclass:

class Hashable1 h => CacheableHashable h where
  hashed :: Hashable a => a -> h a
  unhashed :: h a -> a
@phadej
Copy link
Contributor

phadej commented Feb 16, 2021

I'm not sure I understand a motivation. Hashed is introduced to memoize expensive-ish hashes, so that is the same. Yet it feels that you use hashable as some kind of checksum, and that is wrong use-case.

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

No branches or pull requests

2 participants