- Home
- Skills
- Whatiskadudoing
- Fp Ts Skills
- Fp Pragmatic
fp-pragmatic_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-pragmatic- SKILL.md15.2 KB
Overview
This skill is a practical, jargon-free guide to functional programming that focuses on the 80/20 patterns that deliver real benefits. It strips away category theory and shows patterns you can apply today to make code clearer, safer, and easier to refactor. The emphasis is on readability and using FP only when it improves the code.
How this skill works
The skill teaches five core patterns: pipe for linear data flow, Option for nullable values, Either for explicit errors, map to transform inside containers, and flatMap to chain fallible steps. Each pattern is presented with before/after examples and plain-language translations so you can adopt them immediately. It also covers when to avoid FP and quick practical refactors for immediate wins.
When to use it
- When you have 3+ transformations that benefit from top-to-bottom flow
- When values may be missing and you want to avoid scattered null checks
- When you want errors represented as values instead of thrown exceptions
- When multiple steps might fail and you need clear error propagation
- When a refactor will improve maintainability without hiding intent
Best practices
- Prefer readability: if FP makes it harder for your team, don’t use it
- Start with pipe, Option, Either, map, and flatMap before exploring advanced features
- Use Option for nullable returns and Either for expected failures
- Keep hot paths imperative for performance-sensitive loops
- Convert string errors to typed error shapes for safer handling
Example use cases
- Parsing and validating user input with Either and flatMap
- Safely accessing nested properties with Option chains
- Replacing nested callbacks or promise chains with TaskEither pipelines
- Transforming arrays and container values using map without unpacking
- Quickly turning try/catch JSON parsing into E.tryCatch one-liners
FAQ
No. Use FP where it improves clarity or error handling. Keep simple loops and performance-critical code imperative.
How do I start introducing these patterns to a team?
Start small: replace obvious null checks with Option, use pipe for multi-step transforms, and add short examples in code reviews to teach patterns.