From antigravity-awesome-skills
Provides quick reference for fp-ts types in TypeScript with decision tree for Option/Either/TaskEither/TaskOption, common imports, and one-line patterns. Use for type selection or import help.
npx claudepluginhub sickn33/antigravity-awesome-skillsThis skill uses the workspace's default tool permissions.
- You need help choosing between `Option`, `Either`, `Task`, `TaskEither`, or related fp-ts types.
Provides quick reference for fp-ts types in TypeScript with decision tree for Option/Either/TaskEither/TaskOption, common imports, and one-line patterns. Use for type selection or import help.
Provides TypeScript functional patterns for ADTs, discriminated unions, Result/Option types, branded types. Use for state machines, type-safe domain models, and error handling.
Guides Effect-TS usage in TypeScript for writing, reviewing, debugging: paradigm shift, typed errors, layers/services DI, fiber concurrency, streams, schema validation, migrations from fp-ts/Promises.
Share bugs, ideas, or general feedback.
Option, Either, Task, TaskEither, or related fp-ts types.Is the operation async?
├─ NO: Does it involve errors?
│ ├─ YES → Either<Error, Value>
│ └─ NO: Might value be missing?
│ ├─ YES → Option<Value>
│ └─ NO → Just use the value
└─ YES: Does it involve errors?
├─ YES → TaskEither<Error, Value>
└─ NO: Might value be missing?
├─ YES → TaskOption<Value>
└─ NO → Task<Value>
// Core
import { pipe, flow } from 'fp-ts/function'
// Types
import * as O from 'fp-ts/Option' // Maybe exists
import * as E from 'fp-ts/Either' // Success or failure
import * as TE from 'fp-ts/TaskEither' // Async + failure
import * as T from 'fp-ts/Task' // Async (no failure)
import * as A from 'fp-ts/Array' // Array utilities
| Need | Code |
|---|---|
| Wrap nullable | O.fromNullable(value) |
| Default value | O.getOrElse(() => default) |
| Transform if exists | O.map(fn) |
| Chain optionals | O.flatMap(fn) |
| Wrap try/catch | E.tryCatch(() => risky(), toError) |
| Wrap async | TE.tryCatch(() => fetch(url), toError) |
| Run pipe | pipe(value, fn1, fn2, fn3) |
// Option
pipe(maybe, O.match(
() => 'nothing',
(val) => `got ${val}`
))
// Either
pipe(result, E.match(
(err) => `error: ${err}`,
(val) => `success: ${val}`
))