Expand description
Which types are Key, and the checks that need it. Constrained generics
slice 2 (#2684; the model is the track’s Q6 in
design/archive/retired-tracks.md).
Key admits a type as a value Map key or Set member (and as a distinct,
groupBy or join key). It is automatic, never derived: a type is Key when it
is one of:
String,Int,Bool,Instant,Duration,BytesorDecimal, or a refined or opaque type over one of them;Option[T]orList[T]withTKey;- a record, sum or enum whose every field and payload is
Key, and, when it is generic, whose type arguments areKey; - a type parameter declared
K: Key(checked separately: seesuper::equality::require_key_vars).
Float is not Key at any depth (NaN is not equal to itself), nor are
Map and Set (an order-independent encoding is possible but nothing needs
one yet), functions, Effect, Query, streams, held resources, actors and
the boundary-only types.
The runtime holds a composite key under a canonical encoding
(__bynkKeyEncode); Key needs no witness, so it adds no hidden argument.
The store rule (store m: Map[K, V], Cache, @indexed) keeps its own
String/Int predicate: those keys persist through String(k).
Functions§
- key_
params - The type parameters of
fdeclaredKey: its own (inline or inwhere) and its receiver type’s.