> fp-option-ref
Quick reference for Option type. Use when user needs to handle nullable values, optional data, or wants to avoid null checks.
curl "https://skillshub.wtf/sickn33/antigravity-awesome-skills/fp-option-ref?format=md"Option Quick Reference
Option = value that might not exist. Some(value) or None.
Create
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)
Transform
O.map(fn) // Transform inner value
O.flatMap(fn) // Chain Options (fn returns Option)
O.filter(predicate) // None if predicate false
Extract
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
Common Patterns
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')
)
vs Nullable
// ❌ 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.
> related_skills --same-repo
> zustand-store-ts
Create Zustand stores following established patterns with proper TypeScript types and middleware.
> zoom-automation
Automate Zoom meeting creation, management, recordings, webinars, and participant tracking via Rube MCP (Composio). Always search tools first for current schemas.
> zoho-crm-automation
Automate Zoho CRM tasks via Rube MCP (Composio): create/update records, search contacts, manage leads, and convert leads. Always search tools first for current schemas.
> zod-validation-expert
Expert in Zod — TypeScript-first schema validation. Covers parsing, custom errors, refinements, type inference, and integration with React Hook Form, Next.js, and tRPC.