Effect primer
Pressline’s server is Effect throughout. What you meet in the code:
Effect<A, E, R>: a description of a computation producingA, failing with typedE, needing servicesR. Nothing runs until a runtime runs it.Effect.gen(function* () { const x = yield* step; … })sequences steps.- Services are
Context.Tags (Db,Psp,FulfillmentProvider,Mailer,DesignSource,Config); Layers build them. Tests provide in-memory layers; production provides adapters. The web handler is built once from aLayerof services. The service-layer view draws the five services and their adapters. - Errors are
Schema.TaggedErrorclasses; the HTTP layer maps each to a status.Effect.eitherwhen you want to inspect a failure;Effect.orDiefor infrastructure faults that are bugs, not outcomes. - Schema validates every boundary: config, env, API bodies, database rows, provider wire shapes.
- HttpApi: endpoints are declared once (
api.ts), implemented by groups, served byHttpApiBuilder.toWebHandler, and the same declaration produces the OpenAPI document. The Engine-facing contract is its ownHttpApiin@pressline/contract, from which the Engine client is derived. - Clock: time comes from Effect’s
Clock, so tests advance it.
Read docs/adr/0011-effect-throughout.md for why.