hearth-macro-basics

Derive type classes across Scala 2.13 and Scala 3 with rule-based macro generation.

68|7|Updated Nov 24, 2025
One-click install
npx skills add https://github.com/kubuszok/kindlings --skill hearth-macro-basics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hearth-macro-basics
Source: https://github.com/kubuszok/kindlings/tree/main/docs/contributing/hearth-macro-basics
Command: npx skills add https://github.com/kubuszok/kindlings --skill hearth-macro-basics

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Core Hearth macro architecture provides a unified foundation for building type-class derivation macros that work across Scala 2.13 and Scala 3, speeding up compilation and ensuring consistent behavior across modules.

Core Features & Use Cases

  • Context-based parameter passing via a DerivationCtx to bundle all inputs for code generation.
  • Rule-based derivation architecture with a canonical ordering to coordinate decision points.
  • Logging with MIO and Log to trace macro decisions and help debugging.
  • Caching with ValDefsCache and MLocal to avoid duplicate definitions and support recursive derivation.
  • Self-type skip, placeholder caching, and cross-module entry point patterns to enable scalable macro modules.

Quick Start

Follow this pattern to implement a new Hearth-based macro derivation module by wiring a DerivationCtx and a Rules pipeline.

Frequently Asked Questions about hearth-macro-basics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement type class derivation macros that work across Scala 2.13 and Scala 3?

Type class derivation across Scala 2.13 and Scala 3 requires a unified macro architecture. Hearth provides a cross-version foundation using a DerivationCtx to bundle inputs, enabling context passing, caching, and rule-based generation for complex type structures.

What is the best way to avoid duplicate definitions during recursive macro derivation?

Avoiding duplicate definitions during recursive macro derivation relies on caching. Hearth uses ValDefsCache and MLocal to store generated definitions, preventing redundant code generation and supporting safe recursive expansion for complex types.

How do you coordinate decision points when building rule-based derivation macros?

Coordinating decision points in rule-based derivation macros requires a canonical rule order. Hearth enforces this ordering alongside safety checks to ensure consistent behavior and guide macro expansion across different modules.

How can I trace macro decisions when debugging type class generation in Scala?

Tracing macro decisions during type class generation requires dedicated logging. Hearth integrates MIO and Log utilities to record internal derivation choices, helping developers debug the rule-based generation pipeline and verify complex type structures.

Does Hearth support cross-module entry points for scalable macro architectures?

Hearth supports scalable macro architectures through cross-module entry point patterns. It enables self-type skipping and placeholder caching within the DerivationCtx, allowing developers to build modular type class derivation systems without hitting compilation bottlenecks.