Files
2nd/10_Wiki/Topics/Domain_Programming/Programming & Language/Effect TS.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

4.7 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-effect-ts Effect TS 10_Wiki/Topics verified self
Effect
Effect-TS
effect.ts
none A 0.9 applied
typescript
functional-programming
effect
error-handling
2026-05-10 pending
language framework
TypeScript Effect

Effect TS

매 한 줄

"매 TypeScript 의 functional effect system — error · concurrency · resource 매 type-level encoding". 매 ZIO (Scala) inspired library 의 TS port. 2026 시점 v3.x stable, Discord · Vercel · Stripe internal services 가 production 채택.

매 핵심

매 Effect<A, E, R>

  • A: success value type
  • E: error type (typed errors, no exceptions)
  • R: required services (DI context)
  • 매 lazy description — execution은 Effect.runPromise 시점.

매 핵심 primitives

  • Effect.succeed / Effect.fail / Effect.sync / Effect.tryPromise
  • Effect.gen (generator-based do-notation)
  • Effect.all (parallel), Effect.forEach (concurrency control)
  • Layer (DI composition), Context.Tag (service identity)

매 응용

  1. API gateway error contracts (HttpClient typed errors).
  2. Database transactional pipelines (Effect.scoped + Layer).
  3. Streaming ETL (Stream module).

💻 패턴

Effect.gen do-notation

import { Effect } from "effect"

const getUser = (id: string) =>
  Effect.gen(function* () {
    const db = yield* DatabaseService
    const user = yield* db.findUser(id)
    if (!user) return yield* Effect.fail(new UserNotFound({ id }))
    return user
  })

Typed errors (Data.TaggedError)

import { Data } from "effect"

class UserNotFound extends Data.TaggedError("UserNotFound")<{
  id: string
}> {}

class DbConnectionError extends Data.TaggedError("DbConnectionError")<{
  cause: unknown
}> {}

Layer composition

import { Effect, Layer, Context } from "effect"

class DatabaseService extends Context.Tag("DatabaseService")<
  DatabaseService,
  { findUser: (id: string) => Effect.Effect<User | null, DbConnectionError> }
>() {}

const DatabaseLive = Layer.succeed(DatabaseService, {
  findUser: (id) =>
    Effect.tryPromise({
      try: () => pgClient.query("SELECT * FROM users WHERE id=$1", [id]),
      catch: (cause) => new DbConnectionError({ cause }),
    }),
})

Concurrent execution

const fetchAll = Effect.forEach(
  ["a", "b", "c"],
  (id) => getUser(id),
  { concurrency: 5 }
)

Retry + timeout

import { Schedule, Duration } from "effect"

const robust = getUser("123").pipe(
  Effect.retry(Schedule.exponential(Duration.millis(100)).pipe(
    Schedule.compose(Schedule.recurs(3))
  )),
  Effect.timeout(Duration.seconds(5))
)

Resource scoping

const program = Effect.scoped(
  Effect.gen(function* () {
    const file = yield* Effect.acquireRelease(
      openFile("data.txt"),
      (f) => closeFile(f)
    )
    return yield* readContent(file)
  })
)

Schema validation

import { Schema } from "effect"

const User = Schema.Struct({
  id: Schema.String,
  age: Schema.Number.pipe(Schema.int(), Schema.nonNegative()),
})

const parse = Schema.decodeUnknown(User)

매 결정 기준

상황 Approach
단순 CRUD app plain async/await + zod
복잡한 error taxonomy Effect (typed errors)
Concurrency-heavy pipeline Effect (Schedule + Stream)
Team unfamiliar with FP neverthrow / fp-ts 시작

기본값: 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).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — Effect 3.x patterns, Layer/Schema/typed errors