agentleFS
rainoftimerainoftime/pl-skills/algebraic-effects/SKILL.md

algebraic-effects

Skill17 starsChanged 9 months agoApache-2.0View on GitHub

Implements algebraic effects and effect handlers for computational effects in typed languages.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Start with simple effects (state, exceptions)

    line 40
  2. Distinctive:

    Use deep handlers for full resumption

    line 41
  3. Distinctive:

    Consider effect inference to reduce annotation burden

    line 42

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Algebraic Effects

Implements algebraic effects and effect handlers - a modular approach to computational effects where effects are described as operations and handled by handler functions.

When to Use This Skill

  • Building languages with composable effects
  • Implementing async/await, state, exceptions, logging, nondeterminism
  • Researching effect systems and handlers
  • Creating domain-specific effect languages

What This Skill Does

  1. Effect Signature Definition: Defines effects as sets of operations with types
  2. Effect Handler Implementation: Implements handlers that interpret effect operations
  3. Deep vs Shallow Handlers: Supports both continuation-based deep handlers and single-shot shallow handlers
  4. Effect Inference: Infers effect types from code using effect inference algorithms

Key Concepts

ConceptDescription
Effect OperationAbstract description of an effect (e.g., State.get, State.put)
Effect HandlerFunction that interprets effect operations
ResumptionContinuation passed to handler for resuming computation
Effect RowCollection of effects tracked in type system

Tips

  • Start with simple effects (state, exceptions)
  • Use deep handlers for full resumption
  • Consider effect inference to reduce annotation burden
  • Handlers compose via delegation

Related Skills

  • effect-system - Effect type tracking
  • monad-transformer - Alternative effect composition
  • type-inference-engine - Effect inference

Canonical References

ReferenceWhy It Matters
Plotkin & Pretnar "Handlers of Algebraic Effects" (2009)Foundational effect handlers paper
Bauer & Pretnar "Programming with Algebraic Effects and Handlers"Eff language implementation
Leijen "Koka: Programming with Row Polymorphic Effect Types" (2014)Effect rows in practice
Kammar et al. "Handlers in Action" (ICFP 2013)Comprehensive handler study

Tradeoffs and Limitations

ApproachProsCons
Deep handlersFull resumption, composableComplex continuation management
Shallow handlersSimpler implementationLimited expressiveness
Monadic encodingFamiliar, pureEffets verbosity, lack of local reasoning

Assessment Criteria

CriterionWhat to Look For
Type safetyEffect operations well-typed
Handler correctnessOperations correctly interpreted
PerformanceMinimal overhead vs monadic approach
ComposabilityHandlers can be layered

Quality Indicators

✅ Good: Type-safe, correct handlers, good performance, composable ⚠️ Warning: Partial type safety, some handler issues ❌ Bad: Type errors, incorrect handler behavior

Research Tools & Artifacts

Algebraic effect implementations:

ToolLanguageWhat to Learn
EffOCamlOriginal implementation
KokaKokaEffect types
FrankFrankHandler calculus
Idris 2IdrisEffects

Research Frontiers

1. Effect Inference

  • Goal: Reduce annotation burden
  • Approach: Row polymorphism, effect variables
  • Papers: "A Theory of Effect Inference" (Lucassen & Gifford)

2. Algebraic Effects for Concurrency

  • Goal: Composable concurrency primitives
  • Approach: Effect handlers for async/await
  • Papers: "Asynchronous Effect Handlers" (2019)

Implementation Pitfalls

PitfallReal ConsequenceSolution
Continuation leakMemory issuesProper resumption handling
Effect row ambiguityUnclear effect setExplicit row variables
Handler orderingWrong semanticsDefine evaluation order

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.