fp-option-ref – skill Dữ liệu & Khoa học cho agent AI
Tài liệu tham khảo nhanh về kiểu Option. Dùng khi cần xử lý giá trị có thể null, dữ liệu tùy chọn hoặc muốn tránh kiểm tra null.
Cài skill fp-option-ref bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/fp-option-ref-196bb.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /fp-option-ref – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/fp-option-ref-196bb.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $fp-option-ref – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/fp-option-ref-196bb.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /fp-option-ref – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/fp-option-ref-196bb.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /fp-option-ref – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
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((n: number) => n > 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 falseExtract
O.getOrElse(() => fallbackValue) // Get value or default
O.toNullable(opt) // Back to T | null
O.toUndefined(opt) // Back to T | undefined
O.match(onNone, onSome) // Pattern matchCommon Patterns
import { pipe } from 'fp-ts/function'
import * as O from 'fp-ts/Option'
// Safe property access
pipe(
O.fromNullable(user),
O.flatMap(u => O.fromNullable(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: concise and safe for a short access chain
const name = user?.profile?.name ?? 'Guest'
// Option: explicit and composable across multiple operations
pipe(
O.fromNullable(user),
O.flatMap(u => O.fromNullable(u.profile)),
O.flatMap(p => O.fromNullable(p.name)),
O.getOrElse(() => 'Guest')
)Use Option when you need to chain operations on optional values.
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/).
Skill liên quan
- fp-pipe-ref – Tài liệu tham khảo nhanh về pipe và flow. Dùng khi cần nối chuỗi hàm, kết hợp phép toán…
- senior-data-engineer – Skill data engineering để xây dựng data pipelines có khả năng mở rộng, hệ thống ETL/ELT…
- gdpr-compliance – Triển khai các yêu cầu bảo vệ dữ liệu GDPR. Cấu hình quản lý consent, quyền của chủ thể…
- senior-data-scientist – Skill data scientist cấp cao hàng đầu, chuyên về mô hình thống kê, thiết kế thử nghiệm…
- gdpr-data-handling – Hướng dẫn thực hành triển khai thiết kế xử lý dữ liệu theo GDPR, quản lý consent và các…
- gemini-deep-research – Chạy nghiên cứu tự động nhiều bước với Gemini Deep Research Agent của Google: khởi tạo…
- geo-crawlers – Phân tích quyền truy cập của AI crawler.
- senior-ml-engineer – Kỹ năng kỹ sư ML để đưa model vào production, xây dựng pipeline MLOps và tích hợp LLM…