Equality and well-known contexts
What is still open about Eq, Ord, Hash and the contexts the compiler knows by name
Equality, ordering, hashing and printing through the well-known contexts Eq, Ord, Hash and ToString are
described in the language docs:
Common contexts, Eq(a),
Ord(a), Hash(a),
ToString(a), A type’s own instance wins
and Extending a type. Whether maps and sets use the hash is on
Maps and sets. This page keeps what is still open.
Not done yet
- Ordering through each part, beyond one list.
==compares a tag, a tuple, a record or a list part by part, each part with its ownEq, and<on a list of a type that attachescomparecalls it. But a tuple holding aVersion, or a list of lists of them, isNYX0205, as ifVersionhad no order, and<on alist(a)whose type is only known later orders by structure. Eqof an open union passed to a function.==on#some(Email) | ris derived through each tag it names, but a call that requiresEqof an open union, assame(v, w)withv: #x(a) | rdoes, is passed the compiler’s own.- The order of instances for a type variable. A type’s own instance comes first, then the one the enclosing
signature declares, then one loaded with
use. For a type variable the code looks at ausebefore the signature’s instance, the opposite of that order. - Attached definitions through an import’s alias. A type’s own definitions are in scope wherever its values are,
but a module the importer imports itself is reached as the import says, so after
import nanyx/text as tan ownedstring.trimist.string.trim, not in scope unqualified; it is reached through the alias as a value too (#1833). Two visible types of one name (two modules’Points) have their owned definitions left out, as an attached name says only the type’s name.
Still open
- Should a private type’s module be able to withhold equality from other modules? [Recommended: no, not until someone needs it.]