Set up Effect services architecture

effect-servicesskillsetup L261
kriegcloud/beep-effect
What it does

Define typed services in Effect v4 with Context.Service and Layers

Best for

When defining services in Effect v4 with compile-time type safety and explicit dependency wiring.

Inputs
  • · service class definition
  • · constructor effect
  • · dependency list
Outputs
  • · Context.Service subclass
  • · Layer.effect binding
Requires
  • · Effect
  • · TypeScript 5+
Preconditions

Effect v4 project; understanding of Effect.gen and Layer composition

Failure modes
  • · Using string literals instead of IdentityComposer $I tags (loses compile-time validation)
  • · shape type mismatch between class and service
  • · Layer.provide order matters for dependency resolution
Trust signals
  • · IdentityComposer key validation at runtime
  • · class nominal typing prevents accidental mix-ups
  • · Layer composition example provided