home / skills / nonameplum / agent-skills / swift-case-paths

swift-case-paths skill

/swift-case-paths

This skill helps you work with Swift enum cases as first-class values by enabling key path-like access and clean navigation.

npx playbooks add skill nonameplum/agent-skills --skill swift-case-paths

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
609 B
---
name: swift-case-paths
description: A library for working with enum cases as first-class values, enabling key path-like access to enum cases
---

# CasePaths/CasePathable()

See the [`CasePathsCore`](../casepathscore) module for the `CasePathable` protocol and other core

## Documentation Structure

## Usage Notes

- Documentation is organized progressively from getting started to advanced topics
- Start with the Introduction or Getting Started section
- Consult specific guides for detailed information

## License & Attribution

This skill contains content converted from DocC documentation format.

Overview

This skill documents swift-case-paths, a library that treats enum cases as first-class values and enables key path–like access to enum cases. It focuses on progressive documentation from introduction through advanced topics and includes a DocC converter used to generate the skill content. The material helps developers learn how to create, compose, and apply case paths in Swift code.

How this skill works

The documentation explains the CasePathable protocol and related CasePathsCore primitives that represent extraction and embedding of enum cases as value-level functions. It demonstrates how to construct case paths for enum cases, compose them like key paths, and use them to match, transform, or extract associated values. The DocC converter translates Apple-style DocC pages into this skill format for easy consumption by AI coding assistants.

When to use it

  • When you need to match Swift enum cases without writing repetitive switch statements.
  • When you want to extract or embed associated values from enum cases in a composable way.
  • When implementing functional-style transformations over enums in application or library code.
  • When building generic utilities that operate on enum cases across modules.
  • When documenting or teaching enum-related patterns and you prefer progressive, example-driven guides.

Best practices

  • Start with the Introduction or Getting Started sections to learn core concepts before advanced topics.
  • Prefer composing simple case paths for nested enums instead of deep switches or manual pattern matching.
  • Use CasePathable and the CasePathsCore primitives for interoperability across codebases.
  • Keep case path helpers small and focused; treat them like key paths rather than complex functions.
  • Consult the module-level guides for common patterns and performance considerations.

Example use cases

  • Creating a reusable extractor that pulls associated values from multiple enum variants.
  • Composing case paths to access deeply nested associated values across enum wrappers.
  • Implementing reducers or state handlers that dispatch based on enum cases using case paths.
  • Writing tests that assert behavior by extracting values from result enums in a concise way.

FAQ

Is this skill the official library documentation?

No. This skill contains converted DocC content for documentation convenience and is not the official source.

Where do I start learning case paths?

Begin with the Introduction or Getting Started sections to grasp CasePathable and basic composition patterns.