Effect Service Architect (v3)
Instructions
- Service Tag: Define the service using
Effect.Tag.export class MyService extends Effect.Tag("MyService")<MyService, { readonly getData: () => Effect.Effect<Data, MyError> }>() {} - Implementation: Create the
Livelayer usingLayer.effectorLayer.succeed.export const MyServiceLive = Layer.effect( MyService, Effect.gen(function* () { // Implementation logic return { getData: () => Effect.succeed({ ... }) } }) ) - Error Handling: Use
Data.TaggedErrorfor all domain-specific errors.export class MyError extends Data.TaggedError("MyError")<{ readonly message: string }> {} - Composition: Use
pipefor simple flows andEffect.genwithyield*for complex sequential logic. - Verification:
- Run
tsc --noEmitto verify type inference. - Ensure all
Effect.tryPromisecalls include acatchblock for typed errors.
- Run
Patterns to Enforce
- NO explicit return type annotations unless necessary (let inference work).
- NO
try/catchblocks insideEffect.gen(useEffect.catchAlletc.). - ALWAYS use
yield*when calling an Effect insideEffect.gen.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.