Schema.Union and Schema.Literal
Model discriminated unions with `Schema.Union` and `Schema.Literal`. Use a shared literal field (e.g. `_tag`) to distinguish variants. Decoding picks the right branch.
- Use Schema.Literal("value") for literal discriminators
- Use Schema.Union(SchemaA, SchemaB) for union types
- Decoding tries each branch in order
Loading code editor...