import{Effect,Layer,Context}from"effect"classDatabaseServiceextendsContext.Tag("DatabaseService")<DatabaseService,{findUser:(id: string)=>Effect.Effect<User|null,DbConnectionError>}>(){}constDatabaseLive=Layer.succeed(DatabaseService,{findUser:(id)=>Effect.tryPromise({try:()=>pgClient.query("SELECT * FROM users WHERE id=$1",[id]),catch:(cause)=>newDbConnectionError({cause}),}),})
기본값: greenfield TS backend with complex error contracts → Effect 채택. 매 learning curve 높음 — team buy-in 매 우선.
🔗 Graph
부모: Functional Programming · TypeScript 타입 시스템 및 인터페이스 설계
변형: Result Type
응용: 견고한 도메인 모델 및 API 계약 설계 · API 응답 및 에러 핸들링 아키텍처
Adjacent: Zod 런타임 유효성 검사 통합 · ts-brand
🤖 LLM 활용
언제: TS backend with strict error typing, dependency injection at type level, retry/circuit-breaker policies.
언제 X: 매 simple script · prototype · React component logic — overhead 매 큼.
❌ 안티패턴
Effect.runSync everywhere: 매 sync execution 강제 — async benefit 상실.
Fail with strings: typed TaggedError 의 사용해야 매 discriminated handling 가능.
Layer.merge spaghetti: 매 dependency graph 의 명시적 organize.
🧪 검증 / 중복
Verified (effect.website official docs · Effect 3.x release notes 2025).