#Java EffectHandlers without the boilerplate?
In Higher-Kinded-J 0.4.1 — you define the what, the tooling generates the how.
You write this:
@EffectAlgebra
public sealed interface PaymentGatewayOp<A>
permits Authorise, Charge, Refund { ... }
It generates five classes:
✦ Kind marker + Witness — HKT plumbing
✦ KindHelper — safe widen/narrow conversions
✦ Functor — auto-detects your mapK method
✦ Ops + Bound — smart constructors for building programs
✦ Interpreter skeleton — abstract class with exhaustive switch
Composing multiple effects?
@ComposeEffects
public record AppEffects(
Class<GatewayOp<?>> gateway,
Class<FraudOp<?>> fraud,
Class<LedgerOp<?>> ledger) {}
This generates Inject factories, a composed Functor, a BoundSet, and an interpret() bridge. All type-safe. All compile-time checked.
You define records. You write interpreters. The processor handles everything in between.
👉 https://higher-kinded-j.github.io/latest/effect/effect_handlers_intro.html
#Java #DOP #FP #OpenSource #FunctionalProgramming