fp-option-ref

Solid

Quick reference for Option type. Use when user needs to handle nullable values, optional data, or wants to avoid null checks.

AI & Automation 39,350 stars 6386 forks Updated today MIT

Install

View on GitHub

Quality Score: 97/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
90
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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 ```typescript 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 ```typescript O.map(fn) // Transform inner value O.flatMap(fn) // Chain Options (fn returns Option) O.filter(predicate) // None if predicate false ``` ## Extract ```typescript 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 ```typescript 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 ```typescript // ❌ Nullable - ea...

Details

Author
sickn33
Repository
sickn33/antigravity-awesome-skills
Created
4 months ago
Last Updated
today
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category