Skip to content

0.3.1 - Expr.semiEval, Type.CtorK1, JDK Futureproofing, and a New Logo

Latest

Choose a tag to compare

@MateuszKubuszok MateuszKubuszok released this 11 Jun 06:57
· 53 commits to master since this release

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, and ValueOf.
    • Lambdas of any arity are supported via java.lang.reflect.Proxy, with FunctionXXL used explicitly for arity > 22.
    • Resolves val fields 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.quote test coverage included).
  • New utilities

    • MacroExtension priority — control the order in which extensions are applied.
    • IsCollectionOf.foreach for iterating collection elements.
    • Expr.typeOf for recovering the type of an expression.
  • Cross-Quotes fixes

    • Fixed splice isolation for nested Expr.quote.
    • Fixed private setter/field visibility.
    • Fixed rassoc$N name collision for deeply right-nested :: (e.g. inside foldLeft).
    • Fixed removeMacroSuffix stripping compiler-generated $N suffixes instead of only Hearth's $macro$N.
  • Better Printers fixes

    • AndType (intersection types) support in RuntimeAwareTypePrinter.
    • LiteralType handling in Scala 2 showCodePretty.
    • Fixed union type printing.
  • Micro FP fixes

    • Fixed NonEmptyMap.map and flatMap silently producing duplicate keys.
  • Futureproofed for JDKs without sun.misc.Unsafe

    • Hearth is now built with Scala 3.3.8 with -Yfuture-lazy-vals enabled, so lazy vals use VarHandles instead of sun.misc.Unsafe — this version should keep working on future JDKs that remove sun.misc.Unsafe.
    • Regression testing bumped to Scala 3.8.4 and munit 1.3.2; fixed a memberType AssertionError on Scala 3.8.4 and a Scala Native issue.
  • 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 Refined codebases 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 semiEval documentation.
  • 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!