跳到正文
Skillpedia
通用编程48k · #4647

fp-refactor

它能做什么

这个工具可以借助 fp-ts 库,把 TypeScript 中命令式(imperative)风格的代码改写成函数式编程风格。它还提供了一份完整的迁移指南。

适用场景

  • ✓当你想把现有的 TypeScript 代码重构为 fp-ts 的函数式模式时。
  • ✓当你需要把 `try/catch`、null 检查、回调或循环等代码块转换成函数式写法时。
  • ✓当你需要迁移指导和权衡取舍的说明,而不只是孤立的示例时。

技能链接

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

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-refactor/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想把命令式的 TypeScript 代码改写成 fp-ts 的函数式模式,其中包括 try/catch 和 null 检查的转换,该怎么做?”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具会分析你的 TypeScript 代码,并应用 fp-ts 库中的函数式编程模式。它会指导你用函数式写法替换命令式结构,比如用 `Either` 处理错误,用 `Option` 处理可选值。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Refactoring Imperative Code to fp-ts

This skill provides comprehensive patterns and strategies for migrating existing imperative TypeScript code to fp-ts functional programming patterns.

Detailed Guide

Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

When to Use

  • You are refactoring an existing imperative TypeScript codebase toward fp-ts patterns.
  • The task involves converting try/catch, null checks, callbacks, DI, or loops into functional equivalents.
  • You need migration guidance and tradeoffs, not just isolated fp-ts examples.

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.
常见问题

什么是函数式编程?

它是一种编程风格,把计算看作数学函数的求值过程,并避免改变状态和可变数据。

什么是 fp-ts?

它是一个用于 TypeScript 的库,把函数式编程的优势带入这门语言,提供了一些类型和函数,帮助你编写更健壮、表达力更强的代码。

什么是命令式代码?

它是一种编程风格,通过一步一步的指令描述程序应该如何改变自身的状态。

详情

作者的原始描述

Comprehensive guide for refactoring imperative TypeScript code to fp-ts functional patterns

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4647
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能