fp-either-ref – Other skill for AI agents
Quick reference for Either type. Use when user needs error handling, validation, or operations that can fail with typed errors.
Install the fp-either-ref skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/fp-either-ref-c4389.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /fp-either-ref – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/fp-either-ref-c4389.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $fp-either-ref – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/fp-either-ref-c4389.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /fp-either-ref – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/fp-either-ref-c4389.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /fp-either-ref – then describe the task you want done.
SKILL.md content
Either Quick Reference
Either = success or failure. Right(value) or Left(error).
When to Use
- You need a quick fp-ts reference for typed synchronous error handling.
- The task involves validation, fallible operations, or converting throwing code to
Either. - You want a compact cheat sheet rather than a long tutorial.
Create
import * as E from 'fp-ts/Either'
E.right(value) // Success
E.left(error) // Failure
E.fromNullable(err)(x) // null → Left(err), else Right(x)
E.tryCatch(fn, toError) // try/catch → EitherTransform
E.map(fn) // Transform Right value
E.mapLeft(fn) // Transform Left error
E.flatMap(fn) // Chain (fn returns Either)
E.filterOrElse(pred, toErr) // Right → Left if pred failsExtract
E.getOrElse(err => fallbackValue) // Get Right or default
E.match(onLeft, onRight) // Pattern match
E.toUnion(either) // E | A (loses type info)Common Patterns
import { pipe, identity } from 'fp-ts/function'
import * as E from 'fp-ts/Either'
// Toy validation; an @ check is not complete email validation
const validateEmail = (s: string): E.Either<string, string> =>
s.includes('@') ? E.right(s) : E.left('Invalid email')
// Chain validations (stops at first error)
pipe(
E.right({ email: '[email protected]', age: 25 }),
E.flatMap(d => pipe(validateEmail(d.email), E.map(() => d))),
E.flatMap(d => d.age >= 18 ? E.right(d) : E.left('Must be 18+'))
)
// Convert throwing code
const parseJson = (s: string) => E.tryCatch(
() => JSON.parse(s),
(e) => `Parse error: ${e}`
)vs try/catch
// ❌ try/catch - errors not in types
try {
const data = JSON.parse(input)
process(data)
} catch (e) {
handleError(e)
}
// ✅ Either - errors explicit in types
pipe(
E.tryCatch(() => JSON.parse(input), String),
E.flatMap(data => E.tryCatch(() => process(data), String)),
E.match(handleError, identity)
)Use Either when error type matters and you want to chain operations.
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.
Reference scope
These are fp-ts 2.x fragments. Supply application variables, types, validators and imports, and check the installed version. map does not catch thrown exceptions. Task has no typed error channel; an improperly wrapped promise can still reject. Use tryCatch at fallible boundaries.
Official API: [fp-ts modules](https://gcanti.github.io/fp-ts/modules/).
Related skills
- fp-types-ref – Quick reference for fp-ts types. Use when user asks which type to use, needs…
- fxmacrodata – Query FXMacroData for official-source macro indicators, release calendars, central-bank…
- gamification-engine – Gamification points register: player and department, points balance and points earned…
- geminiignore-finops – Configure and optimize .geminiignore files for AI context window efficiency and token…
- geo-citability – AI citability scoring and optimization.
- geo-compare – Monthly delta tracking and progress reporting for GEO clients.
- geo-fundamentals – Generative Engine Optimization for AI search engines (ChatGPT, Claude, Perplexity).
- geo-keyword-expansion-tool – Geo Keyword Expansion Tool. Use when working with seed keyword and target locations.