fragment-context::new := λ. (: ( (let r FCtxEOF) r ) FContext); fragment-context::lookup := λ(: ctx FContext)(: k String)(: kt Type)(: sloc AST). (: ( (fragment-context::lookup( ctx k kt sloc True_u8 )) ) Fragment); fragment-context::lookup-soft := λ(: ctx FContext)(: k String)(: kt Type)(: sloc AST). (: ( (fragment-context::lookup( ctx k kt sloc False_u8 )) ) Fragment); fragment-context::lookup := λ(: ctx FContext)(: k String)(: kt Type)(: sloc AST)(: hard U8). (: ( (set k (find-alias( k kt ))) (let r (fragment::new())) (let found TAny) (while (non-zero ctx) (match ctx ( () ( (FCtxBind( rst rk rt rf )) ( (if (==( k rk )) ( (match (slot( rt 'Arrow_s )) ( () ( (TGround( 'Arrow_s (LCons( ranget (LCons( domaint LEOF )) )) )) ( (if (can-unify( domaint kt )) ( (if (non-zero found) ( (if (can-unify( found domaint )) ( (set r rf) (set found domaint) ) ()) ) ( (set r rf) (set found domaint) )) ) ()) (set ctx rst) )) ( _ ( (set r rf) (set found (t1 'LocalVariable_s)) (set ctx FCtxEOF) )) )) ) ( (set ctx rst) )) )) ))) (if (||( (non-zero( found )) (==( hard False_u8 )) )) () ( (print 'Context::lookup\s_s)(print k)(print '\s:\s_s)(print kt)(print '\n_s) (exit-error( 'Context::lookup\sCould\sNot\sFind\sSymbol_s sloc )) )) r ) Fragment); fragment-context::lookups := λ(: ctx FContext)(: k String)(: kt Type)(: sloc AST). (: ( (fragment-context::lookups( ctx k kt sloc True_u8 )) ) List); fragment-context::lookups := λ(: ctx FContext)(: k String)(: kt Type)(: sloc AST)(: hard U8). (: ( (set k (find-alias( k kt ))) (let r (: LEOF List)) (let found TAny) (while (non-zero ctx) (match ctx ( () ( (FCtxBind( rst rk rt rf )) ( (let is-hook (non-zero(slot( rt 'Hook_s )))) (if (==( k rk )) ( (match (slot( rt 'Arrow_s )) ( () ( (TGround( 'Arrow_s (LCons( ranget (LCons( domaint LEOF )) )) )) ( (if (can-unify( domaint kt )) ( (if (non-zero found) ( (if (can-unify( found domaint )) ( (if (!=( is-hook 0_u64 )) ( (set r (cons( rf r ))) ) ( (set r (cons( rf (: LEOF List) ))) (set found domaint) )) ) ()) ) ( (if (!=( is-hook 0_u64 )) ( (set r (cons( rf r ))) ) ( (set r (cons( rf (: LEOF List) ))) (set found domaint) )) )) ) ()) (set ctx rst) )) ( _ ( (if (!=( is-hook 0_u64 )) ( (set r (cons( rf r ))) ) ( (set r (cons( rf (: LEOF List) ))) (set ctx FCtxEOF) (set found (t1 'LocalVariable_s)) )) )) )) ) ( (set ctx rst) )) )) ))) (if (||( (!=( (.length r) 0_u64 )) (==( hard False_u8 )) )) () ( (print 'Context::lookups\s_s)(print k)(print '\s:\s_s)(print kt)(print '\n_s) (exit-error( 'Context::lookup\sCould\sNot\sFind\sSymbol_s sloc )) )) r ) List); fragment-context::lookup-vararg := λ(: ctx FContext)(: k String)(: kt Type)(: sloc AST). (: ( (let r FLEOF) (while (non-zero ctx) (match ctx ( () ( (FCtxBind( rst rk rt rf )) ( (if (==( k rk )) ( (set r (FLSeq( (close r) rf ))) ) ()) (set ctx rst) )) ))) r ) FragmentList); fragment-context::bind := λ(: ctx FContext)(: k String)(: kt Type)(: f Fragment). (: ( (let new-ctx (FCtxBind( (close ctx) k kt f ))) new-ctx ) FContext); fragment-context::bind-vararg := λ(: ctx FContext)(: k String)(: kt Type)(: f Fragment). (: ( (let new-ctx (FCtxBind( (close ctx) k kt f ))) new-ctx ) FContext);