pipe & flow Quick Reference
Selective Reading Rule
Start with:
references/senior-master-standard.md
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
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.map(u => 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.
1---2name: fp-pipe-ref3description: ALWAYS use this when the user mentions FP Pipe REF, asks to build, debug, review, document, automate, test, configure, migrate, or make decisions in this domain, or the task clearly depends on FP Pipe REF; scope: Quick reference for pipe and flow. Apply the bundled workflow, references, scripts, Senior Master standard, and Codex strict review gate before final output.4---56# pipe & flow Quick Reference78## Selective Reading Rule910Start with:1112- `references/senior-master-standard.md`13- `references/usage-routing.md`14- `references/quality-checklist.md`1516Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.1718## pipe - Transform a Value1920```typescript21import { pipe } from 'fp-ts/function'2223// pipe(startValue, fn1, fn2, fn3)24// = fn3(fn2(fn1(startValue)))2526const result = pipe(27 ' hello world ',28 s => s.trim(),29 s => s.toUpperCase(),30 s => s.split(' ')31)32// ['HELLO', 'WORLD']33```3435## flow - Create Reusable Pipeline3637```typescript38import { flow } from 'fp-ts/function'3940// flow(fn1, fn2, fn3) returns a new function41const process = flow(42 (s: string) => s.trim(),43 s => s.toUpperCase(),44 s => s.split(' ')45)4647process(' hello world ') // ['HELLO', 'WORLD']48process(' foo bar ') // ['FOO', 'BAR']49```5051## When to Use52| Use | When |53|-----|------|54| `pipe` | Transform a specific value now |55| `flow` | Create reusable transformation |5657## With fp-ts Types5859```typescript60import * as O from 'fp-ts/Option'61import * as A from 'fp-ts/Array'6263// Option chain64pipe(65 O.fromNullable(user),66 O.map(u => u.email),67 O.getOrElse(() => 'no email')68)6970// Array chain71pipe(72 users,73 A.filter(u => u.active),74 A.map(u => u.name)75)76```7778## Common Pattern7980```typescript81// Data last enables partial application82const getActiveNames = flow(83 A.filter((u: User) => u.active),84 A.map(u => u.name)85)8687// Reuse anywhere88getActiveNames(users1)89getActiveNames(users2)90```9192## Limitations93- Use this skill only when the task clearly matches the scope described above.94- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.95- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.