Chuyển đến nội dung
Skillpedia
Lập trình chung48k · #4644

fp-pipe-ref

Skill này làm gì

Các công cụ này giúp tổ chức chuỗi hành động trong mã. `pipe` áp dụng một loạt phép biến đổi cho một giá trị cùng lúc. `flow` tạo ra một hàm mới kết hợp nhiều phép biến đổi để dùng sau này.

Khi nào nên dùng

  • ✓Khi bạn cần áp dụng nhiều bước xử lý cho dữ liệu.
  • ✓Khi bạn muốn tạo một hàm có thể tái sử dụng để xử lý dữ liệu theo cách cụ thể.
  • ✓Khi làm việc với các thư viện tổ chức hàm thành chuỗi.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-pipe-ref/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm thế nào để biến đổi một chuỗi bằng cách xóa khoảng trắng thừa, viết hoa và sau đó tách thành các từ?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Hàm `pipe` nhận một giá trị ban đầu và đưa nó qua một loạt hàm, lần lượt từng hàm. Hàm `flow` kết hợp nhiều hàm thành một hàm mới, có thể dùng để xử lý các giá trị khác nhau theo cùng một cách.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

pipe & flow Quick Reference

pipe - Transform a Value

import { pipe } from 'fp-ts/function'

// pipe(startValue, fn1, fn2, fn3)
// = fn3(fn2(fn1(startValue)))

const result = pipe(
  '  hello world  ',
  s => s.trim(),
  s => s.toUpperCase(),
  s => s.split(' ')
)
// ['HELLO', 'WORLD']

flow - Create Reusable Pipeline

import { flow } from 'fp-ts/function'

// flow(fn1, fn2, fn3) returns a new function
const process = flow(
  (s: string) => s.trim(),
  s => s.toUpperCase(),
  s => s.split(' ')
)

process('  hello world  ') // ['HELLO', 'WORLD']
process('  foo bar  ')     // ['FOO', 'BAR']

When to Use

Use When
pipe Transform a specific value now
flow Create reusable transformation

With fp-ts Types

import * as O from 'fp-ts/Option'
import * as A from 'fp-ts/Array'

// Option chain
pipe(
  O.fromNullable(user),
  O.flatMap(u => O.fromNullable(u.email)),
  O.getOrElse(() => 'no email')
)

// Array chain
pipe(
  users,
  A.filter(u => u.active),
  A.map(u => u.name)
)

Common Pattern

// Data last enables partial application
const getActiveNames = flow(
  A.filter((u: User) => u.active),
  A.map(u => u.name)
)

// Reuse anywhere
getActiveNames(users1)
getActiveNames(users2)

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.

Câu hỏi thường gặp

Khác biệt giữa `pipe` và `flow` là gì?

`pipe` dùng để biến đổi một giá trị cụ thể ngay lúc đó, áp dụng các hàm theo thứ tự. `flow` dùng để tạo một hàm mới kết hợp các phép biến đổi, để dùng nhiều lần sau này.

`pipe` và `flow` dùng để làm gì?

Chúng giúp nối hoặc kết hợp các hàm, làm mã dễ đọc và có tổ chức hơn, đặc biệt khi có nhiều bước xử lý.

Tôi có thể dùng cái này với mọi kiểu dữ liệu không?

Có, miễn là các hàm bạn dùng trong `pipe` hoặc `flow` tương thích với kiểu dữ liệu được truyền giữa chúng.

Chi tiết

Mô tả gốc của tác giả

Quick reference for pipe and flow. Use when user needs to chain functions, compose operations, or build data pipelines in fp-ts.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4644
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự