fp-taskeither-ref

Quick reference for TaskEither. Use when user needs async error handling, API calls, or Promise-based operations that can fail.

31,392 stars
Complexity: none

About this skill

This skill serves as a concise guide to `fp-ts`'s `TaskEither` data type, which represents an asynchronous computation that may result in an error (`Left`) or a successful value (`Right`). It is conceptually similar to `Promise<Either<E, A>>`. The reference provides essential syntax and patterns for creating, transforming, and composing `TaskEither` instances. It is particularly valuable for AI agents tasked with generating or understanding TypeScript code that requires robust, functional-style error handling for API calls, Promise-based operations, or other potentially failing asynchronous processes, promoting clarity and error resilience.

Best use case

When an AI agent needs to understand or generate TypeScript code involving `fp-ts` for: 1. Implementing robust asynchronous error handling. 2. Structuring API calls with clear success and failure paths. 3. Composing multiple Promise-based operations that might fail in a functional style. 4. Providing explanations or debugging advice related to `TaskEither` usage.

Quick reference for TaskEither. Use when user needs async error handling, API calls, or Promise-based operations that can fail.

The AI agent will retrieve clear explanations and runnable TypeScript code examples demonstrating how to create, transform, and manage `TaskEither` instances, enabling it to better generate or understand `fp-ts` code and answer related user queries effectively.

Practical example

Example input

Show me how to create new `TaskEither` instances and the basic ways to transform them using `fp-ts`.

Example output

```json
{
  "explanation": "Here's a quick reference on creating and transforming `TaskEither` instances using `fp-ts`:",
  "code_examples": [
    "```typescript\nimport * as TE from 'fp-ts/TaskEither'\n\n// How to create TaskEither instances:\nTE.right(value)          // Represents an asynchronous operation that successfully returns 'value'.\nTE.left(error)           // Represents an asynchronous operation that fails with 'error'.\nTE.tryCatch(asyncFn, toError)  // Converts a Promise-based asynchronous function (asyncFn) that might throw into a TaskEither. 'toError' is a function to map any thrown error to your desired error type.\nTE.fromEither(either)    // Converts an existing 'Either' instance into a TaskEither.\n```",
    "```typescript\nimport * as TE from 'fp-ts/TaskEither'\n\n// How to transform TaskEither instances:\nTE.map(fn)               // Applies a function 'fn' to the success value (if the TaskEither is Right) without affecting the error type. `fn` takes A and returns B, resulting in TaskEither<E, B>.\nTE.mapLeft(fn)           // Applies a function 'fn' to the error value (if the TaskEither is Left) without affecting the success type. `fn` takes E and returns F, resulting in TaskEither<F, A>.\nTE.flatMap(fn)           // Chains another TaskEither operation. If the current TaskEither is Right(value), 'fn' is applied to 'value' and must return another TaskEither. If the current TaskEither is Left, the error is propagated. `fn` takes A and returns TaskEither<E, B>, resulting in TaskEither<E, B>.\n// ... (a full reference would include more transform functions like 'fold', 'alt', 'chainW', etc.)\n```"
  ]
}
```

When to use this skill

  • Use this skill when an AI agent is asked to generate code snippets, provide explanations, or debug issues related to asynchronous functional programming in TypeScript, specifically utilizing `fp-ts`'s `TaskEither`. It's ideal for scenarios requiring a quick lookup of `TaskEither` creation, transformation, or error handling patterns.

When not to use this skill

  • Do not use this skill for direct execution of operations; it is purely a reference tool. It is not suitable if `fp-ts` or functional programming paradigms are not relevant to the user's task, or if the user simply needs to execute a basic JavaScript Promise without advanced error handling or `fp-ts` integration.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/fp-taskeither-ref/SKILL.md --create-dirs "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/plugins/antigravity-awesome-skills-claude/skills/fp-taskeither-ref/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/fp-taskeither-ref/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How fp-taskeither-ref Compares

Feature / Agentfp-taskeither-refStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexitynoneN/A

Frequently Asked Questions

What does this skill do?

Quick reference for TaskEither. Use when user needs async error handling, API calls, or Promise-based operations that can fail.

Which AI agents support this skill?

This skill is designed for Claude.

How difficult is it to install?

The installation complexity is rated as none. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# TaskEither Quick Reference

TaskEither = async operation that can fail. Like `Promise<Either<E, A>>`.

## When to Use

- You need a quick fp-ts reference for async operations that can fail.
- The task involves API calls, Promise wrapping, or composing asynchronous error-handling pipelines.
- You want a concise cheat sheet for `TaskEither` operators and patterns.

## Create

```typescript
import * as TE from 'fp-ts/TaskEither'

