checking-option-and-either-cases

A pattern for checking whether an Option contains a value or whether an Either represents success or failure.

In plain words
What is it for?
Use it to handle optional data with Option and successful or failed results with Either in Effect-TS code.
Why use it?
It makes conditional handling explicit and type-safe instead of relying on unclear null checks or unstructured error values.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/pauljphilp/effectpatterns/checking-option-and-either-cases
Clone the repo
git clone --depth 1 https://github.com/PaulJPhilp/EffectPatterns
Per session 371 This file is loaded in full into every session.
When invoked 371 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00371 $0.00371
Opus 5 $0.00186 $0.00186
Sonnet 5 $0.00074 $0.00074
Haiku 4.5 $0.00037 $0.00037

Measured 2d ago against content hash 201f65972f93, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

checking-option-and-either-cases scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

content/published/rules/cursor/checking-option-and-either-cases.mdc · 46 lines

What it actually says

description: Use isSome, isNone, isLeft, and isRight to check Option and Either cases for simple, type-safe conditional logic. globs: "**/*.ts" alwaysApply: true

Checking Option and Either Cases

Rule: Use isSome, isNone, isLeft, and isRight to check Option and Either cases for simple, type-safe conditional logic.

Example

import { Option, Either } from "effect";

// Option: Check if value is Some or None
const option = Option.some(42);

if (Option.isSome(option)) {
  // option.value is available here
  console.log("We have a value:", option.value);
} else if (Option.isNone(option)) {
  console.log("No value present");
}

// Either: Check if value is Right or Left
const either = Either.left("error");

if (Either.isRight(either)) {
  // either.right is available here
  console.log("Success:", either.right);
} else if (Either.isLeft(either)) {
  // either.left is available here
  console.log("Failure:", either.left);
}

// Filtering a collection of Options
const options = [Option.some(1), Option.none(), Option.some(3)];
const presentValues = options.filter(Option.isSome).map((o) => o.value); // [1, 3]

Explanation:

  • Option.isSome and Option.isNone let you check for presence or absence.
  • Either.isRight and Either.isLeft let you check for success or failure.
  • These are especially useful for filtering or quick conditional logic.

Explanation:
These predicates provide a concise, type-safe way to check which case you have, without resorting to manual property checks or unsafe type assertions.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 46 lines · 371 tokens per session scan A 201f65972f93

Subscribe to this mod's changes

checking-option-and-either-cases is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (795 stars, last pushed 2mo ago), licensed MIT. It adds 371 tokens to every session, about $0.0019 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.