fp-async_skill

This skill helps you build robust async pipelines with TaskEither, replacing try/catch chaos and improving error handling across APIs.

2

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill whatiskadudoing/fp-ts-skills --skill fp-async

  • SKILL.md23.2 KB

Overview

This skill teaches practical async patterns with fp-ts TaskEither to replace nested try/catch code with clear, type-safe pipelines. It focuses on wrapping promises, chaining dependent work, parallel vs sequential execution, and robust error recovery strategies using real API examples. Expect actionable patterns, small utilities, and ready-to-use snippets for Node/Browser/React projects.

How this skill works

The skill provides a small set of idiomatic helpers and patterns built around fp-ts TaskEither: a safe fetchJson wrapper, chain/map vs Do-notation for composing steps, parallel execution helpers (ApplyPar, traverseArray), and recovery utilities (orElse, retries, fallbacks). Each pattern shows how to convert thrown errors into typed error channels and how to keep async pipelines flat, testable, and composable. Examples include API request wrappers, batch processing with concurrency control, and typed error handling for differentiated recovery.

When to use it

  • Replace nested try/catch blocks with composable async pipelines
  • Compose multiple dependent async calls where failure must short-circuit
  • Run independent requests in parallel to improve throughput
  • Implement retries, backoff, or fallback strategies for unreliable APIs
  • Limit concurrency when calling many endpoints to avoid rate limits

Best practices

  • Wrap every Promise-producing call once (e.g., fetchJson) using TE.tryCatch to preserve error context
  • Use TE.chain for async/possibly-failing steps and TE.map for pure transforms
  • Use TE.Do and TE.bind to build readable context objects instead of threading values manually
  • Choose ApplyPar/sequenceT or traverseArray for parallel work; be aware it fails fast on first error
  • Control concurrency by batching work (chunk + traverseArray per batch) instead of blind parallelism

Example use cases

  • Fetch user, posts, and related resources with a single TaskEither pipeline instead of nested awaits
  • Process an order: fetch order → fetch user → check inventory → charge → ship, all as a flat TE.Do flow
  • Fetch dashboard data in parallel (user, notifications, activity) and combine results into a UI model
  • Retry a flaky network call with exponential backoff wrapped as a reusable retry(operation, attempts) helper
  • Batch-fetch many user profiles in chunks of N to respect rate limits while keeping parallelism

FAQ

TaskEither handles async errors in a typed channel so you avoid try/catch for flow control, but use try/catch for local synchronous code or when interacting with non-TaskEither APIs.

How do I recover from specific HTTP errors?

Return a discriminated error type from your wrapper (e.g., NotFound, Unauthorized) and use TE.orElse to conditionally handle or rethrow based on the tag.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
fp-async skill by whatiskadudoing/fp-ts-skills | VeilStrat