Meta Programming
Introduction
Scala erases most type information at runtime, so a List[Int] and a List[String] look the same to the JVM. The blocks in this group turn type information into ordinary values that a program can inspect, store and act on. This lets a library derive serializers, validators and accessors from the shape of a type instead of requiring them to be written by hand.
The Blocks
The group has two blocks, and Schema is the one most programs start with.
| Block | Artifact | What It Is For |
|---|---|---|
| Schema | zio-blocks-schema | Type-safe schemas with automatic codec, optic, and validator derivation |
| TypeId | zio-blocks-typeid | Compile-time type identity with rich metadata |
How the Blocks Differ
Schema describes the structure of a data type, and one schema drives JSON support, validation and optics. Further formats such as Avro, BSON, CSV, MessagePack, Thrift, TOON, XML and YAML are separate modules, each with its own artifact (for example zio-blocks-schema-avro). The overview lists them with their platforms, and the Schema page documents them.
TypeId answers a narrower question: which type is this? It captures names, type parameters, parent types and annotations as data, which suits registries, code generation and dispatching on a type that would otherwise be erased.
Where to Start
Start with Schema to define a data type once and derive codecs from it. Reach for TypeId when a program needs a type's identity as a value rather than its structure. The overview compares every block in one table.