- 신선한 탐사자(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
27 lines
1.2 KiB
Text
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})
|