Expand description
Which types are Codable, and the checks that need it. Constrained generics
slice 3 (#2715; the model is the track’s Q4/Q7 in
design/archive/retired-tracks.md).
Codable is automatic, never derived, and its meaning is one predicate: the
domain Json.decode accepts , which Json.encode,
Json.decode and a Codable bound all share so they cannot drift. A type is
Codable when it is:
- a base type (including
FloatandBytes), or a refined or opaque type; Option,List,Set,MaporResultofCodabletypes;- a record, sum or enum, or a generic instantiation whose arguments are
Codable; - a type parameter declared
T: Codable(checked separately: seesuper::equality::require_codable_vars).
Not Codable: top-level () (it encodes but does not decode), functions,
Effect, Query, Stream and anything that carries one, Connection, the
HTTP and queue result types, Asset, request headers, token claims,
statements, actors, a recursive generic record, and an unbounded type
parameter. The declaration-position rule (context_checks::reject_fn_types)
stays separate: its answer depends on the position.
A Codable type parameter gets a hidden codec witness (__codec_T), ordered
with the comparator witnesses by witness_list.
Structs§
- CapEncoding
- How a call to a capability operation with
Codableparameters is lowered: the provider receives plain JSON, never a witness (DECISION D). - Reply
Decode - How a call site decodes the reply of a typed read (#3458).
- Witness
Param - One hidden trailing parameter of a bounded generic function.
Enums§
- Reply
Policy - What a capability operation’s reply that does not decode as its payload type means, declared per operation (#3458). The default is a fault.
- Witness
Kind - Which hidden witness a type parameter takes.
Constants§
- REPLY_
POLICY_ ANNOTATION - The internal annotation a first-party operation uses to declare what a reply
that does not decode means (#3458):
@onUndecodable(miss)or@onUndecodable(fault). Not user-visible surface: the resolver refuses it outside the standard library.
Functions§
- codable_
op_ params - The type parameters of a capability operation declared
Codable. - mentions_
any - Whether
tmentions any ofnames, as a bare name or a generic argument. - op_
reply_ policy - The failure policy an operation declares for an undecodable reply: its
@onUndecodable(..)annotation, or a fault when it has none. - reply_
policy_ word - The policy word an
@onUndecodable(...)annotation carries, when it is a single baremissorfault. - typed_
read_ policy - The failure policy of a typed read,
Nonefor any other operation (#3458): one whoseEffect[P]payload mentions aCodabletype parameter of its own. Hover renders it, so the clause is read off the same rule the call site uses. - witness_
list - The hidden witness parameters of
f, in order: the receiver type’s parameters first, then the function’s own, each in declaration order; within one parameter the comparator comes before the codec (the order ofCONSTRAINTS). A bound is declared inline (T: Ord), in awhereentry, or, for a receiver parameter, on the type. The emitter adds one trailing parameter per entry and every call site passes one argument per entry, so this order is the contract between them across units; it is not part of the published ABI.