fp-option-ref
Quick reference for Option type. Use when user needs to handle nullable values, optional data, or wants to avoid null checks.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Quick reference for Option type. Use when user needs to handle nullable values, optional data, or wants to avoid null checks.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Product types, sum types, semigroups, monoids, Eq, Ord, and building custom type class instances for domain modeling in TypeScript
Practical async patterns using TaskEither - clean pipelines instead of try/catch hell, with real API examples
Functional programming patterns for Node.js/Deno backend development using fp-ts, ReaderTaskEither, and functional dependency injection
Practical patterns for composing functions in TypeScript using pipe, flow, and functional design principles
Everyday data transformations using functional patterns - arrays, objects, grouping, aggregation, and null-safe access
Master Do notation in fp-ts to write readable, sequential functional code without callback hell. Covers bind, apS, let, bindTo and real-world patterns.
| name | fp-option-ref |
| description | Quick reference for Option type. Use when user needs to handle nullable values, optional data, or wants to avoid null checks. |
| version | 1.0.0 |
| tags | ["fp-ts","option","nullable","maybe","quick-reference"] |
Option = value that might not exist. Some(value) or None.
import * as O from 'fp-ts/Option'
O.some(5) // Some(5)
O.none // None
O.fromNullable(x) // null/undefined → None, else Some(x)
O.fromPredicate(x > 0)(x) // false → None, true → Some(x)
O.map(fn) // Transform inner value
O.flatMap(fn) // Chain Options (fn returns Option)
O.filter(predicate) // None if predicate false
O.getOrElse(() => default) // Get value or default
O.toNullable(opt) // Back to T | null
O.toUndefined(opt) // Back to T | undefined
O.match(onNone, onSome) // Pattern match
import { pipe } from 'fp-ts/function'
import * as O from 'fp-ts/Option'
// Safe property access
pipe(
O.fromNullable(user),
O.map(u => u.profile),
O.flatMap(p => O.fromNullable(p.avatar)),
O.getOrElse(() => '/default-avatar.png')
)
// Array first element
import * as A from 'fp-ts/Array'
pipe(
users,
A.head, // Option<User>
O.map(u => u.name),
O.getOrElse(() => 'No users')
)
// ❌ Nullable - easy to forget checks
const name = user?.profile?.name ?? 'Guest'
// ✅ Option - explicit, composable
pipe(
O.fromNullable(user),
O.flatMap(u => O.fromNullable(u.profile)),
O.map(p => p.name),
O.getOrElse(() => 'Guest')
)
Use Option when you need to chain operations on optional values.