Skip to content
Skillv1.0.0

fp-option-ref

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

by FISCFED9(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from FISCFED9/CLI (.agents/skills/plugins/antigravity-awesome-skills-claude/skills/fp-option-ref/SKILL.md). Install upstream with npx skills add FISCFED9/CLI --skill fp-option-ref. Copyright stays with the author.

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)              // 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.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/fiscfed9-cli-fp-option-ref/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

fiscfed9-cli-fp-option-ref.ocm.jsonjson
{
  "ocm": "1",
  "id": "fiscfed9-cli-fp-option-ref",
  "kind": "skill",
  "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.",
  "publisher": "FISCFED9",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "fp-ts",
      "option",
      "nullable",
      "maybe",
      "quick-reference",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Quick reference for Option type. Use when user needs to handle nullable values, optional data, or wants to avoid null checks."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/FISCFED9/CLI",
      "path": ".agents/skills/plugins/antigravity-awesome-skills-claude/skills/fp-option-ref/SKILL.md",
      "ref": "dc5c68e06bbbffb3a2ddd72a79e277b71b02b0e9",
      "url": "https://github.com/FISCFED9/CLI/blob/dc5c68e06bbbffb3a2ddd72a79e277b71b02b0e9/.agents/skills/plugins/antigravity-awesome-skills-claude/skills/fp-option-ref/SKILL.md",
      "key": "FISCFED9/CLI/.agents/skills/plugins/antigravity-awesome-skills-claude/skills/fp-option-ref/SKILL.md"
    }
  },
  "instructions": "# Option Quick Reference\n\nOption = value that might not exist. `Some(value)` or `None`.\n\n## When to Use\n\n- You need a quick fp-ts reference for nullable or optional values.\n- The task involves eliminating null checks, safe property access, or optional chaining with `Option`.\n- You want a short reference card rather than a full migration guide.\n\n## Create\n\n```typescript\nimport * as O from 'fp-ts/Option'\n\nO.some(5)              // Some(5)\nO.none                 // None\nO.fromNullable(x)      // null/undefined → None, else Some(x)\nO.fromPredicate(x > 0)(x) // false → None, true → Some(x)\n```\n\n## ",
  "cost": {
    "context_tokens": 450
  }
}

Fetch it by URL: GET /api/v1/registry/fiscfed9-cli-fp-option-ref/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.