--!strict -- base/source-state-plan.md: state:Apply(factory) — `factory: (State) -> U): U` -- base/debounce-throttle-plan.md 5-4: Debounce{...}가 돌려주는 것은 __call 테이블 -- (setmetatable({}, {__call = ..., __index = {Flush=..., Cancel=...}})) -- base/gate-plan.md 2번: "__call 테이블이 Luau에서 (State) -> U 함수 타입 자리에 -- 그대로 들어가는지가 불확실하다(들어가지 않는 쪽이 유력)" — 확인 안 하기로 접었음 export type StateData = { Get: (self: StateData) -> T } export type State = StateData & { Compute: (self: StateData, fn: (self: StateData) -> U) -> State, Apply: (self: State, factory: (State) -> U) -> U, } local s: State = nil :: any -- (A) 평범한 함수 팩토리 — 양성 대조군 local a = s:Apply(function(self: State): State return self end) -- (B) __call 테이블 팩토리 — 5-4절이 확정한 모양 type GateFactory = typeof(setmetatable( {} :: { Flush: () -> (), Cancel: () -> () }, {} :: { __call: (any, State) -> State } )) local Debounced: GateFactory = nil :: any local b = s:Apply(Debounced) -- (C) 직접 호출은 되는가 local c = Debounced(s)