Skip to content
OpenSmartRoute
Skillv1.0.0

fp-types-ref

Quick reference for fp-ts types. Use when user asks which type to use, needs Option/Either/Task decision help, or wants fp-ts imports.

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

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

See reviews

About

Imported from JantonioFC/skillsbank (skills/fp-types-ref/SKILL.md). Install upstream with npx skills add JantonioFC/skillsbank --skill fp-types-ref. Copyright stays with the author (MIT).

fp-ts Quick Reference

When to Use

  • You need help choosing between Option, Either, Task, TaskEither, or related fp-ts types.
  • The task is about imports, decision guidance, or selecting the right abstraction for a TypeScript flow.
  • You want a compact reference for common fp-ts type choices and patterns.

Which Type Should I Use?

Is the operation async?
├─ NO: Does it involve errors?
│   ├─ YES → Either<Error, Value>
│   └─ NO: Might value be missing?
│       ├─ YES → Option<Value>
│       └─ NO → Just use the value
└─ YES: Does it involve errors?
    ├─ YES → TaskEither<Error, Value>
    └─ NO: Might value be missing?
        ├─ YES → TaskOption<Value>
        └─ NO → Task<Value>

Common Imports

// Core
import { pipe, flow } from 'fp-ts/function'

// Types
import * as O from 'fp-ts/Option'      // Maybe exists
import * as E from 'fp-ts/Either'      // Success or failure
import * as TE from 'fp-ts/TaskEither' // Async + failure
import * as T from 'fp-ts/Task'        // Async (no failure)
import * as A from 'fp-ts/Array'       // Array utilities

One-Line Patterns

Need Code
Wrap nullable O.fromNullable(value)
Default value O.getOrElse(() => default)
Transform if exists O.map(fn)
Chain optionals O.flatMap(fn)
Wrap try/catch E.tryCatch(() => risky(), toError)
Wrap async TE.tryCatch(() => fetch(url), toError)
Run pipe pipe(value, fn1, fn2, fn3)

Pattern Match

// Option
pipe(maybe, O.match(
  () => 'nothing',
  (val) => `got ${val}`
))

// Either
pipe(result, E.match(
  (err) => `error: ${err}`,
  (val) => `success: ${val}`
))

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/jantoniofc-skillsbank-fp-types-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.

jantoniofc-skillsbank-fp-types-ref.ocm.jsonjson
{
  "ocm": "1",
  "id": "jantoniofc-skillsbank-fp-types-ref",
  "kind": "skill",
  "name": "fp-types-ref",
  "description": "Quick reference for fp-ts types. Use when user asks which type to use, needs Option/Either/Task decision help, or wants fp-ts imports.",
  "publisher": "JantonioFC",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "fp-ts",
      "typescript",
      "quick-reference",
      "option",
      "either",
      "task",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Quick reference for fp-ts types. Use when user asks which type to use, needs Option/Either/Task decision help, or wants fp-ts imports."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/JantonioFC/skillsbank",
      "path": "skills/fp-types-ref/SKILL.md",
      "ref": "512bb7e8cc67c53699d7697edf4376d0f4d64007",
      "url": "https://github.com/JantonioFC/skillsbank/blob/512bb7e8cc67c53699d7697edf4376d0f4d64007/skills/fp-types-ref/SKILL.md",
      "key": "JantonioFC/skillsbank/skills/fp-types-ref/SKILL.md"
    },
    "license": "MIT"
  },
  "instructions": "# fp-ts Quick Reference\n\n## When to Use\n- You need help choosing between `Option`, `Either`, `Task`, `TaskEither`, or related fp-ts types.\n- The task is about imports, decision guidance, or selecting the right abstraction for a TypeScript flow.\n- You want a compact reference for common fp-ts type choices and patterns.\n\n## Which Type Should I Use?\n\n```\nIs the operation async?\n├─ NO: Does it involve errors?\n│   ├─ YES → Either<Error, Value>\n│   └─ NO: Might value be missing?\n│       ├─ YES → Option<Value>\n│       └─ NO → Just use the value\n└─ YES: Does it involve errors?\n    ├─ YES → TaskEither<",
  "cost": {
    "context_tokens": 424
  }
}

Fetch it by URL: GET /api/v1/registry/jantoniofc-skillsbank-fp-types-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.