본문으로 건너뛰기
Skillpedia
일반 코딩48k · #4643

fp-option-ref

하는 일

이 도구는 코드에서 존재할 수도, 없을 수도 있는 값을 다루도록 돕습니다. 잠재적으로 없는 데이터를 안전하게 다루는 방법을 제공하며 흔한 오류를 막습니다.

사용하는 경우

  • ✓사용하기 전에 값이 있는지 확인해야 할 때.
  • ✓외부에서 와서 불완전할 수 있는 데이터를 다룰 때.
  • ✓기대한 값이 없을 때 오류 메시지를 피하고 싶을 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-option-ref/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-option-ref/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“사용자의 이름이 있는지 안전하게 확인하려면 어떻게 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

「Option」이라는 개념을 사용합니다. 값이 있으면 「Some(value)」, 없으면 「None」이 됩니다. 이렇게 하면 작업을 안전하게 연결할 수 있습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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 false

Extract

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 match

Common 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.

자주 묻는 질문

「Option」을 쓰는 것과 그냥 「null」이나 「undefined」인지 확인하는 것의 차이는 무엇인가요?

긴 확인 체인에서는 「Option」이 더 안전합니다. 값이 있는 경우와 없는 경우를 모두 명시적이고 체계적으로 처리하도록 강제하기 때문입니다.

「null」이나 「undefined」 값을 「Option」으로 바꿀 수 있나요?

네, `fromNullable` 같은 함수를 사용해 null일 수 있는 값을 「Option」으로 바꿀 수 있습니다.

존재하지 않는 값을 「Option」으로 사용하면 어떻게 되나요?

오류 대신, 보통 기본값이나 값이 없었다는 결과를 받게 됩니다. 설정 방식에 따라 다릅니다.

상세 정보

작성자의 원본 설명

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

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#4643
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