- Home
- Skills
- Whatiskadudoing
- Fp Ts Skills
- Fp Compose
fp-compose_skill
2
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill whatiskadudoing/fp-ts-skills --skill fp-compose- SKILL.md18.7 KB
Overview
This skill teaches practical TypeScript function composition patterns using pipe, flow, and data-last design. It focuses on small, single-purpose utilities you can combine to build readable, testable pipelines without FP jargon. Expect concrete utilities for strings, numbers, arrays, validation, and debugging pipelines.
How this skill works
You write small functions that do one thing and compose them left-to-right with pipe or flow. Functions are designed data-last (configuration first, data last) so they can be partially applied and reused. The skill also shows adapters for data-first APIs, tracing helpers for debugging, and validator/async composition patterns.
When to use it
- Multi-step data transformation (API responses, form processing)
- Building reusable, configurable utilities (formatters, clamps, mappers)
- Creating specialized functions from general builders (HTTP clients, formatters)
- Validation chains that return Either/Option for composable error handling
- When you want clearer left-to-right logic and better testability
Best practices
- Keep functions single-responsibility and pure where possible
- Favor data-last argument order: configuration before data for partial application
- Use pipe for sequences and flow to build reusable composed functions
- Add small debug helpers (trace, traceIf, traceWith, breakpoint) to inspect pipeline state
- Avoid composition when a single simple function is clearer or when multiple independent inputs are required
Example use cases
- Clean and normalize user input: trim, lowercase, parse numbers, return typed object
- Create formatters: currency, percentage, price formatting built from small utilities
- Process arrays: map, filter, sort to compute totals or lists for UI
- Compose validators returning Either for stepwise validation with clear error messages
- Build specialized fetchers by partially applying a general HTTP client factory
FAQ
Avoid composition for trivial single-operation functions, for multi-argument operations that aren’t comfortably curried, or when the team is unfamiliar—prefer explicit code in those cases.
How do I debug a long pipeline?
Insert trace or traceIf between stages, use traceWith for structured logs, or add a breakpoint function to pause execution and inspect values.
How do I convert data-first APIs to data-last?
Wrap them in a small adapter that takes configuration first and returns a function that accepts the data last (e.g., map(fn) => (arr) => arr.map(fn), or formatDate(options)(locale)(date)).