fp-ts Quick Reference
When to Use
- You need help choosing between
Option, Either, Task, TaskEither, or related fp-ts types.
- The task is about imports, decision guidance, or selecting the right abstraction for a TypeScript flow.
- You want a compact reference for common fp-ts type choices and patterns.
Which Type Should I Use?
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>
Common Imports
// 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
One-Line Patterns
| 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) |
Pattern Match
// Option
pipe(maybe, O.match(
() => 'nothing',
(val) => `got ${val}`
))
// Either
pipe(result, E.match(
(err) => `error: ${err}`,
(val) => `success: ${val}`
))
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Source: sickn33/agentic-awesome-skills → skills/fp-types-ref/SKILL.md
Also appears in: sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/fp-types-ref/SKILL.md, sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/fp-types-ref/SKILL.md
1---
2name: fp-types-ref
3description: "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."
4category: general-purpose
5source_repo: sickn33/agentic-awesome-skills
6source_path: "skills/fp-types-ref/SKILL.md"
7source_url: https://github.com/sickn33/agentic-awesome-skills/blob/HEAD/skills/fp-types-ref/SKILL.md
8metadata:
9 source: https://skillmd.com/skills/thedixitjain/fp-types-ref
10---
11
12
13# fp-ts Quick Reference
14
15## When to Use
16- You need help choosing between `Option`, `Either`, `Task`, `TaskEither`, or related fp-ts types.
17- The task is about imports, decision guidance, or selecting the right abstraction for a TypeScript flow.
18- You want a compact reference for common fp-ts type choices and patterns.
19
20## Which Type Should I Use?
21
22```
23Is the operation async?
24├─ NO: Does it involve errors?
25│ ├─ YES → Either<Error, Value>
26│ └─ NO: Might value be missing?
27│ ├─ YES → Option<Value>
28│ └─ NO → Just use the value
29└─ YES: Does it involve errors?
30 ├─ YES → TaskEither<Error, Value>
31 └─ NO: Might value be missing?
32 ├─ YES → TaskOption<Value>
33 └─ NO → Task<Value>
34```
35
36## Common Imports
37
38```typescript
39// Core
40import { pipe, flow } from 'fp-ts/function'
41
42// Types
43import * as O from 'fp-ts/Option' // Maybe exists
44import * as E from 'fp-ts/Either' // Success or failure
45import * as TE from 'fp-ts/TaskEither' // Async + failure
46import * as T from 'fp-ts/Task' // Async (no failure)
47import * as A from 'fp-ts/Array' // Array utilities
48```
49
50## One-Line Patterns
51
52| Need | Code |
53|------|------|
54| Wrap nullable | `O.fromNullable(value)` |
55| Default value | `O.getOrElse(() => default)` |
56| Transform if exists | `O.map(fn)` |
57| Chain optionals | `O.flatMap(fn)` |
58| Wrap try/catch | `E.tryCatch(() => risky(), toError)` |
59| Wrap async | `TE.tryCatch(() => fetch(url), toError)` |
60| Run pipe | `pipe(value, fn1, fn2, fn3)` |
61
62## Pattern Match
63
64```typescript
65// Option
66pipe(maybe, O.match(
67 () => 'nothing',
68 (val) => `got ${val}`
69))
70
71// Either
72pipe(result, E.match(
73 (err) => `error: ${err}`,
74 (val) => `success: ${val}`
75))
76```
77
78## Limitations
79- Use this skill only when the task clearly matches the scope described above.
80- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
81- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
82
83---
84
85**Source:** [`sickn33/agentic-awesome-skills`](https://github.com/sickn33/agentic-awesome-skills) → `skills/fp-types-ref/SKILL.md`
86
87**Also appears in:** `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/fp-types-ref/SKILL.md`, `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/fp-types-ref/SKILL.md`