Pattern Matching

Replace imperative control flow with exhaustive pattern matching in Effect code.

8|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/andrueandersoncs/claude-skill-effect-ts --skill pattern-matching-andrueandersoncs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Pattern Matching
Source: https://github.com/andrueandersoncs/claude-skill-effect-ts/tree/main/skills/pattern-matching
Command: npx skills add https://github.com/andrueandersoncs/claude-skill-effect-ts --skill pattern-matching-andrueandersoncs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pattern Matching replaces imperative control flow with safe, exhaustive pattern matching in Effect code.

Core Features & Use Cases

  • Exhaustive pattern matching for discriminated unions and tagged data
  • Type narrowing with Schema.is() and Match.type for robust, maintainable code
  • Reusable matchers (Match.type) and variants (Match.value, Match.tag) to simplify complex logic

Quick Start

Use the Pattern Matching skill to transform an if/else cascade into a single, expressive Match pipeline. For example, replace multiple conditional branches with Match.value(input).pipe(Match.when(...), Match.exhaustive). Then instantiate the matcher for reusable patterns and apply it across different inputs.

Frequently Asked Questions about Pattern Matching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace if/else cascades with exhaustive pattern matching in Effect?

Exhaustive pattern matching in Effect replaces if/else cascades by piping input through Match.value, Match.when, and Match.exhaustive to evaluate discriminated unions and enforce type safety. This approach ensures all branches resolve without unhandled cases.

What is the best way to handle type narrowing for tagged data in Effect?

Type narrowing for tagged data in Effect is handled using Schema.is integration and Match.type, which allows you to create reusable matchers that validate and narrow types within a Match pipeline for robust data-driven decisions.

Can I use Match.tag for discriminated unions in Effect without external setup?

Yes, you can use Match.tag for discriminated unions in Effect without external setup. The Match API operates natively within the Effect ecosystem, requiring no additional dependencies to evaluate tagged union variants.

When do I need Match.type for complex branching scenarios in Effect?

You need Match.type for complex branching scenarios in Effect when you want to instantiate reusable matchers. It simplifies logic by allowing you to apply the same pattern matching pipeline across different inputs and data structures.

Does Effect pattern matching require external dependencies to handle error control flow?

Effect pattern matching requires no external dependencies to handle error control flow. It leverages the built-in Match API to replace imperative logic with exhaustive checks for error handling and data-driven decisions directly.

Why use Match.value and Match.exhaustive instead of switch statements for type guards?

Using Match.value and Match.exhaustive instead of switch statements provides compile-time safety for type guards. It ensures that every discriminated union variant is explicitly handled, eliminating missing case errors in complex branching scenarios.