本文へスキップ
Skillpedia
一般的なプログラミング48k · #4652

fp-types-ref

できること

fp-tsライブラリのOption、Either、Taskなどの型のなかから適切なものを選び、TypeScriptのコードを整理する手助けをします。特に、値が存在しないかもしれない場合や、エラーが起こりうる非同期処理を扱うときに役立ちます。

使う場面

  • ✓Option、Either、Task、TaskEitherのどれを使うか決めたいとき。
  • ✓fp-tsの型のインポート方法がわからないとき。
  • ✓よく使うfp-tsのパターンを手早く確認したいとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-types-ref/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“エラーが起こる可能性があり、かつ非同期の関数には、fp-tsのどの型を使うのがよいですか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIは、処理が非同期かどうか、失敗する可能性があるか、値が存在しない可能性があるかに基づいて、簡単なフローチャートで選択を案内します。また、インポートや一般的なパターンのコード例も提供します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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'        // Lazy async; no typed error channel
import * as A from 'fp-ts/Array'       // Array utilities

One-Line Patterns

Need Code
Wrap nullable O.fromNullable(value)
Default value O.getOrElse(() => fallbackValue)
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}`
))

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、Either、Taskとは何ですか?

よくあるプログラミングの場面を、より安全で整理された方法で扱うための型です。値が存在しないかもしれない場合(Option)、成功または失敗する処理(Either)、完了までに時間がかかる処理(Task)などに使います。

「非同期」とはどういう意味ですか?

処理がすぐに終わるのではなく、将来のどこかの時点で完了することを意味します。サーバーからのデータ取得やファイルの読み込みなどが例です。

fp-tsとは何ですか?

TypeScriptで人気のあるライブラリで、関数型プログラミングの考え方を取り入れ、より堅牢で予測しやすいコードを書くのに役立ちます。

詳細

作者による元の説明

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.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#4652
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル