<< All versions
Skill v1.0.0
currentAutomated scan100/100om-varma12/405-found-mgm-hackathon/fp-types-ref
──Details
PublishedApril 28, 2026 at 06:32 AM
Content Hashsha256:0a7a3360460a26af...
Git SHAa74cbb5e7212
──Files
Files (1 file, 1.7 KB)
SKILL.md1.7 KBactive
SKILL.md · 69 lines · 1.7 KB
name: fp-types-ref description: 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. risk: safe source: community version: 1.0.0 tags: [fp-ts, typescript, quick-reference, option, either, task]
fp-ts Quick Reference
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
typescript
// Coreimport { pipe, flow } from 'fp-ts/function'// Typesimport * as O from 'fp-ts/Option' // Maybe existsimport * as E from 'fp-ts/Either' // Success or failureimport * as TE from 'fp-ts/TaskEither' // Async + failureimport * 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
typescript
// Optionpipe(maybe, O.match(() => 'nothing',(val) => `got ${val}`))// Eitherpipe(result, E.match((err) => `error: ${err}`,(val) => `success: ${val}`))