A Layer as constructor
A Layer describes how to build a service and supply its dependencies. A service is the named interface callers use for a job.ΒΆ
Sam compares the constructor pattern to a Layer and uses a React component as an analogy. In the same discussion, he connects the pattern to infrastructure policies. Watch from 18:45.ΒΆ
See Sam Goodwin on Alchemy10 and cartridges36.ΒΆ
Read why dependency injection matters14.ΒΆ
Sources
- Sam Goodwin - Alchemy - YouTube. Sam Goodwin. Layer composition discussion; used for infrastructure carried with a service. Accessed 2026-10-01.
Last changed 2026-10-07 in e73c9d9. Source on GitHub. Change log.
Linked from
- A service captures its construction dependencies. Build a service with its dependencies, then expose methods that callers can use without rebuilding the graph.
See also: domain structure, Layer composition, the Layer constructor pattern, and testing through services.ΒΆ
- Agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
A Layer as constructor β Sam Goodwin compares an Effect Layer that builds a service to a constructor.
- Change log. What changed in the files served here, newest first.
A Layer as constructor β edited: feat(learn): teach the next twenty cards with plain lines, diagrams and snippets
- Code snippets quote a pinned source. Shipped design brief: pinned Git objects, typed diagnostics, and one build-only snippet model for both views.
Layers provide the adapters.
- Dependency injection is the reason to choose Effect. Effect tracks service requirements in types and supplies replaceable implementations through Layers.
Read the Layer constructor pattern.ΒΆ
- Engine-neutral tokens keep adapters replaceable. The highlighter port exposes text, roles, and font styles rather than Shiki types.
Both adapters provide the same port through an Effect Layer.ΒΆ
- Full agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
- Hexagonal architecture. Ports name the application's jobs; adapters connect them to the outside world.
A Layer as constructor explains the construction mechanism.ΒΆ
- learn-rat-stack. Trace a capability through Effect, XState, five projections, the CLI, and Alchemy. Try hosted search and read.
The service exposes its Layer beside the implementation.
- Rat Stack lore | rat-stack. Short, source-grounded notes on the ideas and decisions behind rat-stack.
A Layer as constructor β Sam Goodwin compares an Effect Layer that builds a service to a constructor.
- rat-stack. An Effect stack so pure (aspirational) Kit Langton will blush.
- Source change history (log.md). The generated change log as Markdown.
A Layer as constructor β edited: feat(learn): teach the next twenty cards with plain lines, diagrams and snippets