What problem does it solve?
This Skill provides comprehensive patterns for Effect-TS, enabling developers to write highly robust, type-safe, and composable code by making effects, errors, and dependencies explicit in the type system. It eliminates untyped exceptions and simplifies complex asynchronous logic.
Core Features & Use Cases
Effect<A, E, R> Type System: Guides on understanding and utilizing the core Effect type, which explicitly declares success (A), error (E), and required services (R) in its signature.
- Service Pattern (DI): Defines services with
Context.Tag and implements them with Layer for powerful, type-safe dependency injection, ensuring clear separation of concerns.
- Typed Errors: Uses
Data.TaggedError for defining and recovering from specific, type-safe errors, making error handling explicit and exhaustive.
- Advanced Operations: Patterns for retries with schedules, timeouts, parallel execution, and resource management (
acquireRelease), building resilient applications.
- Use Case: A developer is building a complex data processing pipeline that involves multiple external API calls and database interactions, each with potential failures. They can use this skill to define each step as an
Effect, manage dependencies with Layers, handle errors with catchTag, and implement retries, ensuring a resilient and type-safe pipeline.
Quick Start
Refactor the 'fetchUserData' function in 'src/services/user.ts' to return an 'Effect<User, NetworkError, HttpClient>', explicitly defining its success, error, and dependency types.