---
name: "arrow-kt-functional-programming-either"
description: "Eliminate unexpected runtime exceptions using typed Either, Raise, and Option in Kotlin."
metadata:
  author: "Arrow"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "use arrow either kotlin"
  - "raise dsl arrow-kt"
  - "typed error handling kotlin"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Arrow-kt Functional Programming & Typed Error Handling

Implements functional programming with Arrow-kt: Either<Error, Success>, Raise DSL (raise/ensure), converting exceptions into typed errors, accumulating validation errors (Either.zipOrAccumulate), and resource safety.

## When to Invoke
Invoke this skill whenever you need to:
- use arrow either kotlin
- raise dsl arrow-kt
- typed error handling kotlin

## Execution SOP & Rules
1. Define domain errors: sealed interface UserError; data class InvalidEmail(val msg: String) : UserError.
2. Write function with Raise: fun Raise<UserError>.createUser(email: String): User { ensure(email.contains('@')) { InvalidEmail('Invalid') }; ... }.
3. Call and unwrap: either { createUser(email) }.fold(ifLeft = { handleError(it) }, ifRight = { showUser(it) }).
4. Eliminate unexpected 500 server crashes by turning all failure modes into explicit compiler-enforced types.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
