agentleFS
Poorgramer-ZackPoorgramer-Zack/dart-expert-skills/skills/fpdart/SKILL.md

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.

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
  1. Distinctive:

    Use primitives to handle common edge cases without branching logic:

    line 16
  2. Very specific:

    Monadic Integrity: Never use ! (bang operator) or force-casts on functional types.

    line 68

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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>: Replaces T?. Use Option.of(val) or Option.none(). Access via match or getOrElse.
  • Either<L, R>: Replaces try-catch. L (Left) is for errors, R (Right) is for success.
  • Unit: Replaces void to 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 for Future that never fails.
  • TaskEither<L, R>: The standard for API requests. Composes Future and Either into 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> (Safe first)
  • list.all((e) => ...) -> bool

Constraints

  • Zero Exceptions: Prohibit the use of throw for expected business errors. Force use of Either or TaskEither.
  • 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_collections for all state definitions.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.