Skip to content
← Volver al catálogo
Desarrollosegurocommunity

fp-types-ref

Referencia rápida para tipos de fp-ts. Úsalo cuando el usuario pregunta qué tipo usar, necesita ayuda en la decisión Option/Either/Task, o quiere imports de fp-ts.

El contenido de este skill está en su idioma original (a menudo inglés).

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

NeedCode
Wrap nullableO.fromNullable(value)
Default valueO.getOrElse(() => default)
Transform if existsO.map(fn)
Chain optionalsO.flatMap(fn)
Wrap try/catchE.tryCatch(() => risky(), toError)
Wrap asyncTE.tryCatch(() => fetch(url), toError)
Run pipepipe(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}`
))

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
— Field Manual

Las 1.441 skills, desmitificadas en un PDF.

Una guía editorial gratuita que escribimos para Skills Atlas: taxonomía, las 25 skills imprescindibles, antipatrones, rutas de aprendizaje por perfil.

  • 70+ páginas, índice, lista para imprimir.
  • Enviado por email — enlace válido 7 días.
  • Cancela suscripción en un clic cuando quieras.

Sin spam. Nunca compartimos tu email. Cancelación en un clic.