- Home
- Skills
- Nonameplum
- Agent Skills
- Functional Programming Developer
functional-programming-developer_skill
- Swift
11
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill nonameplum/agent-skills --skill functional-programming-developer- SKILL.md1.4 KB
Overview
This skill provides practical guidance for designing functional architecture in Swift, emphasizing immutability, pure functions, and explicit effects. It focuses on domain and core logic: reducers, workflows, and dependency-injected use cases that are highly testable. The guidance favors functional techniques first and OO/protocol approaches only where they serve boundaries.
How this skill works
The skill inspects common domain design choices and recommends a functional core with an imperative shell. It explains how to model state and events with algebraic data types, implement reducers and Mealy-style state machines, and represent effects as data. It also prescribes dependency injection via closures or capability structs and testing with fake closures rather than mocks.
When to use it
- Modeling domain and business logic separate from UI
- Designing reducers, workflows, and state machines
- Writing dependency-injected use cases that must be testable
- Refactoring code that is hard to unit test
- Building features that need composable, predictable behavior
Best practices
- Prefer immutability and pure functions in the core domain
- Use closures for DI first, capability structs second, protocols only at boundaries
- Represent effects as data and handle them in an imperative shell
- Keep unit tests focused on the core; avoid timers and sleeps
- Use enums and structs for algebraic data types and strong state modeling
- Fake closures in tests instead of creating heavy mocks
Example use cases
- Implementing a reducer-driven feature where state transitions are pure and side effects are described as data
- Defining a Mealy or extended state machine for complex workflows
- Creating a set of use cases injected via curried functions for easy testing
- Refactoring a view model to a functional core + small imperative shell to simplify tests
- Composing domain logic with optics (lenses/prisms) to work with nested immutable state
FAQ
Use protocols only at module boundaries or when you need multiple implementations that must be swapped at runtime. Prefer closures for simple, testable injection inside the core.
How do I test effects described as data?
Keep the core pure and return an effects description. In tests, assert the effects produced. Execute effects in an outer integration layer or test harness when necessary.