What problem does it solve?
Deriving type class instances for Scala case classes often requires boilerplate and repeated patterns. This skill provides structured rules and patterns for automatic derivation using Hearth's CaseClass.parse, supporting both encoder-style field reading and decoder-style construction, while handling existential types and nested structures.
Core Features & Use Cases
- Encoder-style derivation using CaseClass.parse to read case class fields and derive instances.
- Decoder-style construction using primaryConstructor and field maps for building instances from decoded fields.
- Advanced patterns for existential types, LambdaBuilder usage, and cache-aware strategies like nest vs nestInCache.
- Guidance for dual-path derivation with a runtime flag to support fail-fast vs error-accumulating workflows.
- Practical use cases include deriving encoders/decoders for ADTs, nested case classes, and mixed field types with minimal boilerplate.
Quick Start
Derive a type class for a sample case class using CaseClass.parse to see encoder/decoder paths.