ワンクリックで
effect-system
Implement effect systems to track and control side effects in programs.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Implement effect systems to track and control side effects in programs.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Implement abstract machines for defining and executing operational semantics of programming languages.
Implements alias and points-to analysis for pointer programs. Use for: (1) Optimizing compilers, (2) Verifying memory safety, (3) Program understanding, (4) Parallelization.
Define program meaning through logical assertions and proof rules (Hoare logic).
Transforms closures to explicit environments. Use when: (1) Implementing functional languages, (2) Building compilers, (3) Understanding closures.
Implements common subexpression elimination (CSE). Use when: (1) Building compilers, (2) Optimizing code, (3) Program analysis.
Implements general dataflow analysis framework. Use when: (1) Building compilers, (2) Static analysis tools, (3) Program verification.
| name | effect-system |
| description | Implement effect systems to track and control side effects in programs. |
| version | 1.0.0 |
| tags | ["effects","types","purity","popl"] |
| difficulty | intermediate |
| languages | ["haskell","purecript","koka"] |
| dependencies | ["type-checker-generator","type-class-implementer"] |
Effect systems track what computational effects a function may perform, enabling reasoning about purity, exceptions, I/O, and other side effects at the type level.
| Concept | Description |
|---|---|
| Effect | Computational side effect (IO, State, Throw) |
| Effect Set | Collection of effects |
| Effect Row | Extensible row of effects |
| Effect Polymorphism | Generic over effect sets |
| Effect Handler | Interpret effects |
| Pure | No effects |
algebraic-effects - Algebraic effect handlerstype-class-implementer - Monad type classesmonad-transformer - Monad transformersinformation-flow-analyzer - Security effects| Reference | Why It Matters |
|---|---|
| Lucassen & Gifford, "Polymorphic Effect Systems" (POPL 1988) | Original paper on effect systems |
| Talpin & Jouvelot, "The Type and Effect Discipline" (POPL 1992) | Effect polymorphism formalization |
| Leijen, "Koka: Programming with Row Polymorphic Effect Handlers" (2017) | Modern effect system design |
| Approach | Pros | Cons |
|---|---|---|
| Monads | Composable | Syntactic overhead |
| Effect systems | Cleaner syntax | Complex inference |
| Algebraic effects | Flexible | Runtime overhead |
A high-quality implementation should have:
| Criterion | What to Look For |
|---|---|
| Soundness | All effects tracked |
| Inference | Automatic effect inference |
| Polymorphism | Effect polymorphism |
| Handlers | Effect interpretation |
✅ Good: Sound, infers effects, supports polymorphism ⚠️ Warning: Manual annotations required ❌ Bad: Misses effects, no polymorphism
Effect system implementations:
| Tool | Language | What to Learn |
|---|---|---|
| Koka | Koka | Row-based effects |
| Frank | Frank | Handler calculus |
| Eff | Eff | Direct handlers |
| Multicore OCaml | OCaml | Effects in OCaml |
| Pitfall | Real Consequence | Solution |
|---|---|---|
| Effect inference | Complexity | Use bidirectional |