quad/.claude/audit/handtrace-round10-reference-impl/spikes/ty2_effect_deps.luau
qwreey d2d67c7aeb
qa: 10라운드 광범위 탐사 완료 — 발견 H-150~H-157 (🔴 0 / 🟡 5 / 🟢 3), §4 배치 문항 7건 회신 대기
- 신선한 탐사자(fable) 단일 컨텍스트, 지시서 -round10-brief.md §2 레인 A·C 완료, B 부분, D ALL PASS
- audit/handtrace-round10-reference-impl/: round7 참조 구현을 현재 계약으로 갱신·재실행
  (부수: round7/ref9 _recompute 첫 인자 오류 발견·정정)
- base/·인덱스 레이어는 미변경 — 결정은 사용자 배치 회신 뒤 -round10-followup.md로

Co-authored-by: qwreey <me@qwreey.moe>
Claude-Session: https://claude.ai/code/session_01546hjsYNLSMZdHdPyTZaGb
2026-08-28 01:03:05 +09:00

27 lines
1.2 KiB
Text

--!strict
-- base/effect-plan.md: Effect(fn, ...deps) — deps는 State/Source(→Observer)와
-- Ref(→:Callback)가 섞인다. fn엔 deps가 안 넘어간다(H-14).
export type StateData<T> = { Get: (self: StateData<T>) -> T }
export type State<T> = StateData<T> & {
Compute: <U>(self: StateData<T>, fn: (self: StateData<T>) -> U) -> State<U>,
}
export type Ref<T> = { Value: T?, Set: (self: Ref<T>, v: T) -> (), Callback: (self: Ref<T>, fn: (T) -> ()) -> () }
export type EffectHandle = { Rerun: (self: EffectHandle) -> (), Subscribe: (self: EffectHandle) -> () }
type Dep = State<any> | Ref<any>
local function Effect(fn: (self: EffectHandle) -> (() -> ())?, ...: Dep): EffectHandle
return nil :: any
end
local n: State<number> = nil :: any
local b: State<boolean> = nil :: any
local r: Ref<Instance> = nil :: any
-- (A) State 하나
local e1 = Effect(function(self) return nil end, n)
-- (B) 이형 State 둘
local e2 = Effect(function(self) return nil end, n, b)
-- (C) State + Ref 섞기 — effect-plan.md가 확정한 대표 용례
local e3 = Effect(function(self) return nil end, n, r)
-- (D) 음성 대조군 — 아무 테이블이나 넣으면 걸려야 정상
local e4 = Effect(function(self) return nil end, {foo = 1})