TE.right(value)          // Async success
TE.left(error)           // Async failure
TE.tryCatch(asyncFn, toError)  // Promise → TaskEither
TE.fromEither(either)    // Either → TaskEither
```

## Transform

```typescript
TE.map(fn)               // Transform success value
TE.mapLeft(fn)           // Transform error
TE.flatMap(fn)           // Chain (fn returns TaskEither)
TE.orElse(fn)            // Recover from error
```

## Execute

```typescript
// TaskEither is lazy - must call () to run
const result = await myTaskEither()  // Either<E, A>

// Or pattern match
await pipe(
  myTaskEither,
  TE.match(
    (err) => console.error(err),
    (val) => console.log(val)
  )
)()
```

## Common Patterns

```typescript
import { pipe } from 'fp-ts/function'
import * as TE from 'fp-ts/TaskEither'

// Wrap fetch
const fetchUser = (id: string) => TE.tryCatch(
  () => fetch(`/api/users/${id}`).then(r => r.json()),
  (e) => ({ type: 'NETWORK_ERROR', message: String(e) })
)

// Chain async calls
pipe(
  fetchUser('123'),
  TE.flatMap(user => fetchPosts(user.id)),
  TE.map(posts => posts.length)
)

// Parallel calls
import { sequenceT } from 'fp-ts/Apply'
sequenceT(TE.ApplyPar)(
  fetchUser('1'),
  fetchPosts('1'),
  fetchComments('1')
)

// With recovery
pipe(
  fetchUser('123'),
  TE.orElse(() => TE.right(defaultUser)),
  TE.getOrElse(() => defaultUser)
)
```

## vs async/await

```typescript
// ❌ async/await - errors hidden
async function getUser(id: string) {
  try {
    const res = await fetch(`/api/users/${id}`)
    return await res.json()
  } catch (e) {
    return null  // Error info lost
  }
}

// ✅ TaskEither - errors typed and composable
const getUser = (id: string) => pipe(
  TE.tryCatch(() => fetch(`/api/users/${id}`), toNetworkError),
  TE.flatMap(res => TE.tryCatch(() => res.json(), toParseError))
)
```

Use TaskEither when you need **typed errors** for async operations.

Related Skills

n8n-expression-syntax

31392
from sickn33/antigravity-awesome-skills

Validate n8n expression syntax and fix common errors. Use when writing n8n expressions, using {{}} syntax, accessing $json/$node variables, troubleshooting expression errors, or working with webhook data in workflows.

Developer ToolsClaude

mermaid-expert

31392
from sickn33/antigravity-awesome-skills

Create Mermaid diagrams for flowcharts, sequences, ERDs, and architectures. Masters syntax for all diagram types and styling.

Developer ToolsClaude

mcp-builder-ms

31392
from sickn33/antigravity-awesome-skills

Use this skill when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

Developer ToolsClaude

makepad-deployment

31392
from sickn33/antigravity-awesome-skills

CRITICAL: Use for Makepad packaging and deployment. Triggers on: deploy, package, APK, IPA, 打包, 部署, cargo-packager, cargo-makepad, WASM, Android, iOS, distribution, installer, .deb, .dmg, .nsis, GitHub Actions, CI, action, marketplace

Developer ToolsClaude

macos-menubar-tuist-app

31392
from sickn33/antigravity-awesome-skills

Build, refactor, or review SwiftUI macOS menubar apps that use Tuist.

Developer ToolsClaude

kaizen

31392
from sickn33/antigravity-awesome-skills

Guide for continuous improvement, error proofing, and standardization. Use this skill when the user wants to improve code quality, refactor, or discuss process improvements.

Developer ToolsClaude

issues

31392
from sickn33/antigravity-awesome-skills

Interact with GitHub issues - create, list, and view issues.

Developer ToolsClaude

hugging-face-tool-builder

31392
from sickn33/antigravity-awesome-skills

Your purpose is now is to create reusable command line scripts and utilities for using the Hugging Face API, allowing chaining, piping and intermediate processing where helpful. You can access the API directly, as well as use the hf command line tool.

Developer ToolsClaude

git-pushing

31392
from sickn33/antigravity-awesome-skills

Stage all changes, create a conventional commit, and push to the remote branch. Use when explicitly asks to push changes ("push this", "commit and push"), mentions saving work to remote ("save to github", "push to remote"), or completes a feature and wants to share it.

Developer ToolsClaude

git-hooks-automation

31392
from sickn33/antigravity-awesome-skills

Master Git hooks setup with Husky, lint-staged, pre-commit framework, and commitlint. Automate code quality gates, formatting, linting, and commit message enforcement before code reaches CI.

Developer ToolsClaude

gh-review-requests

31392
from sickn33/antigravity-awesome-skills

Fetch unread GitHub notifications for open PRs where review is requested from a specified team or opened by a team member. Use when asked to "find PRs I need to review", "show my review requests", "what needs my review", "fetch GitHub review requests", or "check team review queue".

Developer ToolsClaude

fp-types-ref

31392
from sickn33/antigravity-awesome-skills

Quick reference for fp-ts types. Use when user asks which type to use, needs Option/Either/Task decision help, or wants fp-ts imports.

Developer ToolsClaude