| 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. |
| type | skill |
| created | 2026-02-27T00:00:00.000Z |
| domain | communication-content |
| category | documentation |
| risk | unknown |
| source | community |
| tags | ["skill","communication-content","documentation","option","ref"] |
Option Quick Reference
Option = value that might not exist. Some(value) or None.
When to Use
- You need a quick fp-ts reference for nullable or optional values.
- The task involves eliminating null checks, safe property access, or optional chaining with
Option.
- You want a short reference card rather than a full migration guide.
Create
import * as O from 'fp-ts/Option'
O.some(5)
O.none
O.fromNullable(x)
O.fromPredicate(x > 0)(x)
Transform
O.map(fn)
O.flatMap(fn)
O.filter(predicate)
Extract
O.getOrElse(() => default)
O.toNullable(opt)
O.toUndefined(opt)
O.match(onNone, onSome)
Common Patterns
import { pipe } from 'fp-ts/function'
* O
(
O.(user),
O.( u.),
O.( O.(p.)),
O.( )
)
* A
(
users,
A.,
O.( u.),
O.( )
)