The 0.3.1 release adds a few things to the 0.3.x line, that I didn't waned to wait with, but also ones that should not break existing libraries based on 0.3.0. (More exciting things to come in 0.4.0!)
This release introduces Expr.semiEval — compile-time reconstruction of runtime values from expression ASTs — adds Type.CtorK1 for higher-kinded type constructors, futureproofs the library against JDKs that remove sun.misc.Unsafe, and ships a batch of Cross-Quotes and Better Printers fixes. It also debuts the new Hearth logo!
Highlights
-
Expr.semiEval— compile-time AST-to-value reconstruction- Reconstructs a runtime value from a macro expression AST by recursively decomposing the tree and replaying it with runtime reflection — useful for reading configuration-like values passed to macros.
- Supports literals, constructor calls, method calls (including varargs and overloads), blocks, primitives with their operators,
asInstanceOf/isInstanceOf, andValueOf. - Lambdas of any arity are supported via
java.lang.reflect.Proxy, withFunctionXXLused explicitly for arity > 22. - Resolves
valfields on companion objects and eta-expanded methods. - Fully documented with runnable examples.
-
Type.CtorK1[F[_[_]]]— higher-kinded type constructors- Type constructors parameterized by type constructors (e.g.
F[_[_]]) can now be abstracted over, with Cross-Quotes integration (Expr.quotetest coverage included).
- Type constructors parameterized by type constructors (e.g.
-
New utilities
MacroExtensionpriority — control the order in which extensions are applied.IsCollectionOf.foreachfor iterating collection elements.Expr.typeOffor recovering the type of an expression.
-
Cross-Quotes fixes
- Fixed splice isolation for nested
Expr.quote. - Fixed private setter/field visibility.
- Fixed
rassoc$Nname collision for deeply right-nested::(e.g. insidefoldLeft). - Fixed
removeMacroSuffixstripping compiler-generated$Nsuffixes instead of only Hearth's$macro$N.
- Fixed splice isolation for nested
-
Better Printers fixes
AndType(intersection types) support inRuntimeAwareTypePrinter.LiteralTypehandling in Scala 2showCodePretty.- Fixed union type printing.
-
Micro FP fixes
- Fixed
NonEmptyMap.mapandflatMapsilently producing duplicate keys.
- Fixed
-
Futureproofed for JDKs without
sun.misc.Unsafe- Hearth is now built with Scala 3.3.8 with
-Yfuture-lazy-valsenabled, so lazy vals useVarHandles instead ofsun.misc.Unsafe— this version should keep working on future JDKs that removesun.misc.Unsafe. - Regression testing bumped to Scala 3.8.4 and munit 1.3.2; fixed a
memberTypeAssertionErroron Scala 3.8.4 and a Scala Native issue.
- Hearth is now built with Scala 3.3.8 with
-
Hearth-based libraries to learn from
- Kindlings — a repository showing how the existing Hearth features can be used in practice, implementing several derivation macros (Show, Schema, codecs, and more). The newest release based on Hearth 0.3.1 is 0.2.0 and it now has a documentation!
- refined-compat — a Hearth-based macro library that finally lets you migrate
Refinedcodebases to Scala 3, if macros were the thing that held you back! Now released as 0.1.0.
-
New logo and docs
- Hearth has a new logo! 🔥
- Expanded FAQ and improved
semiEvaldocumentation.
-
Build & CI
- Build simplified with sbt-kubuszok.
- Coursier caching for the snippets-check CI job, fixed flaky MIO tests.
Summary
0.3.1 rounds out the 0.3.x line: Expr.semiEval lets macros turn expression trees back into runtime values for configuration-style APIs, Type.CtorK1 extends type-constructor abstraction to higher kinds, and -Yfuture-lazy-vals makes Hearth ready for JDKs that drop sun.misc.Unsafe. With Kindlings and refined-compat as real-world examples of Hearth-based macro libraries, it has never been easier to see how the pieces fit together.
Be sure to look at our documentation, star the project ⭐ and leave us some feedback!