universalist
Algebra-Driven Design (ADD): model domains via minimal algebra + laws; encode in types; test laws.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Universalist
Intent
Use Algebra-Driven Design (ADD) to find the smallest algebra that fits the domain, encode it in types, and enforce laws with tests.
Core workflow (ADD)
- Frame the domain: observations, invariants, operations.
- Pick the minimal algebra; avoid overfitting.
- Define types: make illegal states unrepresentable.
- State laws: identity, associativity, distributivity, absorption, round-trip, homomorphism.
- Derive operations from the algebra (map/fold/compose) to reduce ad hoc branching.
- Refactor architecture to match algebra boundaries.
- Test the laws (property/model/metamorphic checks).
- Iterate: if laws are hard to state or test, the algebra is likely wrong.
Minimal-algebra decision guide
- Alternatives/variants → coproduct (tagged union)
- Independent fields → product (record/struct)
- Combine + identity → monoid
- Combine, no identity → semigroup
- Ordering/permissions → poset/lattice
- Add+multiply structure → semiring
- Structure-preserving map → functor
- Effectful apply → applicative
- Sequenced effects → monad
Testing expectations
- Include law/property tests for the chosen algebra.
- Prefer property-based checks when the repo already supports them.
- If not, write minimal deterministic law checks in the existing test framework.
- Don’t assume tooling exists; propose new dependencies only with user approval.
References
-
references/addd-overview.md -
references/addd-sources.md -
references/structures-and-laws.md -
references/testing-playbook.md -
references/case-studies.md -
references/examples-haskell.md -
references/examples-go.md -
references/examples-typescript.md
Scripts
-
scripts/emit_law_test_stub.shprints illustrative law-test stubs for Haskell, Go, or TypeScript.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!