hkj-effects

Implement algebraic effect handlers with Free monads for Java side-effect decoupling.

78|6|Updated Apr 4, 2025
One-click install
npx skills add https://github.com/higher-kinded-j/higher-kinded-j --skill hkj-effects
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hkj-effects
Source: https://github.com/higher-kinded-j/higher-kinded-j/tree/main/.claude/skills/hkj-effects
Command: npx skills add https://github.com/higher-kinded-j/higher-kinded-j --skill hkj-effects

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the complexity of managing side effects in Java applications by providing a structured, algebraic-effect-style approach that separates business logic from execution, eliminating nested error handling and simplifying testing.

Core Features & Use Cases

  • Algebraic Effect Handlers: Define domain operations as data structures (Free monads) and interpret them via multiple modes like production, testing, or audit.
  • Mock-Free Testing: Use Id monad interpreters to perform deterministic, pure testing of complex workflows without needing external mocks or Spring context.
  • Use Case: A payment processing service can be written once and interpreted as a real IO-based production service, a pure Id-based test suite, or a dry-run fee estimator without changing the core business logic.

Quick Start

Use the hkj-effects skill to generate an effect algebra interface and a corresponding interpreter skeleton for a new domain operation.

Frequently Asked Questions about hkj-effects

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

FAQPage Schema
How do I decouple business logic from side-effect execution in Java?

You can decouple business logic from side-effect execution in Java by implementing algebraic effect handlers using Free monads, which model domain operations as data structures interpreted via multiple modes like production IO or deterministic testing.

What is mock-free testing for functional programming workflows in Java?

Mock-free testing uses Id monad interpreters to execute pure, deterministic tests of complex workflows, eliminating the need for external mocks or Spring context while validating business logic against expected outputs.

How do I build an algebraic effect handler for a new domain operation?

To build an algebraic effect handler, define your domain operations as a Free monad interface, then generate a corresponding interpreter skeleton that translates these operations into target execution modes like production or audit logging.

Can I interpret the same Java business logic for production and dry-run modes?

Yes, you can interpret the same Java business logic for production and dry-run modes by routing the Free monad data structure through different interpreters, such as IO for production or Id for dry-run fee estimation.

Does this approach require compile-time exhaustive operation checking?

Yes, implementing algebraic effect handlers with Free monads satisfies requirements for compile-time exhaustive operation checking by forcing interpreters to handle every defined operation in the domain algebra interface.

What are the limitations of using Free monads for side-effect management?

Using Free monads for side-effect management introduces limitations around architectural overhead, requiring boilerplate algebra definitions and interpreter implementations for each distinct domain operation before execution.