Skip to main content

Module codable

Module codable 

Source
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 Float and Bytes), or a refined or opaque type;
  • Option, List, Set, Map or Result of Codable types;
  • a record, sum or enum, or a generic instantiation whose arguments are Codable;
  • a type parameter declared T: Codable (checked separately: see super::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 Codable parameters is lowered: the provider receives plain JSON, never a witness (DECISION D).
ReplyDecode
How a call site decodes the reply of a typed read (#3458).
WitnessParam
One hidden trailing parameter of a bounded generic function.

Enums§

ReplyPolicy
What a capability operation’s reply that does not decode as its payload type means, declared per operation (#3458). The default is a fault.
WitnessKind
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 t mentions any of names, 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 bare miss or fault.
typed_read_policy
The failure policy of a typed read, None for any other operation (#3458): one whose Effect[P] payload mentions a Codable type 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 of CONSTRAINTS). A bound is declared inline (T: Ord), in a where entry, 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.