- 신선한 탐사자(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
23 lines
852 B
Text
23 lines
852 B
Text
--!strict
|
|
export type StateData<T> = { Get: (self: StateData<T>) -> T }
|
|
export type State<T> = StateData<T> & {
|
|
Apply: <U>(self: State<T>, factory: (State<T>) -> U) -> U,
|
|
}
|
|
local s: State<number> = nil :: any
|
|
|
|
type GateFactory = typeof(setmetatable(
|
|
{} :: { Flush: () -> (), Cancel: () -> () },
|
|
{} :: { __call: (any, State<number>) -> State<number> }
|
|
))
|
|
local Debounced: GateFactory = nil :: any
|
|
|
|
-- (A) 제네릭이 아닌 평범한 함수 파라미터 자리에도 안 들어가는가?
|
|
local function takesFn(f: (State<number>) -> State<number>) return f(s) end
|
|
local a = takesFn(Debounced)
|
|
|
|
-- (B) 유니온으로 열면 되는가
|
|
local function takesEither(f: ((State<number>) -> State<number>) | GateFactory)
|
|
return (f :: any)(s)
|
|
end
|
|
local b = takesEither(Debounced)
|
|
local b2 = takesEither(function(x: State<number>) return x end)
|