fp-taskeither-ref

Featured

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

AI & Automation 39,350 stars 6386 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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)), T...

Details

Author
sickn33
Repository
sickn33/antigravity-awesome-skills
Created
4 months ago
Last Updated
today
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category