Add Hashable typeclass
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 20/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Domaine
- backend
Piste de recherche
The issue proposes adding a Hashable typeclass to the prelude and deriving support to the compiler, but names no files or tests. Start by reviewing the existing Eq and Ord typeclasses and the linked purescript-unordered-collections implementation. Done means agreeing on the design and adding the prelude typeclass and compiler deriving support; the thread has had no comment for years, so check whether the proposal is still wanted.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
I would like to add a Hashable typeclass to the prelude and deriving support for it to the compiler. It is intended as an approximation of equality for use in hash-based algorithms and data structures, such as hash maps, not cryptographically secure digests or password hashes.
class Eq a <= Hashable a where
hash :: a -> Int
There are two reasons for adding it to the prelude instead of having a standalone library:
- Dependencies: To be useful in general data structures, as many datatypes as possible should be hashable. Ideally, whenever a datatype is
Eq, it should also haveOrdandHashableinstances, if possible. Most packages depend on the prelude already.[citation needed] This should make it easier to convince authors to addHashableinstances, because they do not need to add another dependency, all that is required is one more deriving line below the lines forEqandOrd. - Performance: Usually, the main goal of hashing is to avoid expensive comparisons. One could write a generic hash function in terms of
purescript-generics-rep. This would be fine for many applications, but for hash-based data structures etc., the hash function should really be as fast as possible.
I am more than happy to make an initial pull request (based on https://github.com/fehrenbach/purescript-unordered-collections/blob/master/src/Data/Hashable.purs) and work on deriving support.
What do people think?
- Langage dominant
- PureScript
- Étoiles
- 168
- Forks
- 90
- Merge moyen
- 3 j 1 h
- PR mergées (30 j)
- 1
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de purescript/purescript-prelude
-
Difficulté 2/5 1-3 heures Accessibilité débutants 57/100
purescript/purescript-prelude#317 · 1 réaction ·
-
Int bottom is not safeOuverte
Difficulté 3/5 1-2 jours Accessibilité débutants 32/100
purescript/purescript-prelude#312 · 5 commentaires ·
-
add liftCompare & friendsOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
purescript/purescript-prelude#310 · 5 commentaires ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 24/100
purescript/purescript-prelude#308 · 2 commentaires ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
purescript/purescript-prelude#307 · 1 commentaire · 1 réaction ·
Toutes les issues de purescript/purescript-prelude
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
-
ManageSieve proxy: a backend's NO/BYE greeting is skipped as a capability line and reported as EOFOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Mend: dependency security vulnerability
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
Mend: dependency security vulnerability
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
ManageIQ/manageiq-pods#1476 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
prime-radiant-inc/evener#6366 ·
Les mainteneurs répondent en général sous 1 jour