fp-ts-errors
Handle errors as values using fp-ts Either and TaskEither for cleaner, more predictable TypeScript code. Use when implementing error handling patterns with fp-ts.
npx skills add sickn33/agentic-awesome-skills --skill fp-ts-errors --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Teach concrete patterns for handling errors as data using fp-ts Either and TaskEither. Demonstrates turning exceptions into typed error values, and provides examples for common tasks like validation, chaining, and async operations.
How it works
- Describes using Either to represent error or success with Left as error and Right as value.
- Shows creating values via E.right and E.left, and inspecting via E.fold or pipe patterns.
- Demonstrates converting throwing code to Either using E.tryCatch and E.tryCatchK.
- Illustrates chaining with E.chain, E.map, and Do notation for accessing intermediate values.
- Presents error accumulation via E.getApplicativeValidation and NonEmptyArray to collect multiple errors.
- Covers async operations with TaskEither, including TE.tryCatch, TE.chain, TE.map, and parallel data gathering with sequenceS.
- Includes conversions between patterns: fromNullable, fromOption, fromPromise to TaskEither, and back to Promise.
When to use it
- When you want type-safe error handling in TypeScript
- When replacing try/catch with Either and TaskEither patterns
- When building APIs or services that need explicit error types
- When accumulating multiple validation errors
What it can touch
- Code examples import modules: * as E from 'fp-ts/Either', * as TE from 'fp-ts/TaskEither', * as NEA from 'fp-ts/NonEmptyArray', sequenceS from 'fp-ts/Apply', pipe from 'fp-ts/function'.
- It uses file names and commands as shown in the examples, e.g., E.tryCatch, TE.tryCatch, TE.chain, TE.map, sequenceS, Do notation, and various helper functions.
Caveats
- The guidance relies on fp-ts APIs like Either and TaskEither; behavior depends on library semantics.
- Examples show patterns rather than guaranteeing runtime outcomes; actual success depends on user code and environment.
# Practical Error Handling with fp-ts This skill teaches you how to handle errors without try/catch spaghetti. No academic jargon - just practical patterns for real problems. ## When to Use This Skill - When you want type-safe error handling in TypeScript - When replacing try/catch with Either and TaskEither patterns - When building APIs or services that need explicit error types - When accumulating multiple validation errors The core idea: **Errors are just data**. Instead of throwing them into the void and hoping someone catches them, return them as values that TypeScript can track. --- ## 1. Stop Throwing Everywhere ### The Problem with Exceptions Exceptions are invisible in your types. They break the contract between functions. ```typescript // What this function signature promises: function getUser(id: string): User // What it actually does: function getUser(id: string): User { if (!id) throw new Error('ID required') const user = db.find(id) if (!user) throw new Error('User not found') return user } // The caller has no idea this can fail const user = getUser(id) // Might explode! ``` You end up with code like this: ```typescript // MESSY: try/catch everywhere function process
- When to Use This Skill
- 1. Stop Throwing Everywhere
- The Problem with Exceptions
- The Solution: Return Errors as Values
- 2. The Result Pattern (Either)
- Converting Throwing Code to Either
- Common Either Operations
- 3. Chaining Operations That Might Fail
- Before: Nested Try/Catch Hell
- After: Clean Chain with Either
- Different Error Types? Use chainW
- 4. Collecting Multiple Errors
- Before: Collecting Errors Manually
- After: Validation with Error Accumulation
What does the fp-ts-errors skill do?
Handle errors as values using fp-ts Either and TaskEither for cleaner, more predictable TypeScript code. Use when implementing error handling patterns with fp-ts.
How do I install it?
Run `npx skills add sickn33/agentic-awesome-skills --skill fp-ts-errors --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From sickn33/agentic-awesome-skills, a repository with 44,414 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.