Back to skills
SkillHub ClubAnalyze Data & AIFull StackData / AI

fp-option-ref

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

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
4
Hot score
81
Updated
March 20, 2026
Overall rating
C1.4
Composite score
1.4
Best-practice grade
S96.0

Install command

npx @skill-hub/cli install whatiskadudoing-fp-ts-skills-fp-option-ref
fp-tsoptionnullablemaybequick-reference

Repository

whatiskadudoing/fp-ts-skills

Skill path: skills/quick-ref/fp-option-ref

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

Open repository

Best for

Primary workflow: Analyze Data & AI.

Technical facets: Full Stack, Data / AI.

Target audience: everyone.

License: Unknown.

Original source

Catalog source: SkillHub Club.

Repository owner: whatiskadudoing.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install fp-option-ref into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/whatiskadudoing/fp-ts-skills before adding fp-option-ref to shared team environments
  • Use fp-option-ref for development workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
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 Quick Reference

Option = value that might not exist. `Some(value)` or `None`.

## 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 - 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.
fp-option-ref | SkillHub