using-fpdart
Skill7 starsChanged 8 months agoMITView on GitHub
Functional error handling in Dart using the fpdart package with Either, Option, TaskEither, and Do notation. Use when replacing try-catch with type-safe error handling or composing async operations functionally.
In this repository41 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- skill-creatorSkill
- flutter-dbSkill
- flutter-routingSkill
- flutter-state-managementSkill
- configuring-codemagicSkill
- applying-effective-dartSkill
- deploying-with-fastlaneSkill
- integrating-firebaseSkill
- implementing-fl-chartSkill
- integrating-google-adsSkill
- animating-flutter-widgetsSkill
- routing-with-autorouteSkill
- implementing-flutter-blocSkill
- configuring-deep-linksSkill
- persisting-data-with-driftSkill
- building-flutter-production-appsSkill
- generating-flutter-uiSkill
- routing-with-gorouterSkill
- managing-hive-storageSkill
- using-flutter-hooksSkill
- running-flutter-isolatesSkill
- managing-flutter-provider-stateSkill
- implementing-responsive-layoutsSkill
- implementing-riverpodSkill
- managing-secure-storageSkill
- flutter-setupSkill
- managing-shared-preferencesSkill
- implementing-flutter-social-authSkill
- flutter-testingSkill
- generating-freezed-modelsSkill
- configuring-github-actionsSkill
- building-jaspr-web-appsSkill
- testing-with-marionetteSkill
- implementing-openapi-in-dartSkill
- integrating-revenuecatSkill
- integrating-sentrySkill
- developing-serverpod-backendSkill
- building-shadcn-flutter-uiSkill
- integrating-supabaseSkill
- converting-ts-to-dartSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use primitives to handle common edge cases without branching logic:
- Very specific: line 68
Monadic Integrity: Never use ! (bang operator) or force-casts on functional types.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Functional Programming with fpdart
Goal
Implement robust, type-safe, and predictable business logic using functional programming principles. Replace side-effect-prone imperative code with pure functions and composable monads (Option, Either, Task), ensuring that error handling and null-safety are enforced at the type level rather than through runtime exceptions.
Process
Phase 1: Basic Data Containment
Use primitives to handle common edge cases without branching logic:
Option<T>: ReplacesT?. UseOption.of(val)orOption.none(). Access viamatchorgetOrElse.Either<L, R>: Replacestry-catch.L(Left) is for errors,R(Right) is for success.Unit: Replacesvoidto allow functional composition.
Phase 2: Execution & Async Flow
Manage side effects and asynchronous operations through wrappers that defer execution:
IO<T>: Synchronous wrapper for pure/safe side effects.Task<T>: Asynchronous wrapper forFuturethat never fails.TaskEither<L, R>: The standard for API requests. ComposesFutureandEitherinto a single monadic flow.
Phase 3: Advanced Linear Chaining
Utilize the Do Notation to flatten nested flatMap calls into readable, imperative-style blocks while preserving monadic safety:
return TaskEither.Do(($) async {
final user = await $(repository.getUser(id));
final profile = await $(api.getProfile(user.code));
return profile.toDomain();
});⚡ Quick Reference
Error Handling (Either)
Either<String, int> checkValue(int v) =>
v > 10 ? Either.of(v) : Either.left('Too small');
final result = checkValue(5).match(
(error) => 'Failure: $error',
(value) => 'Success: $value',
);Async Operations (TaskEither)
TaskEither<Exception, User> fetchUser(String id) =>
TaskEither.tryCatch(
() => api.getUser(id),
(error, stack) => Exception('Fetch failed: $error'),
);Collections Extension
fpdart extends Iterable with safer methods:
list.head->Option<T>(Safefirst)list.all((e) => ...)->bool
Constraints
- Zero Exceptions: Prohibit the use of
throwfor expected business errors. Force use ofEitherorTaskEither. - Monadic Integrity: Never use
!(bang operator) or force-casts on functional types. Always use safe extraction methods (match,getOrElse). - Linear Logic: Mandatory use of Do notation when chaining more than two monadic operations to prevent "callback hell."
- Immutability First: Combine with
fast_immutable_collectionsfor all state definitions.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

