@@ -874,7 +874,7 @@
874874 %'~[' %'|=(' %'$-(' :: openers
875875 %'%/' %'/' :: paths
876876 %'+' %'`' %'=' :: pair, unit, face
877− %'*' %'?' %'_' :: noun, loobean, type hole
877+ %'*' %'?' :: noun, loobean mold
878878 %'++' %'+$' %'|=' %'|$' :: runes
879879 %'^-' %'~&' %'?-' %'!!' :: runes
880880 %'/-' %'/%' %'/=' :: imports
@@ -1016,7 +1016,6 @@
10161016 [%const at=span =lit] :: ~ %add %.y
10171017 [%ref at=span names=(list term)] :: state item.todo
10181018 [%tvar at=span name=@t] :: M
1019− [%hole at=span ~] :: _
10201019 [%path at=span segs=(list pseg)] :: / /todos /todo/[id=@ud]
10211020 [%apply at=span ref=(list term) args=(list shape)] :: (list @t)
10221021 [%cell at=span fields=(list field)] :: [text=@t done=?]
@@ -1025,9 +1024,9 @@
10251024 [%generic at=span vars=(list @t) body=shape] :: +$ name |$ [M] …
10261025 ==
10271026::
1028−:: +pseg: a path mold's segment, a knot, [name=aura], or [name=_]
1027+:: +pseg: a path mold's segment, a knot or [name=aura]
10291028::
1030−+$ pseg $%([%knot p=@ta] [%typed at=span name=term aura=@ta] [%inferred at=span name=term hole-at=span])
1029++$ pseg $%([%knot p=@ta] [%typed at=span name=term aura=@ta])
10311030::
10321031+| %api
10331032::
@@ -1296,7 +1295,6 @@
12961295 (emit 1 %'=')
12971296 ?: =('`' a) (emit 1 %'`')
12981297 ?: =('*' a) (emit 1 %'*')
1299− ?: =('_' a) (emit 1 %'_')
13001298 ?: =('~' a)
13011299 ?: =('[' b) (emit 2 %'~[')
13021300 ?: =('&' b) (emit 2 %'~&')
@@ -1672,14 +1670,14 @@
16721670:: What may begin each place the parser reads (section 3, Errors):
16731671:: an expression a-z 0-9 " ( [ ~ % / ` | ^ ? !
16741672:: an operand a-z 0-9 " ( [ ~ % / ` | !
1675−:: a mold a-z A-Z @ * ! ? ~ % / ( [ $ _
1673+:: a mold a-z A-Z @ * ! ? ~ % / ( [ $
16761674:: a pattern a-z 0-9 " ~ % * [
16771675:: and what may go tight after an operand: . ( + = after a name, a
16781676:: closer ) ] }, or the : of a comment
16791677::
16801678++ expr-mask 0x57ff.ffff.4800.0000.83ff.8126.0000.0000
16811679++ operand-mask 0x57ff.ffff.0800.0000.03ff.8126.0000.0000
1682−++ mold-mask 0x47ff.fffe.8fff.ffff.8000.8532.0000.0000
1680+++ mold-mask 0x47ff.fffe.0fff.ffff.8000.8532.0000.0000
16831681++ bar-mask 0x1000.0000.0000.0000.0000.0000.0000.0000
16841682++ pattern-mask 0x47ff.fffe.0800.0000.03ff.0424.0000.0000
16851683++ after-mask 0x2000.0000.2000.0000.2400.4b00.0000.0000
@@ -2109,7 +2107,6 @@
21092107 ?- -.s
21102108 %knot (weld "/" (trip p.s))
21112109 %typed "/[{(trip name.s)}=@{(trip aura.s)}]"
2112− %inferred "/[{(trip name.s)}=_]"
21132110 ==
21142111::
21152112++ show-tvars
@@ -2321,7 +2318,6 @@
23212318 %const (nod "const" at.s (show-lit lit.s) ~)
23222319 %ref (nod "ref" at.s (show-names names.s) ~)
23232320 %tvar (nod "tvar" at.s (trip name.s) ~)
2324− %hole (nod "hole" at.s "" ~)
23252321 %path (nod "path" at.s (show-psegs segs.s) ~)
23262322 %apply (nod "apply" at.s (show-names ref.s) (turn args.s sexp-shape))
23272323 %cell (nod "cell" at.s "" (turn fields.s sexp-field))
@@ -3846,7 +3842,6 @@
38463842 %'*' [%& [%noun at.t ~] t.ts]
38473843 %'!!' [%& [%void at.t ~] t.ts]
38483844 %'?' [%& [%flag at.t ~] t.ts]
3849− %'_' [%& [%hole at.t ~] t.ts]
38503845 [%name *] [%& [%ref at.t ~[p.lex.t]] t.ts]
38513846 [%wing *] [%& [%ref at.t p.lex.t] t.ts]
38523847 [%tvar *] [%& [%tvar at.t p.lex.t] t.ts]
@@ -4063,7 +4058,7 @@
40634058 ?: &(?=(^ nex) tight.i.nex) (bad nex "a path segment")
40644059 (bad-space i.after nex "a path segment")
40654060 ::
4066− :: +read-pseg: a path mold's knot, [name=aura], or [name=_] with no
4061+ :: +read-pseg: a path mold's segment, a knot or [name=aura] with no
40674062 :: spaces, and where it ends
40684063 ::
40694064 ++ read-pseg
@@ -4080,16 +4075,13 @@
40804075 ?: |(?=(~ r2) !tight.i.r2) (bad-space i.r1 r2 "`=`")
40814076 ?. ?=([[* * %'='] *] r2) (bad-in r2 "`=`" tis-mask)
40824077 =/ r3=(list token) t.r2
4083− ?: |(?=(~ r3) !tight.i.r3) (bad-space i.r2 r3 "an aura or type hole")
4084− ?. ?=([[* * ?([%aura *] %'_')] *] r3) (bad-in r3 "an aura or type hole" (con pat-mask (bex 95)))
4078+ ?: |(?=(~ r3) !tight.i.r3) (bad-space i.r2 r3 "an aura")
4079+ ?. ?=([[* * [%aura *]] *] r3) (bad-in r3 "an aura" pat-mask)
40854080 =/ r4=(list token) t.r3
40864081 ?: |(?=(~ r4) !tight.i.r4) (bad-space i.r3 r4 "`]`")
40874082 ?. ?=([[* * %']'] *] r4) (bad-in r4 "`]`" ser-mask)
40884083 =/ at=span [beg.at.op end.at.i.r4]
4089− =/ seg=pseg
4090− ?: ?=(%'_' lex.i.r3) [%inferred at p.lex.i.r1 at.i.r3]
4091− [%typed at p.lex.i.r1 p.lex.i.r3]
4092− [%& [seg end.at.i.r4] t.r4]
4084+ [%& [[%typed at p.lex.i.r1 p.lex.i.r3] end.at.i.r4] t.r4]
40934085 --
40944086::
40954087+| %span-check
@@ -4473,7 +4465,6 @@
44734465 %const [%const at.s ~[%lit] %one ~]
44744466 %ref [%ref at.s ~[%name %wing] %one ~]
44754467 %tvar [%tvar at.s ~[%tvar] %one ~]
4476− %hole [%hole at.s ~[%'_'] %one ~]
44774468 %apply [%apply at.s ~[%'('] %shut (turn args.s outline-shape)]
44784469 %cell [%cell at.s ~[%'['] %shut (turn fields.s outline-sample)]
44794470 ::
@@ -4482,11 +4473,8 @@
44824473 %+ murn segs.s
44834474 |= g=pseg
44844475 ^- (unit outline)
4485− ?- -.g
4486− %knot ~
4487− %typed `[%typed at.g ~[%'['] %shut ~]
4488− %inferred `[%typed at.g ~[%'['] %shut ~[[%hole hole-at.g ~[%'_'] %one ~]]]
4489− ==
4476+ ?. ?=(%typed -.g) ~
4477+ `[%typed at.g ~[%'['] %shut ~]
44904478 [%path at.s ~[%'/'] %run ks]
44914479 ::
44924480 %union
@@ -4546,8 +4534,6 @@
45464534 [%path [1 9] [1 9] [1 21]]
45474535 [%face [1 7] [1 7] [1 21]]
45484536 ==
4549− :: an inferred path aura's hole spanning its = as well
4550− ['+$ x /a/[id=_]' ~[[%hole [1 13] [1 12] [1 14]]]]
45514537 :: an import's path cut short
45524538 ['/= c /ui/c' ~[[%jibb [1 1] [1 1] [1 11]]]]
45534539 :: brackets that close with the deeper lines, cut at their line's
@@ -4607,8 +4593,6 @@
46074593:: Atom constraints tied to an explicit capital or an inferred sample
46084594:: are generalized and printed. Other aura variables remain unsupported until
46094595:: their defaulting and inferred generalization are implemented.
4610−:: Restricted-number promotion considers written capitals only; if there
4611−:: are none, it skips the otherwise unnecessary environment traversal.
46124596:: Bare @ is a separate unrestricted atom type. A directional fit check
46134597:: permits concrete atoms to widen to it, never the reverse. A fit that
46144598:: needs a not-yet-implemented constraint remains unsupported. Named unions
@@ -4616,64 +4600,18 @@
46164600:: from their display name. Generic cases must be disjoint for all arguments.
46174601:: Unnamed union printing is informational; it is not Jibb syntax.
46184602::
4619−:: `proj` is a reserved, type-directed operation, not an ordinary gate.
4620−:: The supported fragment selects uniquely faced fields from a known record
4621−:: in source order (reordering is a doc question). It records the original
4622−:: call, source and target types, and source axes with its definition;
4623−:: A single selected field keeps its face and uses one source axis.
4624−:: Checked module interfaces retain that evidence and their source, including
4625−:: the private prelude dependency. A later lowerer must replace the call by
4626−:: an inline gate applied to the operand once; no lowering is implemented yet.
4627−:: Ordinary fits never insert a projection. Unknown or variable-origin record
4628−:: spines, nested projected fields and projections in
4629−:: recursive groups remain unsupported. Directional fits bound faced-spine
4630−:: proofs to fewer than 1,024 cells; the projection planner has a separate
4631−:: 4,096-step bound. These are inference limits, not language limits.
4632−::
4633−:: Supported API imports derive request-gate types atomically for multiple
4634−:: paths, including one typed segment or one diff fold per case. Their checked
4635−:: ordinary definitions, mark molds and supported poke constructor are also
4636−:: exported. A selected /sur mold is checked through its trusted reader result;
4637−:: unused cores and other bindings are not independently validated. APIs
4638−:: with /= imports, separate scry paths, multiple parameters or diffs, or a
4639−:: parameter together with a fold remain unsupported. The unchanged todo API
4640−:: fits this fragment, including named closed fold gates.
4641−::
4642−:: Each case's source-derived schema and canonical API identity travel in a
4643−:: dependency closure bound to the exact supplied bundle, prelude, scope and
4644−:: trusted reader results. Unknown cached entries are rebuilt. Request-bearing
4645−:: closures are limited to 256 source paths and requests. This is type
4646−:: inference only: no request lowering, runtime schema validator or proof that
4647−:: an arbitrary ask value is watchable is supplied.
4648−::
4649−:: A closed gate sample may omit one outer face from a known input slot when
4650−:: its product is identical. Distinct written names, nested value faces,
4651−:: ambiguous cell tails and raw-variable-origin fits retain their prior rules.
4652−::
4653−:: In one synthetic eval of a 48-module deep and 48-module wide request-free
4654−:: graph, baseline versus certificate inference took 21.53 s versus 23.10 s
4655−:: elapsed (21.10 s versus 22.34 s CPU), including startup. The deep cache's
4656−:: jam grew from 2,402 to 4,209 bytes (+1,807 bytes). These single-run figures
4657−:: are not production memory or performance benchmarks.
4658−::
46594603+$ itype
46604604 $~ [%var 0]
46614605 $% [%var id=@ud]
46624606 [%avar id=@ud]
4663− [%rvar id=@ud]
46644607 [%nvar id=@ud]
4665− [%rnvar id=@ud]
46664608 [%atom aura=@ta]
46674609 [%any-atom ~]
46684610 [%flag ~]
4669− [%noun ~]
4670− [%empty ~]
46714611 [%tag id=@ud literal=lit constructor=?]
46724612 [%const literal=lit]
46734613 [%collection name=term args=(list itype)]
46744614 [%recursive module=term name=term label=(unit @t)]
4675− [%jrec at=path name=term label=(unit @t) head=term aura=@ta tail=term]
4676− [%grec at=path name=term label=(unit @t) proof=shape args=(list itype)]
46774615 [%union cases=(list itype) origin=(unit [at=path name=term]) label=(unit @t) args=(list itype)]
46784616 [%face name=term body=itype]
46794617 [%fn sample=itype product=itype]
@@ -4697,117 +4635,21 @@
46974635 %var
46984636 =/ found=(unit itype) (itype-lookup id.t sub)
46994637 ?~ found t
4700− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
47014638 $(t u.found)
47024639 %avar
47034640 =/ found=(unit itype) (itype-lookup id.t sub)
47044641 ?~ found t
4705− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4706− $(t u.found)
4707− %rvar
4708− =/ found=(unit itype) (itype-lookup id.t sub)
4709− ?~ found t
4710− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
47114642 $(t u.found)
47124643 %nvar
47134644 =/ found=(unit itype) (itype-lookup id.t sub)
47144645 ?~ found t
4715− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4716− $(t u.found)
4717− %rnvar
4718− =/ found=(unit itype) (itype-lookup id.t sub)
4719− ?~ found t
4720− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
47214646 $(t u.found)
47224647 %tag
47234648 =/ found=(unit itype) (itype-lookup id.t sub)
47244649 ?~ found t
4725− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
47264650 $(t u.found)
47274651 ==
47284652::
4729−:: Prove only emptiness; unknown types are never treated as empty.
4730−:: A shared node budget bounds each proof attempt.
4731−++ itype-empty-cases
4732− |= [xs=(list itype) sub=isub fuel=@ud]
4733− ^- (unit [empty=? left=@ud])
4734− ?~ xs `[& fuel]
4735− =/ first=(unit [empty=? left=@ud]) (itype-empty-proof i.xs sub fuel)
4736− ?~ first ~
4737− ?. empty.u.first `[| left.u.first]
4738− $(xs t.xs, fuel left.u.first)
4739−++ itype-empty-proof
4740− |= [typ=itype sub=isub fuel=@ud]
4741− ^- (unit [empty=? left=@ud])
4742− ?: =(0 fuel) ~
4743− =. fuel (dec fuel)
4744− =. typ (itype-walk typ sub)
4745− ?- -.typ
4746− %empty `[& fuel]
4747− %face $(typ body.typ)
4748− %cell
4749− =/ left=(unit [empty=? left=@ud]) $(typ hed.typ)
4750− ?~ left ~
4751− ?: empty.u.left `[& left.u.left]
4752− $(typ tal.typ, fuel left.u.left)
4753− %union (itype-empty-cases cases.typ sub fuel)
4754− * `[| fuel]
4755− ==
4756−:: Prove reachability separately from emptiness. An unresolved fixed
4757−:: recursive type is not presumed inhabited. A written, still-unconstrained
4758−:: capital is existentially inhabited for pattern reachability; the normal
4759−:: definition-boundary checks reject subsequently constrained capitals.
4760−++ itype-inhabited-cases
4761− |= [xs=(list itype) sub=isub caps=icaps fuel=@ud pending=?]
4762− ^- (unit [result=?(%yes %no %unknown) left=@ud])
4763− ?~ xs `[?:(pending %unknown %no) fuel]
4764− =/ first=(unit [result=?(%yes %no %unknown) left=@ud])
4765− (itype-inhabited-proof i.xs sub caps fuel)
4766− ?~ first ~
4767− ?: =(%yes result.u.first) first
4768− $(xs t.xs, fuel left.u.first, pending |(pending =(%unknown result.u.first)))
4769−++ itype-inhabited-proof
4770− |= [typ=itype sub=isub caps=icaps fuel=@ud]
4771− ^- (unit [result=?(%yes %no %unknown) left=@ud])
4772− ?: =(0 fuel) ~
4773− =. fuel (dec fuel)
4774− =. typ (itype-walk typ sub)
4775− ?- -.typ
4776− %empty `[%no fuel]
4777− ?(%atom %any-atom %flag %const %noun %avar %rvar %nvar %rnvar %fn %jrec) `[%yes fuel]
4778− %var
4779− ?: (lien caps |=(c=icap (hole-same-variable typ (itype-walk [%var id.c] sub)))) `[%yes fuel]
4780− `[%unknown fuel]
4781− %face $(typ body.typ)
4782− %cell
4783− =/ head=(unit [result=?(%yes %no %unknown) left=@ud]) $(typ hed.typ)
4784− ?~ head ~
4785− ?: =(%no result.u.head) head
4786− =/ tail=(unit [result=?(%yes %no %unknown) left=@ud]) $(typ tal.typ, fuel left.u.head)
4787− ?~ tail ~
4788− ?: =(%no result.u.tail) tail
4789− ?: |(=(%unknown result.u.head) =(%unknown result.u.tail)) `[%unknown left.u.tail]
4790− `[%yes left.u.tail]
4791− %union (itype-inhabited-cases cases.typ sub caps fuel |)
4792− %collection
4793− ?. &(|(=(%list name.typ) =(%unit name.typ)) ?=([* ~] args.typ)) `[%unknown fuel]
4794− `[%yes fuel]
4795− %grec ?:((grec-tree-proof name.typ proof.typ) `[%yes fuel] `[%unknown fuel])
4796− * `[%unknown fuel]
4797− ==
4798−++ itype-live-cases
4799− |= [xs=(list itype) sub=isub caps=icaps fuel=@ud]
4800− ^- (unit (list itype))
4801− ?~ xs `~
4802− =/ first=(unit [result=?(%yes %no %unknown) left=@ud])
4803− (itype-inhabited-proof i.xs sub caps fuel)
4804− ?~ first ~
4805− ?: =(%unknown result.u.first) ~
4806− =/ rest=(unit (list itype)) $(xs t.xs, fuel left.u.first)
4807− ?~ rest ~
4808− ?: =(%no result.u.first) rest
4809− `[i.xs u.rest]
4810−::
48114653++ itype-occurs
48124654 |= [n=@ud t=itype sub=isub]
48134655 ^- ?
@@ -4815,20 +4657,14 @@
48154657 ?- -.t
48164658 %var =(n id.t)
48174659 %avar =(n id.t)
4818− %rvar =(n id.t)
48194660 %nvar =(n id.t)
4820− %rnvar =(n id.t)
48214661 %atom |
48224662 %any-atom |
48234663 %flag |
4824− %noun |
4825− %empty |
48264664 %tag =(n id.t)
48274665 %const |
48284666 %union |((lien cases.t |=(c=itype (itype-occurs n c sub))) (lien args.t |=(c=itype (itype-occurs n c sub))))
48294667 %recursive |
4830− %jrec |
4831− %grec (lien args.t |=(c=itype (itype-occurs n c sub)))
48324668 %collection (lien args.t |=(c=itype (itype-occurs n c sub)))
48334669 %face $(t body.t)
48344670 %fn |($(t sample.t) $(t product.t))
@@ -4847,11 +4683,6 @@
48474683 =. a (itype-walk a sub)
48484684 =. b (itype-walk b sub)
48494685 ?: =(a b) `sub
4850− ?: &(?=(%grec -.a) ?=(%grec -.b))
4851− ?. &(=(at.a at.b) =(name.a name.b)) ~
4852− (itype-unify-args args.a args.b sub)
4853− ?: &(?=(%jrec -.a) ?=(%jrec -.b))
4854− ?:(&(=(at.a at.b) =(name.a name.b) =(head.a head.b) =(aura.a aura.b) =(tail.a tail.b)) `sub ~)
48554686 ?: &(?=(%recursive -.a) ?=(%recursive -.b))
48564687 ?:(&(=(module.a module.b) =(name.a name.b)) `sub ~)
48574688 ?: &(?=(%union -.a) ?=(%union -.b))
@@ -4868,32 +4699,6 @@
48684699 ?: ?=(%var -.b)
48694700 ?: (itype-occurs id.b a sub) ~
48704701 `[[id.b a] sub]
4871− :: Arithmetic's aura variable excludes loobeans; decimal literals
4872− :: remain defaultable until a later constraint makes them concrete.
4873− ?: &(?=(%nvar -.a) ?=(%rvar -.b))
4874− `[[id.b [%rnvar id.a]] [id.a [%rnvar id.a]] sub]
4875− ?: &(?=(%rvar -.a) ?=(%nvar -.b))
4876− `[[id.a [%rnvar id.b]] [id.b [%rnvar id.b]] sub]
4877− ?: &(?=(%rnvar -.a) ?=(%rvar -.b)) `[[id.b a] sub]
4878− ?: &(?=(%rvar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4879− ?: &(?=(%rnvar -.a) ?=(%nvar -.b)) `[[id.b a] sub]
4880− ?: &(?=(%nvar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4881− ?: &(?=(%rnvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4882− ?: &(?=(%avar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4883− ?: ?=(%rnvar -.a)
4884− ?. |(?=(%rnvar -.b) ?=(%atom -.b)) ~
4885− `[[id.a b] sub]
4886− ?: ?=(%rnvar -.b)
4887− ?. ?=(%atom -.a) ~
4888− `[[id.b a] sub]
4889− ?: &(?=(%avar -.a) ?=(%rvar -.b)) `[[id.a b] sub]
4890− ?: &(?=(%rvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4891− ?: ?=(%rvar -.a)
4892− ?. |(?=(%rvar -.b) ?=(%atom -.b)) ~
4893− `[[id.a b] sub]
4894− ?: ?=(%rvar -.b)
4895− ?. ?=(%atom -.a) ~
4896− `[[id.b a] sub]
48974702 :: The narrower decimal constraint survives a match with an atom
48984703 :: variable; decimal syntax alone does not make it a loobean.
48994704 ?: &(?=(%nvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
@@ -4948,20 +4753,14 @@
49484753 ?- -.t
49494754 %var |
49504755 %avar |
4951− %rvar |
49524756 %nvar |
4953− %rnvar |
49544757 %atom |
49554758 %any-atom &
49564759 %flag |
4957− %noun |
4958− %empty |
49594760 %tag |
49604761 %const |
49614762 %union |((lien cases.t |=(c=itype (itype-has-any-atom c sub))) (lien args.t |=(c=itype (itype-has-any-atom c sub))))
49624763 %recursive |
4963− %jrec |
4964− %grec (lien args.t |=(c=itype (itype-has-any-atom c sub)))
49654764 %collection (lien args.t |=(c=itype (itype-has-any-atom c sub)))
49664765 %face $(t body.t)
49674766 %fn |($(t sample.t) $(t product.t))
@@ -5024,20 +4823,14 @@
50244823 ?- -.typ
50254824 %var |
50264825 %avar |
5027− %rvar |
50284826 %nvar |
5029− %rnvar |
50304827 %atom &
50314828 %any-atom &
50324829 %flag &
5033− %noun |
5034− %empty |
50354830 %tag &
50364831 %const &
50374832 %union |((lien cases.typ |=(c=itype (itype-has-fixed-atom c))) (lien args.typ |=(c=itype (itype-has-fixed-atom c))))
50384833 %recursive |
5039− %jrec |
5040− %grec (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
50414834 %collection (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
50424835 %face $(typ body.typ)
50434836 %fn |($(typ sample.typ) $(typ product.typ))
@@ -5066,7 +4859,6 @@
50664859 ^- ?
50674860 =. t (itype-walk t sub)
50684861 ?- -.t
5069− %grec (lien args.t |=(c=itype (itype-has-face c sub)))
50704862 %collection (lien args.t |=(c=itype (itype-has-face c sub)))
50714863 %face &
50724864 %cell |($(t hed.t) $(t tal.t))
@@ -5074,42 +4866,6 @@
50744866 * |
50754867 ==
50764868::
5077−:: Closed function samples may omit a slot face, but a known name must
5078−:: match another known name. Keep nested value faces and require exact
5079−:: invariant compatibility; a faced tail against a cell is ambiguous.
5080−++ itype-closed-slot-match
5081− |= [a=itype b=itype]
5082− ^- ?
5083− ?: &(?=(%face -.a) ?=(%face -.b))
5084− ?. =(name.a name.b) |
5085− ?=(^ (itype-unify body.a body.b ~))
5086− ?: ?=(%face -.a) ?=(^ (itype-unify body.a b ~))
5087− ?: ?=(%face -.b) ?=(^ (itype-unify a body.b ~))
5088− ?=(^ (itype-unify a b ~))
5089−++ itype-closed-sample-match
5090− |= [a=itype b=itype fuel=@ud]
5091− ^- ?
5092− ?: =(0 fuel) |
5093− ?. &(?=(%cell -.a) ?=(%cell -.b)) |
5094− ?. (itype-closed-slot-match hed.a hed.b) |
5095− =/ x=itype tal.a
5096− =/ y=itype tal.b
5097− ?: &(?=(%cell -.x) ?=(%cell -.y))
5098− ?=(^ (itype-unify x y ~))
5099− ?: |(&(?=(%face -.x) ?=(%cell -.y)) &(?=(%cell -.x) ?=(%face -.y))) |
5100− (itype-closed-slot-match x y)
5101−++ itype-closed-gates-match
5102− |= [a=itype b=itype]
5103− ^- ?
5104− ?. &(?=(%fn -.a) ?=(%fn -.b)) |
5105− ?. &(?=(%cell -.sample.a) ?=(%cell -.sample.b)) |
5106− ?. =(product.a product.b) |
5107− ?^ (itype-vars a) |
5108− ?^ (itype-vars b) |
5109− ?: |((itype-has-tag a) (itype-has-tag b)) |
5110− ?. (itype-closed-sample-match sample.a sample.b 1.024) |
5111− ?=(^ (itype-unify product.a product.b ~))
5112−::
51134869++ itype-face-asym-collection-args
51144870 |= [as=(list itype) bs=(list itype) sub=isub]
51154871 ^- ?
@@ -5123,15 +4879,12 @@
51234879 ^- ?
51244880 =. a (itype-walk a sub)
51254881 =. b (itype-walk b sub)
5126− ?: &(?=(%grec -.a) ?=(%grec -.b))
5127− ?. &(=(at.a at.b) =(name.a name.b)) |
5128− (itype-face-asym-collection-args args.a args.b sub)
51294882 ?: &(?=(%collection -.a) ?=(%collection -.b))
51304883 ?. =(name.a name.b) |
51314884 (itype-face-asym-collection-args args.a args.b sub)
51324885 ?: &(?=(%face -.a) ?=(%face -.b)) $(a body.a, b body.b)
5133− ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%rvar -.b) |(?=(%nvar -.b) ?=(%rnvar -.b)))
5134− ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%rvar -.a) |(?=(%nvar -.a) ?=(%rnvar -.a)))
4886+ ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%nvar -.b))
4887+ ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%nvar -.a))
51354888 ?: &(?=(%cell -.a) ?=(%cell -.b)) |($(a hed.a, b hed.b) $(a tal.a, b tal.b))
51364889 ?: &(?=(%fn -.a) ?=(%fn -.b)) |($(a sample.a, b sample.b) $(a product.a, b product.b))
51374890 |
@@ -5154,30 +4907,6 @@
51544907 [%cell $(actual hed.actual, expected hed.expected) $(actual tal.actual, expected tal.expected)]
51554908 expected
51564909::
5157−:: Positional call arguments do not write the sample's enclosing field
5158−:: labels. Ignore one raw sample-slot face per written argument while
5159−:: checking value faces as usual. An unknown or variable-bound cell spine
5160−:: cannot justify this distinction, so keep the existing conservative guard.
5161−++ itype-positional-slot-face-asym
5162− |= [actual=itype expected=itype sub=isub]
5163− ^- ?
5164− ?: &(?=(%fn -.actual) ?=(%fn -.expected) (itype-closed-gates-match actual expected)) |
5165− (itype-face-asym actual expected sub)
5166−::
5167−++ itype-positional-face-asym
5168− |= [args=(list expr) actual=itype expected=itype sub=isub]
5169− ^- ?
5170− ?~ args &
5171− ?~ t.args
5172− =/ slot=itype expected
5173− =? slot ?=(%face -.slot) body.slot
5174− (itype-positional-slot-face-asym actual slot sub)
5175− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) &
5176− =/ slot=itype hed.expected
5177− =? slot ?=(%face -.slot) body.slot
5178− ?: (itype-positional-slot-face-asym hed.actual slot sub) &
5179− $(args t.args, actual tal.actual, expected tal.expected)
5180−::
51814910++ itype-output-may-be-cell
51824911 |= [t=itype sub=isub]
51834912 ^- ?
@@ -5187,9 +4916,6 @@
51874916 %cell &
51884917 %union &
51894918 %recursive &
5190− %jrec &
5191− %grec &
5192− %noun &
51934919 %collection &
51944920 %face $(t body.t)
51954921 %fn |($(t sample.t) $(t product.t))
@@ -5218,7 +4944,6 @@
52184944 ^- ?
52194945 ?- -.t
52204946 %tag &
5221− %grec (lien args.t |=(c=itype (itype-has-tag c)))
52224947 %collection (lien args.t |=(c=itype (itype-has-tag c)))
52234948 %face $(t body.t)
52244949 %fn |($(t sample.t) $(t product.t))
@@ -5232,7 +4957,6 @@
52324957 ^- ?
52334958 ?- -.t
52344959 %union &
5235− %grec (lien args.t |=(c=itype (itype-has-union c)))
52364960 %collection (lien args.t |=(c=itype (itype-has-union c)))
52374961 %face $(t body.t)
52384962 %fn |($(t sample.t) $(t product.t))
@@ -5251,7 +4975,6 @@
52514975 %union
52524976 ?: &(?=(~ label.t) ?=(^ args.t)) &
52534977 (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-generic c)))
5254− %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-generic c))))
52554978 %collection (lien args.t |=(c=itype (itype-has-hidden-generic c)))
52564979 %face $(t body.t)
52574980 %fn |($(t sample.t) $(t product.t))
@@ -5264,8 +4987,6 @@
52644987 ^- ?
52654988 ?- -.t
52664989 %recursive &
5267− %jrec &
5268− %grec &
52694990 %collection (lien args.t |=(c=itype (itype-has-recursive c)))
52704991 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-recursive c)))
52714992 %face $(t body.t)
@@ -5279,8 +5000,6 @@
52795000 ^- ?
52805001 ?- -.t
52815002 %recursive ?=(~ label.t)
5282− %jrec ?=(~ label.t)
5283− %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-recursive c))))
52845003 %collection (lien args.t |=(c=itype (itype-has-hidden-recursive c)))
52855004 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-recursive c)))
52865005 %face $(t body.t)
@@ -5308,107 +5027,34 @@
53085027 $(cases t.cases, good `trial)
53095028 ==
53105029::
5311−:: A constructor needs a case whose head has the same literal noun as its
5312−:: tag. An unresolved or opaque case may reveal one later, so it cannot
5313−:: prove a mismatch or a unique match. A broad atom mold is not a case.
5030+:: A constructor needs a case with its tag at the head and a payload
5031+:: compatible with the expected gate sample. Other case forms do not
5032+:: identify a constructor.
53145033::
53155034++ itype-fit-ctor-cases
53165035 |= [tag=lit sample=itype cases=(list itype) sub=isub next=@ud]
53175036 ^- ifit
53185037 =/ found=(unit ifit) ~
5319− =/ pending=? |
53205038 |-
5321− ?~ cases
5322− ?: pending [%unknown ~]
5323− ?~ found [%bad ~]
5324− u.found
5325− =/ raw=itype i.cases
5326− ?: ?=(%var -.raw)
5327− $(cases t.cases, pending &)
5328− =/ c=itype (itype-walk raw sub)
5329− ?: ?=(?(%var %tag %recursive %jrec %grec %union %face) -.c)
5330− $(cases t.cases, pending &)
5039+ ?~ cases ?~(found [%bad ~] u.found)
5040+ =/ c=itype (itype-walk i.cases sub)
53315041 ?. ?=(%cell -.c) $(cases t.cases)
5332− =/ raw-head=itype hed.c
5333− ?: ?=(%var -.raw-head)
5334− $(cases t.cases, pending &)
5335− =/ head=itype (itype-walk raw-head sub)
5336− :: A single faced, explicitly atom-only head cannot be the tag case.
5337− :: Do not follow variables or peel nested faces for this negative proof.
5338− ?: ?=(%face -.head)
5339− ?: ?=(?(%atom %any-atom %flag %avar %rvar %nvar %rnvar) -.body.head)
5340− $(cases t.cases)
5341− $(cases t.cases, pending &)
5342− ?: ?=(?(%var %tag %recursive %jrec %grec %union) -.head)
5343− $(cases t.cases, pending &)
5042+ =/ head=itype (itype-walk hed.c sub)
53445043 ?. ?=(%const -.head) $(cases t.cases)
5044+ ?. =(%term form.literal.head) $(cases t.cases)
53455045 ?. =(val.literal.head val.tag) $(cases t.cases)
5346− :: Equal heads can have disjoint payloads. Test each from the original
5347− :: substitution; a unique success is usable only with no unknown rival.
5046+ ?^ found [%unknown ~]
53485047 =/ trial=ifit (itype-fit sample tal.c sub next)
5349− ?- -.trial
5350− %bad $(cases t.cases)
5351− %unknown $(cases t.cases, pending &)
5352− %ok
5353− ?^ found [%unknown ~]
5354− $(cases t.cases, found `trial)
5355− ==
5048+ $(cases t.cases, found `trial)
53565049::
53575050++ itype-fit
53585051 |= [actual=itype expected=itype sub=isub next=@ud]
53595052 ^- ifit
5360− =/ result=ifit (itype-fit-inner actual expected sub next | |)
5361− ?: ?=(%ok -.result) result
5362− =/ source=itype (itype-walk actual sub)
5363− ?. ?=(?(%empty %face %cell %union) -.source) result
5364− =/ empty=(unit [empty=? left=@ud]) (itype-empty-proof actual sub 256)
5365− ?~ empty [%unknown ~]
5366− ?: empty.u.empty [%ok sub next]
5367− result
5368−++ itype-fit-inner
5369− |= [actual=itype expected=itype sub=isub next=@ud skip-width=? spine-proof=?]
5370− ^- ifit
5371− ?: &(!skip-width ?=(%cell -.actual) ?=(%cell -.expected) |((width-spine-exhausted actual 1.024) (width-spine-exhausted expected 1.024)))
5372− [%unknown ~]
5373− =/ known=(unit [source=iwfields target=iwfields])
5374− ?: skip-width ~
5375− (width-known-shape actual expected sub)
5376− =/ too-wide=? ?~(known | (gth (lent order.source.u.known) (lent order.target.u.known)))
5377− ?: too-wide [%unknown ~]
5378− =/ spine-checked=? |(spine-proof ?=(^ known))
53795053 =/ uncertain=?
5380− |(?=(%var -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)) ?=(%var -.expected) ?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected)))
5381− =/ actual-open=?
5382− |(?=(%var -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))
5054+ |(?=(%var -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%var -.expected) ?=(%avar -.expected) ?=(%nvar -.expected))
53835055 =. actual (itype-walk actual sub)
53845056 =. expected (itype-walk expected sub)
53855057 ?: =(actual expected) [%ok sub next]
5386− ?: &(?=(%empty -.expected) |(?=(%cell -.actual) ?=(%face -.actual) ?=(%union -.actual) ?=(%grec -.actual) ?=(%recursive -.actual))) [%unknown ~]
5387− :: The relation of the source loobean mold to explicit @f is not yet
5388− :: established. Keep it unsupported rather than asserting a mismatch.
5389− ?: &(?=(%flag -.actual) ?=(%atom -.expected) =(%f aura.expected)) [%unknown ~]
5390− :: Any value can be used where a noun is expected. An unresolved
5391− :: bare tag is fixed as a constant; a constructor still needs a gate.
5392− ?: ?=(%noun -.expected)
5393− ?: ?=(%tag -.actual)
5394− ?: constructor.actual [%unknown ~]
5395− [%ok [[id.actual expected] sub] next]
5396− [%ok sub next]
5397− :: An arbitrary noun is not known to fit a narrower type.
5398− ?: &(?=(%noun -.actual) !?=(%var -.expected)) [%unknown ~]
5399− ?: &(!uncertain ?=(%grec -.actual) ?=(%face -.expected)) $(expected body.expected)
5400− ?: &(!uncertain ?=(%face -.actual) ?=(%grec -.expected)) $(actual body.actual)
5401− ?: &(?=(%grec -.actual) ?=(%grec -.expected))
5402− ?. &(=(at.actual at.expected) =(name.actual name.expected)) [%unknown ~]
5403− =/ matched=(unit isub) (itype-unify-args args.actual args.expected sub)
5404− ?~ matched [%unknown ~]
5405− [%ok u.matched next]
5406− ?: &(|(?=(%grec -.actual) ?=(%grec -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
5407− ?: &(!uncertain ?=(%jrec -.actual) ?=(%face -.expected)) $(expected body.expected)
5408− ?: &(!uncertain ?=(%face -.actual) ?=(%jrec -.expected)) $(actual body.actual)
5409− ?: &(?=(%jrec -.actual) ?=(%jrec -.expected))
5410− ?:(&(=(at.actual at.expected) =(name.actual name.expected) =(head.actual head.expected) =(aura.actual aura.expected) =(tail.actual tail.expected)) [%ok sub next] [%bad ~])
5411− ?: &(|(?=(%jrec -.actual) ?=(%jrec -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
54125058 ?: &(?=(%recursive -.actual) ?=(%recursive -.expected))
54135059 ?:(&(=(module.actual module.expected) =(name.actual name.expected)) [%ok sub next] [%bad ~])
54145060 ?: &(|(?=(%recursive -.actual) ?=(%recursive -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
@@ -5420,21 +5066,8 @@
54205066 =/ unified=(unit isub) (itype-unify-args args.actual args.expected sub)
54215067 ?^ unified [%ok u.unified next]
54225068 [%unknown ~]
5423− :: A known union can instantiate an unconstrained sample directly;
5424− :: preserve unknown results for variable-bound union origins.
5425− ?: &(!actual-open ?=(%union -.actual) ?=(%var -.expected))
5426− ?~ origin.actual [%unknown ~]
5427− =/ normalized=itype (itype-normalize actual sub)
5428− ?: |((itype-has-tag normalized) (itype-has-recursive normalized) (itype-has-any-atom actual sub)) [%unknown ~]
5429− =/ unified=(unit isub) (itype-unify actual expected sub)
5430− ?~ unified [%unknown ~]
5431− [%ok u.unified next]
5432− :: A concrete union value in a tuple may acquire the expected field's
5433− :: face. A variable-bound union still needs face propagation support.
5434− ?: &(!uncertain ?=(%union -.actual) ?=(%face -.expected))
5435− $(expected body.expected)
54365069 ?: ?=(%union -.actual) [%unknown ~]
5437− ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))) [%unknown ~]
5070+ ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%nvar -.actual))) [%unknown ~]
54385071 ?: &(?=(%union -.expected) !?=(%var -.actual))
54395072 (itype-fit-cases actual cases.expected sub next)
54405073 ?: ?=(%tag -.actual)
@@ -5442,7 +5075,7 @@
54425075 =/ u=(unit isub) (itype-unify actual expected sub)
54435076 ?~ u [%bad ~]
54445077 [%ok u.u next]
5445− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5078+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
54465079 ?: ?=(%face -.expected) $(expected body.expected)
54475080 ?: constructor.actual
54485081 ?. ?=(%fn -.expected) [%bad ~]
@@ -5451,10 +5084,6 @@
54515084 =/ trial=ifit (itype-fit-ctor-cases literal.actual sample.expected cases sub next)
54525085 ?. ?=(%ok -.trial) trial
54535086 [%ok [[id.actual expected] sub.trial] next.trial]
5454− :: Zero may be the empty list. A nested cell fit lacks the context
5455− :: needed to resolve it here, so do not report a definite mismatch.
5456− ?: &(?=(%collection -.expected) =(%list name.expected) =(0 val.literal.actual))
5457− [%unknown ~]
54585087 ?: ?=(%const -.expected)
54595088 ?:(=(val.literal.actual val.literal.expected) [%ok [[id.actual expected] sub] next] [%bad ~])
54605089 ?: ?=(%atom -.expected)
@@ -5470,17 +5099,11 @@
54705099 =/ u=(unit isub) (itype-unify actual expected sub)
54715100 ?~ u [%bad ~]
54725101 [%ok u.u next]
5473− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5102+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
54745103 ?: ?=(%face -.expected) $(expected body.expected)
5475− ?: &(?=(%collection -.expected) =(%list name.expected) =(0 val.literal.actual))
5476− [%unknown ~]
54775104 ?: ?=(%const -.expected)
54785105 ?:(=(val.literal.actual val.literal.expected) [%ok sub next] [%bad ~])
54795106 ?: ?=(%atom -.expected)
5480− :: A loobean singleton must not silently widen into another aura.
5481− ?: =(%loobean form.literal.actual)
5482− ?: =(%f aura.expected) [%unknown ~]
5483− [%bad ~]
54845107 ?: |(=(%tas aura.expected) =(%ta aura.expected)) [%ok sub next]
54855108 [%bad ~]
54865109 ?: ?=(%flag -.expected)
@@ -5488,14 +5111,8 @@
54885111 ?: ?=(%any-atom -.expected) [%ok sub next]
54895112 [%bad ~]
54905113 ?: &(uncertain (itype-face-asym actual expected sub)) [%unknown ~]
5491− :: A known face labels the same noun. Peel it before applying the
5492− :: directional unrestricted-atom rule, preserving raw-variable guards.
5493− ?: &(!uncertain ?=(%any-atom -.actual) ?=(%face -.expected))
5494− $(expected body.expected, skip-width |, spine-proof |)
5495− ?: &(!uncertain ?=(%any-atom -.expected) ?=(%face -.actual))
5496− $(actual body.actual, skip-width |, spine-proof |)
54975114 ?: ?=(%any-atom -.expected)
5498− ?: |(?=(%atom -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)) ?=(%flag -.actual)) [%ok sub next]
5115+ ?: |(?=(%atom -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%flag -.actual)) [%ok sub next]
54995116 ?: ?=(%var -.actual)
55005117 =/ unified=(unit isub) (itype-unify actual [%avar next] sub)
55015118 ?~ unified [%bad ~]
@@ -5506,16 +5123,16 @@
55065123 =/ unified=(unit isub) (itype-unify actual expected sub)
55075124 ?~ unified [%bad ~]
55085125 [%ok u.unified next]
5509− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5126+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
55105127 [%bad ~]
55115128 ?: &(?=(%atom -.actual) ?=(%atom -.expected))
55125129 ?: (aura-prefix aura.expected aura.actual) [%ok sub next]
55135130 ?: &((aura-prefix aura.actual aura.expected) uncertain) [%unknown ~]
55145131 [%bad ~]
55155132 ?: &(?=(%cell -.actual) ?=(%cell -.expected))
5516− =/ first=ifit $(actual hed.actual, expected hed.expected, skip-width |, spine-proof |)
5133+ =/ first=ifit $(actual hed.actual, expected hed.expected)
55175134 ?. ?=(%ok -.first) first
5518− $(actual tal.actual, expected tal.expected, sub sub.first, next next.first, skip-width spine-checked, spine-proof spine-checked)
5135+ $(actual tal.actual, expected tal.expected, sub sub.first, next next.first)
55195136 :: A field may add a face to an occurrence of the very same type
55205137 :: variable. Binding that variable to a face around itself would fail
55215138 :: the occurs check, but its underlying type has already matched.
@@ -5537,10 +5154,9 @@
55375154 [%ok u.unified next]
55385155 ?: &(?=(%face -.actual) ?=(%face -.expected))
55395156 ?. =(name.actual name.expected) [%bad ~]
5540− $(actual body.actual, expected body.expected, skip-width |, spine-proof |)
5541− ?: ?=(%face -.actual) $(actual body.actual, skip-width |, spine-proof |)
5542− ?: ?=(%face -.expected) $(expected body.expected, skip-width |, spine-proof |)
5543− ?: &(!uncertain (itype-closed-gates-match actual expected)) [%ok sub next]
5157+ $(actual body.actual, expected body.expected)
5158+ ?: ?=(%face -.actual) $(actual body.actual)
5159+ ?: ?=(%face -.expected) $(expected body.expected)
55445160 ?: (itype-face-asym actual expected sub) [%unknown ~]
55455161 ?: |((itype-has-any-atom actual sub) (itype-has-any-atom expected sub))
55465162 [%unknown ~]
@@ -5610,24 +5226,13 @@
56105226 problems
56115227::
56125228:: The expression inference below is deliberately a fragment: bindings,
5613−:: simple gates, calls, fixed-aura literals, and some interpolated strings. The
5229+:: simple gates, calls, fixed-aura literals, and plain strings. The
56145230:: result for unsupported syntax is a diagnostic, never a checked module.
56155231::
56165232+$ ischeme [typ=itype vars=(list @ud)]
56175233+$ ienv (list [name=term scheme=ischeme])
56185234+$ imold-types (list [name=term template=ischeme])
5619−+$ iderived [name=term agent=term mark=term]
5620−+$ iwidth-definition [name=term original=expr typ=itype sub=isub projections=(list iwprojection)]
5621−+$ iwidth-dependency [at=path source=(unit @t) definitions=(list iwidth-definition)]
5622−:: Nonrecursive request evidence is compiler-owned metadata, not a property
5623−:: of an arbitrary ask value. Reader graphs and source inputs are trusted.
5624−+$ irequest-evidence
5625− [api-at=path name=term path=iapi-path-typed api-source=@t public-source=@t internal-source=@t prelude-values=(list term) prelude-molds=(list term) externals=iexternals marks=imark-externals]
5626−:: A unit distinguishes a verified empty closure from a detached legacy file.
5627−:: The opaque prelude is an exact trusted input, not a recursive interface mold.
5628−+$ irequest-graph
5629− [paths=(set path) requests=(list irequest-evidence) bundle-input=* prelude-input=* prelude-values=(list term) prelude-molds=(list term) externals=iexternals marks=imark-externals]
5630−+$ ifile [values=ienv molds=imold-types at=path derived=(list iderived) elaborations=(list iwidth-definition) dependencies=(list iwidth-dependency) source=(unit @t) graph=(unit irequest-graph)]
5235++$ ifile [values=ienv molds=imold-types at=path]
56315236+$ ijimports (list [face=term interface=ifile])
56325237+$ icap [name=@t id=@ud at=span]
56335238+$ icaps (list icap)
@@ -5637,170 +5242,7 @@
56375242:: This core has no Ford dependencies; unrecognized payloads fail closed.
56385243+$ iexternals (list [module=term name=term result=*])
56395244+$ imark-externals (list [mark=term result=*])
5640−:: Hole obligations survive discarded expressions until their owning
5641−:: definition has inferred; their source spans support unresolved reports.
5642−+$ ihole [id=@ud at=span]
5643−:: Recursive-mold unfolding spends fuel in the threaded inference state.
5644−:: Retries can restart from an earlier state, so this bounds an attempt,
5645−:: not all parsing or module-checking work.
5646−:: Experimental: only closed, uniquely faced records have known axes.
5647−+$ iwfield [name=term axis=@ud typ=itype]
5648−+$ iwfields [order=(list iwfield) index=(map term iwfield)]
5649−+$ iwstep [name=term axis=@ud]
5650−+$ iwidth-result [steps=(list iwstep) sub=isub next=@ud]
5651−+$ iwprojection [at=span original=expr source=itype target=itype steps=(list iwstep)]
5652−++ width-scan
5653− |= [typ=itype sub=isub axis=@ud fuel=@ud]
5654− ^- (unit iwfields)
5655− =/ order=(list iwfield) ~
5656− =/ index=(map term iwfield) *(map term iwfield)
5657− |-
5658− ?: =(0 fuel) ~
5659− ?: |(?=(%var -.typ) ?=(%avar -.typ) ?=(%rvar -.typ) ?=(%nvar -.typ) ?=(%rnvar -.typ)) ~
5660− ?: ?=(%face -.typ)
5661− =/ entry=iwfield [name.typ axis body.typ]
5662− ?: ?=(^ (~(get by index) name.entry)) ~
5663− `[(flop [entry order]) (~(put by index) name.entry entry)]
5664− ?. ?=(%cell -.typ) ~
5665− =/ head=itype hed.typ
5666− ?: |(?=(%var -.head) ?=(%avar -.head) ?=(%rvar -.head) ?=(%nvar -.head) ?=(%rnvar -.head)) ~
5667− ?. ?=(%face -.head) ~
5668− =/ entry=iwfield [name.head (mul 2 axis) body.head]
5669− ?: ?=(^ (~(get by index) name.entry)) ~
5670− $(typ tal.typ, axis +((mul 2 axis)), fuel (dec fuel), order [entry order], index (~(put by index) name.entry entry))
5671−++ width-in-order
5672− |= [source=(list iwfield) target=(list iwfield)]
5673− ^- ?
5674− ?~ target &
5675− ?~ source |
5676− ?: =(name.i.source name.i.target) $(source t.source, target t.target)
5677− $(source t.source)
5678−++ width-fit-fields
5679− |= [source=(map term iwfield) target=(list iwfield) sub=isub next=@ud]
5680− ^- (unit iwidth-result)
5681− ?~ target `[~ sub next]
5682− =/ found=(unit iwfield) (~(get by source) name.i.target)
5683− ?~ found ~
5684− =/ fit=ifit (itype-fit typ.u.found typ.i.target sub next)
5685− ?. ?=(%ok -.fit) ~
5686− =/ rest=(unit iwidth-result) $(target t.target, sub sub.fit, next next.fit)
5687− ?~ rest ~
5688− `[[[name.i.target axis.u.found] steps.u.rest] sub.u.rest next.u.rest]
5689−++ width-spine-exhausted
5690− |= [t=itype fuel=@ud]
5691− ^- ?
5692− ?: =(0 fuel) &
5693− ?. ?=(%cell -.t) |
5694− ?. ?=(%face -.hed.t) |
5695− $(t tal.t, fuel (dec fuel))
5696−++ width-known-shape
5697− |= [actual=itype expected=itype sub=isub]
5698− ^- (unit [source=iwfields target=iwfields])
5699− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
5700− =/ source=(unit iwfields) (width-scan actual sub 1 1.024)
5701− =/ target=(unit iwfields) (width-scan expected sub 1 1.024)
5702− ?~ source ~
5703− ?~ target ~
5704− `[u.source u.target]
5705−::
5706−++ width-shape
5707− |= [actual=itype expected=itype sub=isub]
5708− ^- (unit [source=iwfields target=iwfields])
5709− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
5710− =/ source=(unit iwfields) (width-scan actual sub 1 4.096)
5711− =/ target=(unit iwfields) (width-scan expected sub 1 4.096)
5712− ?~ source ~
5713− ?~ target ~
5714− ?. (gth (lent order.u.source) (lent order.u.target)) ~
5715− `[u.source u.target]
5716−++ width-proj-shape
5717− |= [actual=itype expected=itype sub=isub]
5718− ^- (unit [source=iwfields target=iwfields])
5719− ?. &(|(?=(%cell -.actual) ?=(%face -.actual)) |(?=(%cell -.expected) ?=(%face -.expected))) ~
5720− =/ source=(unit iwfields) (width-scan actual sub 1 4.096)
5721− =/ target=(unit iwfields) (width-scan expected sub 1 4.096)
5722− ?~ source ~
5723− ?~ target ~
5724− ?: (lth (lent order.u.source) (lent order.u.target)) ~
5725− `[u.source u.target]
5726−::
5727−++ width-project
5728− |= [shape=[source=iwfields target=iwfields] sub=isub next=@ud]
5729− ^- (unit iwidth-result)
5730− ?. (width-in-order order.source.shape order.target.shape) ~
5731− (width-fit-fields index.source.shape order.target.shape sub next)
5732−::
5733−:: Provisional, globally budgeted gate-free proof. %no includes a
5734−:: gate-bearing witness; an uninhabited sibling could invalidate it.
5735−:: Input types must be resolved and normalized under valid substitutions,
5736−:: from trusted source-backed interfaces and reader results. Collection
5737−:: list/unit names rely on their existing identity invariant; this arm
5738−:: does not validate fabricated internal types.
5739−+$ igf-segment
5740− $% [%field name=term]
5741− [%head ~]
5742− [%tail ~]
5743− [%item ~]
5744− [%case index=@ud]
5745− ==
5746−+$ igate-free [verdict=?(%yes %no %unknown) inhabited=? left=@ud path=(unit (list igf-segment))]
5747−++ gate-free-types
5748− |= [types=(list itype) fuel=@ud path=(list igf-segment) index=@ud]
5749− ^- igate-free
5750− ?~ types [%yes | fuel ~]
5751− ?: =(0 fuel) [%unknown | 0 ~]
5752− =/ first=igate-free (gate-free-type i.types fuel [[%case index] path])
5753− ?: =(%no verdict.first) first
5754− =/ rest=igate-free $(types t.types, fuel left.first, index +(index))
5755− ?: =(%no verdict.rest) rest
5756− =/ inhabited=? |(inhabited.first inhabited.rest)
5757− ?: |(=(%unknown verdict.first) =(%unknown verdict.rest)) [%unknown inhabited left.rest ~]
5758− [%yes inhabited left.rest ~]
5759−++ gate-free-type
5760− |= [typ=itype fuel=@ud path=(list igf-segment)]
5761− ^- igate-free
5762− ?: =(0 fuel) [%unknown | 0 ~]
5763− =. fuel (dec fuel)
5764− ?- -.typ
5765− %fn [%no & fuel `(flop path)]
5766− %atom [%yes & fuel ~]
5767− %any-atom [%yes & fuel ~]
5768− %flag [%yes & fuel ~]
5769− %const [%yes & fuel ~]
5770− %face $(typ body.typ, path [[%field name.typ] path])
5771− %cell
5772− =/ head=igate-free $(typ hed.typ, path [[%head ~] path])
5773− =/ tail=igate-free $(typ tal.typ, fuel left.head, path [[%tail ~] path])
5774− =/ inhabited=? &(inhabited.head inhabited.tail)
5775− ?: |(&(=(%yes verdict.head) !inhabited.head) &(=(%yes verdict.tail) !inhabited.tail)) [%yes | left.tail ~]
5776− ?: &(=(%no verdict.head) inhabited.tail) head(left left.tail)
5777− ?: &(=(%no verdict.tail) inhabited.head) tail
5778− ?: |(!=(%yes verdict.head) !=(%yes verdict.tail)) [%unknown inhabited left.tail ~]
5779− [%yes inhabited left.tail ~]
5780− %collection
5781− ?. |(=(%list name.typ) =(%unit name.typ)) [%unknown | fuel ~]
5782− ?. ?=([* ~] args.typ) [%unknown | fuel ~]
5783− =/ item=igate-free $(typ i.args.typ, path [[%item ~] path])
5784− item(inhabited &)
5785− %union
5786− ?~ cases.typ [%unknown | fuel ~]
5787− (gate-free-types cases.typ fuel path 0)
5788− %noun [%unknown & fuel ~]
5789− %empty [%yes | fuel ~]
5790− %var [%unknown | fuel ~]
5791− %avar [%yes & fuel ~]
5792− %rvar [%yes & fuel ~]
5793− %nvar [%yes & fuel ~]
5794− %rnvar [%yes & fuel ~]
5795− %tag [%unknown | fuel ~]
5796− %recursive [%unknown | fuel ~]
5797− %jrec [%yes & fuel ~]
5798− %grec [%unknown | fuel ~]
5799− ==
5800−::
5801−+$ igate-prelude-evidence [iface=ifile gates=(map term def)]
5802−+$ dgo [left=itype right=itype at=span context=span]
5803−+$ istate [next=@ud sub=isub caps=icaps binders=(list @ud) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) params=iparams active=(list term) tags=(list ipending) in-mold=? at=path top-molds=(list term) prelude=(unit ifile) holes=(list ihole) jrec-fuel=@ud projections=(list iwprojection) gate-defs=(map term def) head-evidence=(unit igate-prelude-evidence) grec-index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)]) defer=(unit ~) obligations=(list dgo)]
5245++$ istate [next=@ud sub=isub caps=icaps binders=(list @ud) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) params=iparams active=(list term) tags=(list ipending) in-mold=? at=path top-molds=(list term) prelude=(unit ifile)]
58045246+$ idiag [msg=tape sites=(list [at=span note=tape])]
58055247+$ iresult (each [typ=itype state=istate] idiag)
58065248+$ isample-result (each [typ=itype env=ienv state=istate] tape)
@@ -5820,7 +5262,6 @@
58205262 |= [t=itype sub=isub]
58215263 ^- itype
58225264 =. t (itype-walk t sub)
5823− ?: ?=(%grec -.t) t(args (turn args.t |=(c=itype (itype-normalize c sub))))
58245265 ?: ?=(%collection -.t) [%collection name.t (turn args.t |=(c=itype (itype-normalize c sub)))]
58255266 ?: ?=(%union -.t)
58265267 [%union (turn cases.t |=(c=itype (itype-normalize c sub))) origin.t label.t (turn args.t |=(c=itype (itype-normalize c sub)))]
@@ -5837,8 +5278,6 @@
58375278:: generalize an aura from its sample, which requires constraint analysis
58385279:: beyond this fragment; leave those cases unresolved.
58395280::
5840−:: This helper only controls decimal defaulting in visible types. A noun
5841−:: may contain gates and is not proof of a gate-free value.
58425281++ itype-has-gate
58435282 |= t=itype
58445283 ^- ?
@@ -5846,8 +5285,6 @@
58465285 %fn &
58475286 %cell |($(t hed.t) $(t tal.t))
58485287 %recursive |
5849− %jrec |
5850− %grec &
58515288 %collection (lien args.t |=(c=itype (itype-has-gate c)))
58525289 %face $(t body.t)
58535290 %union (lien cases.t |=(c=itype (itype-has-gate c)))
@@ -5855,14 +5292,10 @@
58555292 %const |
58565293 %var |
58575294 %avar |
5858− %rvar |
58595295 %nvar |
5860− %rnvar |
58615296 %atom |
58625297 %any-atom |
58635298 %flag |
5864− %noun |
5865− %empty |
58665299 ==
58675300::
58685301++ default-decimals
@@ -5871,136 +5304,26 @@
58715304 ?: (itype-has-gate t) t
58725305 ?- -.t
58735306 %nvar [%atom %ud]
5874− %rnvar [%atom %ud]
5875− %grec t(args (turn args.t |=(c=itype (default-decimals c))))
58765307 %collection [%collection name.t (turn args.t |=(c=itype (default-decimals c)))]
58775308 %face [%face name.t $(t body.t)]
58785309 %cell [%cell $(t hed.t) $(t tal.t)]
58795310 * t
58805311 ==
58815312::
5882−:: A hole is solved only by a fully determined type or a written
5883−:: in-scope type variable. Ordinary fresh variables are not evidence.
5884−:: Compare representatives after substitution, since unification can
5885−:: orient a written capital toward the hole rather than the reverse.
5886−++ hole-variable-id
5887− |= t=itype
5888− ^- (unit @ud)
5889− ?- -.t
5890− %var `id.t
5891− %avar `id.t
5892− %rvar `id.t
5893− %nvar `id.t
5894− %rnvar `id.t
5895− %tag `id.t
5896− * ~
5897− ==
5898−++ hole-same-variable
5899− |= [a=itype b=itype]
5900− ^- ?
5901− =/ x=(unit @ud) (hole-variable-id a)
5902− ?~ x |
5903− =/ y=(unit @ud) (hole-variable-id b)
5904− ?~ y |
5905− =(u.x u.y)
5906−++ hole-known
5907− |= [t=itype state=istate]
5908− ^- ?
5909− =. t (itype-walk t sub.state)
5910− ?- -.t
5911− ?(%var %avar %rvar %nvar %rnvar)
5912− ?: (lien caps.state |=(c=icap (hole-same-variable t (itype-walk [%var id.c] sub.state)))) &
5913− (lien params.state |=(p=[name=@t typ=itype] (hole-same-variable t (itype-walk typ.p sub.state))))
5914− %tag |
5915− %any-atom &
5916− %union &((levy cases.t |=(c=itype (hole-known c state))) (levy args.t |=(c=itype (hole-known c state))))
5917− %grec (levy args.t |=(c=itype (hole-known c state)))
5918− %collection (levy args.t |=(c=itype (hole-known c state)))
5919− %face $(t body.t)
5920− %fn &($(t sample.t) $(t product.t))
5921− %cell &($(t hed.t) $(t tal.t))
5922− * &
5923− ==
5924−++ promote-restricted-numbers
5925− |= [state=istate env=ienv]
5926− ^- istate
5927− :: With no written capitals, there is nothing to promote.
5928− ?~ caps.state state
5929− =/ ids=(list @ud) (turn caps.state |=(c=icap id.c))
5930− =/ free=(list @ud) (free-env-vars env sub.state)
5931− |-
5932− ?~ ids state
5933− =/ t=itype (itype-walk [%var i.ids] sub.state)
5934− ?: &(?=(%rnvar -.t) !(lien free |=(n=@ud =(n +.t))))
5935− $(ids t.ids, state state(sub [[+.t [%rvar +.t]] sub.state]))
5936− $(ids t.ids)
5937−::
5938−++ default-hole-numbers
5939− |= [all=(list ihole) prior=(list ihole) state=istate env=ienv permit=?]
5940− ^- istate
5941− :: Do not default a named capital or a variable captured from env.
5942− ?. permit state
5943− ?: =(all prior) state
5944− ?~ all state
5945− =/ t=itype (itype-walk [%var id.i.all] sub.state)
5946− =/ free=(list @ud) (free-env-vars env sub.state)
5947− =? state &(?=(?(%nvar %rnvar) -.t) !(hole-known t state) !(lien free |=(id=@ud =(id id.t))))
5948− state(sub [[id.t [%atom %ud]] sub.state])
5949− $(all t.all)
5950−::
5951−:: Only obligations created inside this definition belong to it.
5952−++ holes-created
5953− |= [all=(list ihole) prior=(list ihole)]
5954− ^- (list ihole)
5955− ?: =(all prior) ~
5956− ?~ all ~
5957− [i.all $(all t.all)]
5958−++ hole-uncertain
5959− |= [t=itype state=istate]
5960− ^- ?
5961− =. t (itype-walk t sub.state)
5962− ?- -.t
5963− ?(%tag %nvar %rnvar %avar %rvar) !(hole-known t state)
5964− %union |((lien cases.t |=(c=itype (hole-uncertain c state))) (lien args.t |=(c=itype (hole-uncertain c state))))
5965− %grec (lien args.t |=(c=itype (hole-uncertain c state)))
5966− %collection (lien args.t |=(c=itype (hole-uncertain c state)))
5967− %face $(t body.t)
5968− %fn |($(t sample.t) $(t product.t))
5969− %cell |($(t hed.t) $(t tal.t))
5970− * |
5971− ==
5972−::
5973−++ unresolved-hole
5974− |= [all=(list ihole) prior=(list ihole) state=istate]
5975− ^- (unit idiag)
5976− =/ work=(list ihole) (flop (holes-created all prior))
5977− |-
5978− ?~ work ~
5979− ?: (hole-known [%var id.i.work] state) $(work t.work)
5980− ?: (hole-uncertain [%var id.i.work] state)
5981− `["type hole needs unsupported inference" ~[[at.i.work "type hole"]]]
5982− `["type hole needs a determined type" ~[[at.i.work "unresolved type hole"]]]
5983−::
59845313++ itype-vars
59855314 |= t=itype
59865315 ^- (list @ud)
59875316 ?- -.t
59885317 %var ~[id.t]
59895318 %avar ~[id.t]
5990− %rvar ~[id.t]
59915319 %nvar ~[id.t]
5992− %rnvar ~[id.t]
59935320 %atom ~
59945321 %any-atom ~
59955322 %flag ~
5996− %noun ~
5997− %empty ~
59985323 %tag ~
59995324 %const ~
60005325 %union (zing (turn (weld args.t cases.t) |=(c=itype (itype-vars c))))
60015326 %recursive ~
6002− %jrec ~
6003− %grec (zing (turn args.t |=(c=itype (itype-vars c))))
60045327 %collection (zing (turn args.t |=(c=itype (itype-vars c))))
60055328 %face $(t body.t)
60065329 %fn (weld $(t sample.t) $(t product.t))
@@ -6028,29 +5351,17 @@
60285351 =/ found=(unit itype) (itype-lookup id.t ren)
60295352 ?~ found t
60305353 u.found
6031− %rvar
6032− =/ found=(unit itype) (itype-lookup id.t ren)
6033− ?~ found t
6034− u.found
60355354 %nvar
60365355 =/ found=(unit itype) (itype-lookup id.t ren)
60375356 ?~ found t
60385357 u.found
6039− %rnvar
6040− =/ found=(unit itype) (itype-lookup id.t ren)
6041− ?~ found t
6042− u.found
60435358 %atom t
60445359 %any-atom t
60455360 %flag t
6046− %noun t
6047− %empty t
60485361 %tag t
60495362 %const t
60505363 %union [%union (turn cases.t |=(c=itype (itype-rename c ren))) origin.t label.t (turn args.t |=(c=itype (itype-rename c ren)))]
60515364 %recursive t
6052− %jrec t
6053− %grec t(args (turn args.t |=(c=itype (itype-rename c ren))))
60545365 %collection [%collection name.t (turn args.t |=(c=itype (itype-rename c ren)))]
60555366 %face [%face name.t $(t body.t)]
60565367 %fn [%fn $(t sample.t) $(t product.t)]
@@ -6066,50 +5377,19 @@
60665377 ?- -.t
60675378 %var |
60685379 %avar =(n id.t)
6069− %rvar =(n id.t)
60705380 %nvar =(n id.t)
6071− %rnvar =(n id.t)
60725381 %atom |
60735382 %any-atom |
60745383 %flag |
6075− %noun |
6076− %empty |
60775384 %tag |
60785385 %const |
60795386 %union |((lien cases.t |=(c=itype (itype-var-is-atom n c))) (lien args.t |=(c=itype (itype-var-is-atom n c))))
60805387 %recursive |
6081− %jrec |
6082− %grec (lien args.t |=(c=itype (itype-var-is-atom n c)))
60835388 %collection (lien args.t |=(c=itype (itype-var-is-atom n c)))
60845389 %face $(t body.t)
60855390 %fn |($(t sample.t) $(t product.t))
60865391 %cell |($(t hed.t) $(t tal.t))
60875392 ==
6088−++ itype-var-is-restricted
6089− |= [n=@ud t=itype]
6090− ^- ?
6091− ?- -.t
6092− %var |
6093− %avar |
6094− %rvar =(n id.t)
6095− %nvar |
6096− %rnvar |
6097− %atom |
6098− %any-atom |
6099− %flag |
6100− %noun |
6101− %empty |
6102− %tag |
6103− %const |
6104− %union |((lien cases.t |=(c=itype (itype-var-is-restricted n c))) (lien args.t |=(c=itype (itype-var-is-restricted n c))))
6105− %recursive |
6106− %jrec |
6107− %grec (lien args.t |=(c=itype (itype-var-is-restricted n c)))
6108− %collection (lien args.t |=(c=itype (itype-var-is-restricted n c)))
6109− %face $(t body.t)
6110− %fn |($(t sample.t) $(t product.t))
6111− %cell |($(t hed.t) $(t tal.t))
6112− ==
61135393::
61145394:: Canonical numbering makes printed variables independent of the order
61155395:: the unifier happened to allocate intermediates.
@@ -6121,7 +5401,7 @@
61215401 =/ n=@ud 0
61225402 |-
61235403 ?~ vars (itype-rename t ren)
6124− =/ replacement=itype ?:((itype-var-is-restricted i.vars t) [%rvar n] ?:((itype-var-is-atom i.vars t) [%avar n] [%var n]))
5404+ =/ replacement=itype ?:((itype-var-is-atom i.vars t) [%avar n] [%var n])
61255405 $(vars t.vars, ren [[i.vars replacement] ren], n +(n))
61265406::
61275407++ instantiate-scheme
@@ -6132,11 +5412,11 @@
61325412 |-
61335413 ?~ vars [(itype-rename typ.scheme ren) state]
61345414 =/ replacement=itype
6135− ?:((itype-var-is-restricted i.vars typ.scheme) [%rvar next.state] ?:((itype-var-is-atom i.vars typ.scheme) [%avar next.state] [%var next.state]))
5415+ ?:((itype-var-is-atom i.vars typ.scheme) [%avar next.state] [%var next.state])
61365416 :: A generalized atom variable is a valid origin for re-generalizing
61375417 :: an alias, just as a sample binder is.
61385418 =/ st=istate state(next +(next.state))
6139− =? binders.st |(?=(%avar -.replacement) ?=(%rvar -.replacement)) [next.state binders.state]
5419+ =? binders.st ?=(%avar -.replacement) [next.state binders.state]
61405420 $(vars t.vars, ren [[i.vars replacement] ren], state st)
61415421::
61425422++ icap-lookup
@@ -6207,11 +5487,6 @@
62075487 ?. ?=([%ref @ @] node) ~
62085488 ?. &(=(module +<.node) =(name +>.node)) ~
62095489 `[[%unknown ~] &]
6210− %apply
6211− ?. ?=([%apply %list [* ~]] node) ~
6212− =/ item $(node -.+>.node)
6213− ?~ item ~
6214− `[[%or ~[[%atom `0] [%cell pat.u.item [%unknown ~]]]] has.u.item]
62155490 %face
62165491 ?. ?=([%face @ *] node) ~
62175492 ?. (jibb-face-name +<.node) ~
@@ -6266,10 +5541,6 @@
62665541 %cell ?:(?=([%cell * *] node) (imported-record-faces-valid node ~) |)
62675542 %fork (imported-faces-valid-list +.node)
62685543 %apply ?:(?=([%apply @ *] node) (imported-faces-valid-list +>.node) |)
6269− %named
6270− ?. ?=([%named @ @ *] node) |
6271− =/ n=[%named module=@ name=@ body=*] ;;([%named module=@ name=@ body=*] node)
6272− (imported-faces-valid body.n)
62735544 ==
62745545::
62755546++ imported-faces-valid-list
@@ -6301,19 +5572,7 @@
63015572 ^- (unit itype)
63025573 ?@ node ~
63035574 ?+ -.node ~
6304− %noun ?:(=(node [%noun ~]) `[%noun ~] ~)
63055575 %atom
6306− :: A Hoon loobean singleton is one of the two Jibb loobeans.
6307− ?: ?=([%atom %f [~ @]] node)
6308− =/ value=@ +>+.node
6309− ?. |(=(value 0) =(value 1)) ~
6310− =/ printed=@t ?:(=(value 0) '%.y' '%.n')
6311− `[%const [%loobean %f value printed]]
6312− :: Hoon's null singleton is the same noun as Jibb's `~` mold.
6313− :: Other non-term singleton atoms remain unsupported here.
6314− ?: ?=([%atom %n [~ @]] node)
6315− ?. =(0 +>+.node) ~
6316− `[%const [%null %n 0 '~']]
63175576 ?: ?=([%atom %tas [~ @]] node)
63185577 =/ value=@ +>+.node
63195578 ?. |(=(value 0) (jibb-face-name value)) ~
@@ -6323,15 +5582,6 @@
63235582 =/ aura=@ta (@ta +<.node)
63245583 ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
63255584 `[%atom aura]
6326− %named
6327− ?. ?=([%named @ @ *] node) ~
6328− =/ n=[%named module=@ name=@ body=*] ;;([%named module=@ name=@ body=*] node)
6329− ?. &((jibb-face-name module.n) (jibb-face-name name.n)) ~
6330− ?. ?=([%fork *] body.n) ~
6331− =/ proof=(unit irec-pattern) (rec-pattern body.n (@tas module.n) (@tas name.n))
6332− ?~ proof ~
6333− ?. has.u.proof ~
6334− `[%recursive (@tas module.n) (@tas name.n) `(crip "{(trip name.n)}.{(trip module.n)}")]
63355585 %apply
63365586 ?. ?=([%apply @ *] node) ~
63375587 =/ name=term (@tas +<.node)
@@ -6345,15 +5595,10 @@
63455595 ?. =(arity (lent u.args)) ~
63465596 `[%collection name u.args]
63475597 %fork
6348− :: Hoon's ordinary ? mold is the fork of its two %f singletons.
6349− =/ raw=* +.node
6350− ?: |(=(raw ~[[%atom %f `0] [%atom %f `1]]) =(raw ~[[%atom %f `1] [%atom %f `0]]))
6351− `[%flag ~]
6352− =/ cases=(unit (list itype)) (import-to-itypes raw)
5598+ =/ cases=(unit (list itype)) (import-to-itypes +.node)
63535599 ?~ cases ~
63545600 ?~ u.cases ~
63555601 ?~ t.u.cases ~
6356− ?: (import-has-loobean-singleton u.cases) ~
63575602 ?. (import-cases-disjoint u.cases) ~
63585603 `[%union u.cases ~ ~ ~]
63595604 %face
@@ -6372,20 +5617,6 @@
63725617 `[%cell u.left u.right]
63735618 ==
63745619::
6375−++ import-direct-loobean
6376− |= t=itype
6377− ^- ?
6378− ?: ?=(%face -.t) $(t body.t)
6379− ?: ?=(%union -.t) (import-has-loobean-singleton cases.t)
6380− ?=([%const [%loobean *]] t)
6381−::
6382−++ import-has-loobean-singleton
6383− |= cases=(list itype)
6384− ^- ?
6385− ?~ cases |
6386− ?: (import-direct-loobean i.cases) &
6387− $(cases t.cases)
6388−::
63895620++ import-to-itypes
63905621 |= nodes=*
63915622 ^- (unit (list itype))
@@ -6400,10 +5631,7 @@
64005631 |= typ=itype
64015632 ^- upat
64025633 ?- -.typ
6403− %noun [%all ~]
6404− %empty [%empty ~]
64055634 %atom [%atom ~]
6406− %flag [%or ~[[%atom `0] [%atom `1]]]
64075635 %const [%atom `val.literal.typ]
64085636 %face $(typ body.typ)
64095637 %cell [%cell $(typ hed.typ) $(typ tal.typ)]
@@ -6498,85 +5726,25 @@
64985726 ?:(=(`origin origin.typ.template) `name.i.molds $(molds t.molds))
64995727 $(molds t.molds)
65005728::
6501−:: A prelude union alias is a display name, not a new union identity. An
6502−:: identity-generic alias can carry the origin's arguments only when the
6503−:: origin, arity and ordered parameters match. Swapped, repeated, fixed
6504−:: or phantom parameters cannot be printed that way and remain unsupported
6505−:: when their only available name is private. A nongeneric alias of a
6506−:: generic instantiation cannot be printed with the origin's arguments.
6507−++ identity-union-parameters
6508− |= [vars=(list @ud) args=(list itype)]
6509− ^- ?
6510− ?~ vars ?=(~ args)
6511− ?~ args |
6512− ?. =([%var i.vars] i.args) |
6513− $(vars t.vars, args t.args)
6514−++ prelude-union-alias
6515− |= [origin=[at=path name=term] args=(list itype) molds=imold-types]
6516− ^- (unit term)
6517− ?~ molds ~
6518− =/ template=ischeme template.i.molds
6519− ?. ?=(%union -.typ.template) $(molds t.molds)
6520− ?. =(`origin origin.typ.template) $(molds t.molds)
6521− ?~ vars.template
6522− ?^ args $(molds t.molds)
6523− ?:(=(args args.typ.template) `name.i.molds $(molds t.molds))
6524− ?: &((identity-union-parameters vars.template args.typ.template) =((lent vars.template) (lent args)))
6525− `name.i.molds
6526− $(molds t.molds)
6527−::
6528−:: Names exported by the directly imported module are visible through its
6529−:: face; a matching prelude alias is also visible without a qualifier.
6530−::
6531−++ jrec-alias
6532− |= [origin=path name=term molds=imold-types]
6533− ^- (unit term)
6534− ?~ molds ~
6535− =/ template=ischeme template.i.molds
6536− ?: &(?=(~ vars.template) ?=(%jrec -.typ.template) =(at.typ.template origin) =(name.typ.template name)) `name.i.molds
6537− $(molds t.molds)
6538−::
6539−++ grec-visible-alias
6540− |= [origin=path name=term proof=shape args=(list itype) molds=imold-types]
6541− ^- (unit term)
6542− ?~ molds ~
6543− =/ template=ischeme template.i.molds
6544− ?. ?=(%grec -.typ.template) $(molds t.molds)
6545− ?. &(=(at.typ.template origin) =(name.typ.template name) =(proof.typ.template proof)) $(molds t.molds)
6546− ?. &((identity-union-parameters vars.template args.typ.template) =((lent vars.template) (lent args))) $(molds t.molds)
6547− `name.i.molds
5729+:: Only names exported by this directly imported module are visible through
5730+:: its face. Other origins retain identity but print as unnamed unions.
65485731::
65495732++ itype-in-import
6550− |= [t=itype iface=ifile face=term prelude=(unit ifile)]
5733+ |= [t=itype iface=ifile face=term]
65515734 ^- itype
65525735 ?- -.t
65535736 %union
65545737 =/ label=(unit @t)
65555738 ?~ origin.t ~
65565739 ?: =(at.u.origin.t /lib/jibb/prelude/jibb) `name.u.origin.t
6557− =/ public=(unit term)
6558− ?~ prelude ~
6559− (prelude-union-alias u.origin.t args.t molds.u.prelude)
6560− ?^ public `u.public
65615740 =/ alias=(unit term) ~
65625741 =? alias &(=(at.u.origin.t at.iface) ?=(^ (find-jibb-mold name.u.origin.t iface))) `name.u.origin.t
65635742 =? alias ?=(~ alias) (imported-union-alias u.origin.t molds.iface)
65645743 ?~ alias ~
65655744 `(crip "{(trip u.alias)}.{(trip face)}")
6566− [%union (turn cases.t |=(c=itype (itype-in-import c iface face prelude))) origin.t label (turn args.t |=(c=itype (itype-in-import c iface face prelude)))]
5745+ [%union (turn cases.t |=(c=itype (itype-in-import c iface face))) origin.t label (turn args.t |=(c=itype (itype-in-import c iface face)))]
65675746 %recursive [%recursive module.t name.t ~]
6568− %grec
6569− =/ public=(unit term) ?~(prelude ~ (grec-visible-alias at.t name.t proof.t args.t molds.u.prelude))
6570− =/ alias=(unit term) ?~(public (grec-visible-alias at.t name.t proof.t args.t molds.iface) public)
6571− =/ label=(unit @t) ?~(alias ~ ?~(public `(crip "{(trip u.alias)}.{(trip face)}") `u.alias))
6572− t(label label, args (turn args.t |=(c=itype (itype-in-import c iface face prelude))))
6573− %jrec
6574− =/ public=(unit term) ?~(prelude ~ (jrec-alias at.t name.t molds.u.prelude))
6575− ?^ public t(label `u.public)
6576− =/ alias=(unit term) (jrec-alias at.t name.t molds.iface)
6577− ?~ alias t(label ~)
6578− t(label `(crip "{(trip u.alias)}.{(trip face)}"))
6579− %collection [%collection name.t (turn args.t |=(c=itype (itype-in-import c iface face prelude)))]
5747+ %collection [%collection name.t (turn args.t |=(c=itype (itype-in-import c iface face)))]
65805748 %face [%face name.t $(t body.t)]
65815749 %fn [%fn $(t sample.t) $(t product.t)]
65825750 %cell [%cell $(t hed.t) $(t tal.t)]
@@ -6649,66 +5817,9 @@
66495817 =/ rest=[params=iparams vars=(list @ud) next=@ud] $(names t.names, next +(next))
66505818 [[[i.names [%var next]] params.rest] [next vars.rest] next.rest]
66515819::
6652−:: Recognize a unique top-level source mold with exactly a null case and a
6653−:: faced atom-headed cell whose faced tail names that same mold. Its Jibb
6654−:: path and name provide nominal identity. Other recursive shapes fail closed;
6655−:: construction and matching expose the proven shape one layer at a time.
6656−++ simple-source-recursive
6657− |= [name=term sh=shape state=istate]
6658− ^- (unit itype)
6659− ?. (lien top-molds.state |=(n=term =(n name))) ~
6660− =/ original=(unit shape) (find-simple-mold name molds.state)
6661− ?~ original ~
6662− ?. =(u.original sh) ~
6663− ?. ?=(%union -.sh) ~
6664− =/ cs=(list shape) cases.sh
6665− ?~ cs ~
6666− ?~ t.cs ~
6667− ?^ t.t.cs ~
6668− ?. ?=(%const -.i.cs) ~
6669− ?. =(%null form.lit.i.cs) ~
6670− ?. ?=(%cell -.i.t.cs) ~
6671− =/ fs=(list field) fields.i.t.cs
6672− ?~ fs ~
6673− ?~ t.fs ~
6674− ?^ t.t.fs ~
6675− ?. ?=(%face -.i.fs) ~
6676− ?. ?=(%aura -.shape.i.fs) ~
6677− ?. !=(0 aura.shape.i.fs) ~
6678− ?. ?=(%face -.i.t.fs) ~
6679− ?. !=(name.i.fs name.i.t.fs) ~
6680− =/ tail=shape shape.i.t.fs
6681− ?. ?=(%ref -.tail) ~
6682− ?. =(names.tail ~[name]) ~
6683− `[%jrec at.state name `name name.i.fs aura.shape.i.fs name.i.t.fs]
6684−::
6685−++ simple-source-generic-recursive
6686− |= [name=term sh=shape args=(list itype) state=istate]
6687− ^- (unit itype)
6688− ?. ?=(%generic -.sh) ~
6689− ?. ?=([@ ~] vars.sh) ~
6690− ?. ?=([* ~] args) ~
6691− ?~ grec-index.state ~
6692− ?. =(at.u.grec-index.state at.state) ~
6693− ?~ prelude.state ~
6694− ?. =(prelude.u.grec-index.state u.prelude.state) ~
6695− =/ proof=(unit shape) (~(get by shapes.u.grec-index.state) name)
6696− ?~ proof ~
6697− ?. =(u.proof sh) ~
6698− `[%grec at.state name `name sh args]
6699−::
6700−
67015820++ infer-mold-template
67025821 |= [sh=shape state=istate]
67035822 ^- (unit [template=ischeme state=istate])
6704− =/ generic=(unit itype)
6705− ?. ?=([@ ~] active.state) ~
6706− (simple-source-generic-recursive i.active.state sh ~[[%var next.state]] state)
6707− ?^ generic `[[u.generic ~[next.state]] state(next +(next.state))]
6708− =/ direct=(unit itype)
6709− ?. ?=([@ ~] active.state) ~
6710− (simple-source-recursive i.active.state sh state)
6711− ?^ direct `[[u.direct ~] state]
67125823 ?: ?=(%generic -.sh)
67135824 ?~ vars.sh ~
67145825 ?. (distinct-params vars.sh) ~
@@ -6716,139 +5827,32 @@
67165827 =/ out=(unit [typ=itype state=istate])
67175828 (infer-simple-shape body.sh state(next next.fresh, params params.fresh, in-mold &))
67185829 ?~ out ~
6719− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
67205830 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.sh) ?=(~ origin.typ.u.out)) ~
67215831 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.sh))
67225832 typ.u.out(args (turn vars.fresh |=(n=@ud `itype`[%var n])))
67235833 =/ used=(list @ud) (itype-vars typ.u.out)
67245834 ?. (levy used |=(n=@ud (lien vars.fresh |=(p=@ud =(p n))))) ~
6725− `[[typ.u.out vars.fresh] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
5835+ `[[typ.u.out vars.fresh] state.u.out(params params.state, in-mold in-mold.state)]
67265836 =/ out=(unit [typ=itype state=istate])
67275837 (infer-simple-shape sh state(params ~, in-mold &))
67285838 ?~ out ~
6729− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
67305839 ?: ?=(^ (itype-vars typ.u.out)) ~
6731− `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
6732−::
6733−:: A direct imported reference may carry definite reader evidence. Only
6734−:: uniquely supplied, declared inputs are used; unsupported data stay generic.
6735−++ direct-import-invalid
6736− |= [sh=shape state=istate]
6737− ^- (unit idiag)
6738− ?. ?=(%ref -.sh) ~
6739− ?~ names.sh ~
6740− =/ n=term i.names.sh
6741− =/ raw=*
6742− ?~ t.names.sh
6743− ?. (unique-value-name n marks.state) ~
6744− ?: (lien surs.state |=(x=term =(x n))) ~
6745− ?: ?=(^ (find-jibb-interface n jimports.state)) ~
6746− ?: (lien globals.state |=(x=term =(x n))) ~
6747− ?: (lien reserved-molds.state |=(x=term =(x n))) ~
6748− ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) ~
6749− =/ found=imark-externals (skim mark-externals.state |=(e=[mark=term result=*] =(mark.e n)))
6750− ?~ found ~
6751− ?^ t.found ~
6752− result.i.found
6753− ?^ t.t.names.sh ~
6754− =/ mod=term i.t.names.sh
6755− ?: ?=(^ (find-jibb-interface mod jimports.state)) ~
6756− ?. (unique-value-name mod surs.state) ~
6757− ?: (lien marks.state |=(x=term =(x mod))) ~
6758− ?: (lien globals.state |=(x=term =(x mod))) ~
6759− ?: (lien reserved-molds.state |=(x=term =(x mod))) ~
6760− ?: (lien molds.state |=(m=[name=term body=shape] =(mod name.m))) ~
6761− =/ found=iexternals (skim externals.state |=(e=[module=term name=term result=*] &(=(module.e mod) =(name.e n))))
6762− ?~ found ~
6763− ?^ t.found ~
6764− result.i.found
6765− ?. ?=([%invalid ?(%aura %core %overlap) @] raw) ~
6766− `["{(trip +>.raw)}" ~[[at.sh "invalid imported mold"]]]
6767−::
6768−:: Replay only the shape branches whose evaluation order we can prove.
6769−:: Successful prefixes must be checked before descending to a failure.
6770−++ nested-import-invalid
6771− |= [sh=shape state=istate]
6772− ^- (unit idiag)
6773− ?: ?=(^ (infer-simple-shape sh state)) ~
6774− ?- -.sh
6775− %ref
6776− =/ direct=(unit idiag) (direct-import-invalid sh state)
6777− ?^ direct direct
6778− ?~ names.sh ~
6779− ?^ t.names.sh ~
6780− =/ n=term i.names.sh
6781− ?: (lien marks.state |=(x=term =(x n))) ~
6782− ?: (lien active.state |=(x=term =(x n))) ~
6783− =/ found=(unit shape) (find-simple-mold n molds.state)
6784− ?~ found ~
6785− $(sh u.found, state state(active [n active.state], in-mold &, params ~))
6786− %fn
6787− =/ first=(unit [typ=itype state=istate]) (infer-simple-shape sample.sh state)
6788− ?~ first $(sh sample.sh)
6789− $(sh product.sh, state state.u.first)
6790− %cell (nested-field-invalid fields.sh state)
6791− * ~
6792− ==
6793−::
6794−++ nested-field-invalid
6795− |= [fields=(list field) state=istate]
6796− ^- (unit idiag)
6797− ?~ fields ~
6798− =/ sh=shape
6799− ?- -.i.fields
6800− %bare shape.i.fields
6801− %face shape.i.fields
6802− %pun [%ref at.i.fields ~[name.i.fields]]
6803− ==
6804− =/ out=(unit [typ=itype state=istate]) (infer-simple-shape sh state)
6805− ?~ out (nested-import-invalid sh state)
6806− $(fields t.fields, state state.u.out)
6807−::
6808−++ sample-import-invalid
6809− |= [s=sample env=ienv state=istate]
6810− ^- (unit idiag)
6811− =/ result=isample-result (infer-sample s env state)
6812− ?: ?=(%& -.result) ~
6813− ?. =(p.result "sample mold is not supported by partial inference") ~
6814− ?- s
6815− [%face *] (nested-import-invalid shape.s state)
6816− [%bare *] (nested-import-invalid shape.s state)
6817− [%pun *] (nested-import-invalid [%ref at.s ~[name.s]] state)
6818− [%cell *] (nested-samples-invalid items.s env state)
6819− * ~
6820− ==
6821−::
6822−++ nested-samples-invalid
6823− |= [items=(list sample) env=ienv state=istate]
6824− ^- (unit idiag)
6825− ?~ items ~
6826− =/ head=isample-result (infer-sample i.items env state)
6827− ?: ?=(%| -.head) (sample-import-invalid i.items env state)
6828− $(items t.items, env env.p.head, state state.p.head)
5840+ `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state)]
68295841::
68305842++ infer-simple-shape
68315843 |= [sh=shape state=istate]
68325844 ^- (unit [typ=itype state=istate])
68335845 ?- -.sh
6834− %hole `[[%var next.state] state(next +(next.state), holes [[next.state at.sh] holes.state])]
68355846 %aura
68365847 ?: =(0 aura.sh) `[[%any-atom ~] state]
68375848 `[[%atom aura.sh] state]
68385849 %flag `[[%flag ~] state]
6839− %noun `[[%noun ~] state]
6840− %void `[[%empty ~] state]
68415850 %const
6842− ?. |(=(%term form.lit.sh) =(%null form.lit.sh) =(%loobean form.lit.sh)) ~
6843− ?: &(=(%loobean form.lit.sh) !|(=(0 val.lit.sh) =(1 val.lit.sh))) ~
5851+ ?. |(=(%term form.lit.sh) =(%null form.lit.sh)) ~
68445852 `[[%const lit.sh] state]
68455853 %union
68465854 =/ pairs=(list upair) (union-pairs cases.sh molds.state)
6847− ?: (lien pairs |=(p=upair =(%overlap relation.p))) ~
6848− =/ source-proof=?
6849− ?: (levy pairs |=(p=upair =(%disjoint relation.p))) &
6850− &((union-source-state-safe state 256) (union-source-distinct-tags cases.sh molds.state 256))
6851− ?. source-proof ~
5855+ ?. (levy pairs |=(p=upair =(%disjoint relation.p))) ~
68525856 =/ cs=(unit [types=(list itype) state=istate]) (infer-shape-args cases.sh state)
68535857 ?~ cs ~
68545858 `[[%union types.u.cs ~ ~ ~] state.u.cs]
@@ -6869,7 +5873,7 @@
68695873 =/ found=(unit ischeme) (find-jibb-mold n u.iface)
68705874 ?~ found ~
68715875 ?^ vars.u.found ~
6872− `[(itype-in-import typ.u.found u.iface i.t.names.sh prelude.state) state]
5876+ `[(itype-in-import typ.u.found u.iface i.t.names.sh) state]
68735877 =/ found=(unit itype)
68745878 (find-imported-mold i.t.names.sh n externals.state surs.state)
68755879 ?~ found ~
@@ -6888,13 +5892,10 @@
68885892 ?~ prelude-entry ~
68895893 ?^ vars.u.prelude-entry ~
68905894 `[typ.u.prelude-entry state]
6891− =/ direct=(unit itype) (simple-source-recursive n u.found state)
6892− ?^ direct `[u.direct state]
68935895 =/ out=(unit [typ=itype state=istate])
68945896 $(sh u.found, state state(active [n active.state], in-mold &, params ~))
68955897 ?~ out ~
6896− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
6897− `[(label-direct-union typ.u.out u.found n state) state.u.out(active active.state, in-mold in-mold.state, params params.state, holes holes.state)]
5898+ `[(label-direct-union typ.u.out u.found n state) state.u.out(active active.state, in-mold in-mold.state, params params.state)]
68985899 %apply
68995900 ?~ ref.sh ~
69005901 =/ args=(unit [types=(list itype) state=istate]) (infer-shape-args args.sh state)
@@ -6909,7 +5910,7 @@
69095910 ?~ vars.u.template ~
69105911 =/ applied=(unit itype) (template-apply u.template types.u.args)
69115912 ?~ applied ~
6912− `[(itype-in-import u.applied u.iface i.t.ref.sh prelude.state.u.args) state.u.args]
5913+ `[(itype-in-import u.applied u.iface i.t.ref.sh) state.u.args]
69135914 ?: (lien active.state.u.args |=(x=term =(x n))) ~
69145915 =/ found=(unit shape) (find-simple-mold n molds.state.u.args)
69155916 ?~ found
@@ -6922,20 +5923,17 @@
69225923 ?~ applied ~
69235924 `[u.applied state.u.args]
69245925 ?. ?=(%generic -.u.found) ~
6925− =/ grec=(unit itype) (simple-source-generic-recursive n u.found types.u.args state.u.args)
6926− ?^ grec `[u.grec state.u.args]
69275926 ?. (distinct-params vars.u.found) ~
69285927 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
69295928 ?~ params ~
69305929 =/ out=(unit [typ=itype state=istate])
69315930 $(sh body.u.found, state state.u.args(active [n active.state.u.args], in-mold &, params u.params))
69325931 ?~ out ~
6933− ?^ (unresolved-hole holes.state.u.out holes.state.u.args state.u.out) ~
69345932 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.u.found) ?=(~ origin.typ.u.out)) ~
69355933 ?: &(?=(%union -.typ.u.out) ?=(%union -.body.u.found) !(lien top-molds.state.u.args |=(x=term =(x n)))) ~
69365934 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.u.found))
69375935 (label-direct-union typ.u.out(args types.u.args) u.found n state.u.args)
6938− `[typ.u.out state.u.out(active active.state.u.args, in-mold in-mold.state.u.args, params params.state.u.args, holes holes.state.u.args)]
5936+ `[typ.u.out state.u.out(active active.state.u.args, in-mold in-mold.state.u.args, params params.state.u.args)]
69395937 %tvar
69405938 =/ param=(unit itype) (iparam-lookup name.sh params.state)
69415939 ?^ param `[u.param state]
@@ -6975,12 +5973,12 @@
69755973 ^- isample-result
69765974 ?- -.s
69775975 %bind
6978− ?: |(=(name.s %proj) ?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
5976+ ?: |(?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
69795977 [%| "sample shadows a name"]
69805978 =/ t=itype [%var next.state]
69815979 [%& t [[name.s [t ~]] env] state(next +(next.state), binders [next.state binders.state])]
69825980 %face
6983− ?: |(=(name.s %proj) ?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
5981+ ?: |(?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
69845982 [%| "sample shadows a name"]
69855983 =/ t=(unit [typ=itype state=istate]) (infer-simple-shape shape.s state)
69865984 ?~ t [%| "sample mold is not supported by partial inference"]
@@ -7018,8 +6016,8 @@
70186016 [%& [%cell ht typ.p.tail] env.p.tail state.p.tail]
70196017::
70206018:: Local definitions generalize only variables outside their enclosing
7021−:: environment and explicit-capital scope. Recursive gate groups use
7022−:: monomorphic placeholders while their bodies are checked.
6019+:: environment and explicit-capital scope. Unresolved groups stay
6020+:: unsupported: this fragment does not infer recursive definitions.
70236021::
70246022+$ ilocal-result (each [env=ienv state=istate] idiag)
70256023++ free-env-vars
@@ -7048,7 +6046,6 @@
70486046 |-
70496047 ?~ ds &
70506048 ?: ?=(%mold -.i.ds) $(ds t.ds)
7051− ?: =(name.i.ds %proj) |
70526049 ?. (unique-value-name name.i.ds names) |
70536050 ?: ?=(^ (ienv-lookup name.i.ds env)) |
70546051 ?: (lien globals.state |=(n=term =(n name.i.ds))) |
@@ -7072,7 +6069,6 @@
70726069 |-
70736070 ?~ locals &
70746071 =/ n=term name.i.locals
7075− ?: =(n %proj) |
70766072 ?. (unique-value-name n names) |
70776073 ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) |
70786074 ?: (lien marks.state |=(m=term =(n m))) |
@@ -7090,145 +6086,6 @@
70906086 ?~ inferred |
70916087 $(locals t.locals)
70926088::
7093−:: Gather written capitals belonging to one ++. Nested local definitions
7094−:: establish their own scopes; inline gates remain in the enclosing scope.
7095−+$ icap-site [name=@t at=span]
7096−++ scope-shape
7097− |= s=shape
7098− ^- (list icap-site)
7099− ?- -.s
7100− %tvar ~[[name.s at.s]]
7101− %apply (zing (turn args.s scope-shape))
7102− %cell (zing (turn fields.s scope-field))
7103− %union (zing (turn cases.s scope-shape))
7104− %fn (weld (scope-shape sample.s) (scope-shape product.s))
7105− %generic
7106− =/ inside=(list icap-site) (scope-shape body.s)
7107− (skim inside |=(site=icap-site !(lien vars.s |=(v=@t =(v name.site)))))
7108− * ~
7109− ==
7110−::
7111−++ scope-field
7112− |= f=field
7113− ^- (list icap-site)
7114− ?- -.f
7115− %face (scope-shape shape.f)
7116− %bare (scope-shape shape.f)
7117− %pun ~
7118− ==
7119−::
7120−++ scope-sample
7121− |= s=sample
7122− ^- (list icap-site)
7123− ?- -.s
7124− %face (scope-shape shape.s)
7125− %bare (scope-shape shape.s)
7126− %cell (zing (turn items.s scope-sample))
7127− * ~
7128− ==
7129−::
7130−++ scope-pieces
7131− |= ps=(list piece)
7132− ^- (list icap-site)
7133− ?~ ps ~
7134− =/ first=(list icap-site)
7135− ?- -.i.ps
7136− %expr (scope-expr p.i.ps)
7137− %text ~
7138− ==
7139− (weld first $(ps t.ps))
7140−::
7141−++ scope-qsegs
7142− |= ps=(list qseg)
7143− ^- (list icap-site)
7144− ?~ ps ~
7145− =/ first=(list icap-site)
7146− ?- -.i.ps
7147− %expr (scope-expr p.i.ps)
7148− %knot ~
7149− ==
7150− (weld first $(ps t.ps))
7151−::
7152−++ scope-edits
7153− |= xs=(list edit)
7154− ^- (list icap-site)
7155− ?~ xs ~
7156− =/ first=(list icap-site) (scope-expr val.i.xs)
7157− (weld first $(xs t.xs))
7158−::
7159−++ scope-items
7160− |= xs=(list item)
7161− ^- (list icap-site)
7162− ?~ xs ~
7163− =/ first=(list icap-site) (scope-expr val.i.xs)
7164− (weld first $(xs t.xs))
7165−::
7166−++ scope-arms
7167− |= xs=(list arm)
7168− ^- (list icap-site)
7169− ?~ xs ~
7170− =/ first=(list icap-site) (scope-expr val.i.xs)
7171− (weld first $(xs t.xs))
7172−::
7173−++ scope-exprs
7174− |= xs=(list expr)
7175− ^- (list icap-site)
7176− ?~ xs ~
7177− =/ first=(list icap-site) (scope-expr i.xs)
7178− (weld first $(xs t.xs))
7179−::
7180−++ scope-expr
7181− |= e=expr
7182− ^- (list icap-site)
7183− ?- -.e
7184− %str (scope-pieces pieces.e)
7185− %qath (scope-qsegs segs.e)
7186− %change (scope-edits edits.e)
7187− %pair (scope-expr val.e)
7188− %unit (scope-expr val.e)
7189− %group (scope-expr inner.e)
7190− %list (scope-exprs items.e)
7191− %tuple (scope-items items.e)
7192− %gate
7193− =/ first=(list icap-site) (scope-sample sample.e)
7194− =/ last=(list icap-site) (scope-expr body.e)
7195− (weld first last)
7196− %gate-wide
7197− =/ first=(list icap-site) (scope-sample sample.e)
7198− =/ last=(list icap-site) (scope-expr body.e)
7199− (weld first last)
7200− %call
7201− =/ first=(list icap-site) (scope-expr head.e)
7202− =/ last=(list icap-site) (scope-exprs args.e)
7203− (weld first last)
7204− %cast
7205− =/ first=(list icap-site) (scope-shape shape.e)
7206− =/ last=(list icap-site) (scope-expr val.e)
7207− (weld first last)
7208− %trace
7209− =/ first=(list icap-site) (scope-expr val.e)
7210− =/ last=(list icap-site) (scope-expr then.e)
7211− (weld first last)
7212− %branch
7213− =/ first=(list icap-site) (scope-expr subject.e)
7214− =/ last=(list icap-site) (scope-arms arms.e)
7215− (weld first last)
7216− %body (scope-expr final.e)
7217− * ~
7218− ==
7219−::
7220−++ reserve-cap-sites
7221− |= [sites=(list icap-site) state=istate]
7222− ^- istate
7223− ?~ sites state
7224− ?: ?=(^ (icap-lookup name.i.sites caps.state)) $(sites t.sites)
7225− $(sites t.sites, state state(next +(next.state), caps [[name.i.sites next.state at.i.sites] caps.state]))
7226−::
7227−++ reserve-def-caps
7228− |= [e=expr state=istate]
7229− ^- istate
7230− (reserve-cap-sites (scope-expr e) state)
7231−::
72326089++ infer-local-defs
72336090 |= [ds=(list def) env=ienv state=istate]
72346091 ^- ilocal-result
@@ -7237,63 +6094,22 @@
72376094 |-
72386095 ?~ ds
72396096 ?~ remaining [%& env state]
7240− ?. progressed
7241− =/ pending=(list def) (flop remaining)
7242− =/ groups=icomponents (graph-components pending (global-value-names pending))
7243− =/ grouped=(unit [rest=(list def) env=ienv state=istate])
7244− (try-local-group pending groups env state)
7245− ?~ grouped [%| ["local definitions need unsupported inference" ~]]
7246− $(ds rest.u.grouped, remaining ~, env env.u.grouped, state state.u.grouped, progressed |)
6097+ ?. progressed [%| ["local definitions need unsupported inference" ~]]
72476098 $(ds (flop remaining), remaining ~, progressed |)
72486099 =/ d=def i.ds
72496100 ?> ?=(%value -.d)
7250− =/ local-state=istate (reserve-def-caps val.d state)
7251− =/ inferred=iresult (infer-fragment val.d env local-state)
7252− =/ retried=? ?=(%| -.inferred)
7253− =? inferred retried (infer-recursive-gate d env local-state)
6101+ =/ inferred=iresult (infer-fragment val.d env state)
72546102 ?: ?=(%| -.inferred) $(ds t.ds, remaining [d remaining])
7255− ?: !=(obligations.state.p.inferred obligations.state) [%| ["deferred local definition needs unsupported inference" ~]]
7256− =. state.p.inferred (promote-restricted-numbers state.p.inferred env)
7257− =. state.p.inferred (default-hole-numbers holes.state.p.inferred holes.state state.p.inferred env !(itype-has-gate (itype-normalize typ.p.inferred sub.state.p.inferred)))
7258− =/ hole=(unit idiag) (unresolved-hole holes.state.p.inferred holes.state state.p.inferred)
7259− ?^ hole [%| u.hole]
7260− =/ merged=(unit [first=icap second=icap])
7261− (merged-capitals caps.state.p.inferred sub.state.p.inferred)
7262− ?^ merged
7263− [%| ["distinct type variables `{(trip name.first.u.merged)}` and `{(trip name.second.u.merged)}` must not be forced equal; use the same capital for a shared type" ~[[at.first.u.merged "first type variable"] [at.second.u.merged "second type variable"]]]]
7264− ?: (constrained-capitals caps.state.p.inferred sub.state.p.inferred)
7265− [%| ["explicit capital constraints are not supported by partial inference" ~]]
72666103 =/ typ=itype (itype-normalize typ.p.inferred sub.state.p.inferred)
72676104 ?: |((pending-tags tags.state.p.inferred sub.state.p.inferred) (itype-has-tag typ))
72686105 $(ds t.ds, remaining [d remaining])
72696106 ?: (unsupported-atom-vars typ caps.state.p.inferred binders.state.p.inferred sub.state.p.inferred)
72706107 $(ds t.ds, remaining [d remaining])
72716108 =/ free=(list @ud)
7272− (weld (free-env-vars env sub.state.p.inferred) (free-cap-vars caps.state sub.state.p.inferred))
6109+ (weld (free-env-vars env sub.state.p.inferred) (free-cap-vars caps.state.p.inferred sub.state.p.inferred))
72736110 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
72746111 =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
7275− $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred(caps caps.state, holes holes.state), progressed &)
7276−::
7277−:: Try complete cyclic local groups after individual definitions stall.
7278−:: Components with non-gates or unresolved constraints stay unavailable.
7279−::
7280−++ try-local-group
7281− |= [ds=(list def) groups=icomponents env=ienv state=istate]
7282− ^- (unit [rest=(list def) env=ienv state=istate])
7283− ?~ groups ~
7284− =/ names=(list term) i.groups
7285− ?. (gth (lent names) 1) $(groups t.groups)
7286− =/ members=(list def)
7287− (skim ds |=(d=def &(?=(%value -.d) (lien names |=(n=term =(n name.d))))))
7288− ?. =((lent members) (lent names)) $(groups t.groups)
7289− =/ result=ilocal-result (infer-gate-group members env state)
7290− ?: ?=(%| -.result) $(groups t.groups)
7291− =/ rest=(list def)
7292− (skim ds |=(d=def !(lien names |=(n=term =(n name.d)))))
7293− =/ more=(unit [rest=(list def) env=ienv state=istate])
7294− $(ds rest, groups t.groups, env env.p.result, state state.p.result)
7295− ?^ more more
7296− `[rest env.p.result state.p.result]
6112+ $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred, progressed &)
72976113::
72986114:: Read only fields of a known record. Unresolved field constraints and
72996115:: ambiguous repeated faces are outside this fragment. Imported record
@@ -7316,29 +6132,17 @@
73166132 ^- iresult
73176133 =/ reverse=(list term) (flop names)
73186134 ?~ reverse [%| ["empty wing" ~]]
7319− =/ iface=(unit ifile) (find-jibb-interface i.reverse jimports.state)
6135+ =/ scheme=(unit ischeme) (ienv-lookup i.reverse env)
6136+ ?~ scheme [%| ["field access is not supported by partial inference" ~]]
6137+ =/ inst=[typ=itype state=istate] (instantiate-scheme u.scheme state)
73206138 =/ fields=(list term) t.reverse
7321− ?~ fields [%| ["field access is not supported by partial inference" ~]]
7322− =/ scheme=(unit ischeme)
7323− ?~ iface
7324− (ienv-lookup i.reverse env)
7325− (ienv-lookup i.fields values.u.iface)
7326− ?~ scheme
7327− ?^ iface [%| ["module member is not available to partial inference" ~]]
7328− [%| ["field access is not supported by partial inference" ~]]
7329− =/ inst=[typ=itype state=istate]
7330− ?~ iface (instantiate-scheme u.scheme state)
7331− =/ imported=ischeme u.scheme
7332− =. typ.imported (itype-in-import typ.imported u.iface i.reverse prelude.state)
7333− (instantiate-scheme imported state)
7334− =/ remaining=(list term) ?~(iface fields t.fields)
73356139 =/ typ=itype typ.inst
73366140 |-
7337− ?~ remaining [%& typ state.inst]
7338− =/ found=(list itype) (record-fields-named i.remaining typ sub.state.inst)
6141+ ?~ fields [%& typ state.inst]
6142+ =/ found=(list itype) (record-fields-named i.fields typ sub.state.inst)
73396143 ?~ found [%| ["field is not available to partial inference" ~]]
73406144 ?^ t.found [%| ["field name is ambiguous in partial inference" ~]]
7341− $(remaining t.remaining, typ i.found)
6145+ $(fields t.fields, typ i.found)
73426146::
73436147:: Propagate a known union or list through supported loobean, unit and list
73446148:: branches. Empty bodies and groups are transparent; bodies with definitions
@@ -7362,8 +6166,6 @@
73626166 ?: &(?=(%collection -.expected) =(%list name.expected) (context-list-expression e))
73636167 (infer-list-context e expected env state context)
73646168 ?: ?=(%branch -.e)
7365− =/ empty-list=(unit iresult) (empty-list-null-branch e env state `[expected context])
7366− ?^ empty-list u.empty-list
73676169 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
73686170 ?~ t.arms.e [%| ["branch pattern is not supported by partial inference" ~]]
73696171 ?^ t.t.arms.e [%| ["branch is not supported by partial inference" ~]]
@@ -7379,9 +6181,6 @@
73796181 [%| ["branch does not cover both loobeans" ~]]
73806182 =/ subject=iresult (infer-fragment subject.e env state)
73816183 ?: ?=(%| -.subject) subject
7382− =/ subject-type=itype (itype-normalize typ.p.subject sub.state.p.subject)
7383− ?: ?=(%union -.subject-type)
7384− [%| ["contextual union-pattern branch is not supported by partial inference" ~]]
73856184 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
73866185 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
73876186 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
@@ -7395,17 +6194,10 @@
73956194 ?: ?=(%unknown -.fit)
73966195 ?: &(?=(%collection -.expected) =(%list name.expected))
73976196 [%| ["branch list constraint is not supported by partial inference" ~]]
7398− ?: ?=(%flag -.expected) [%| ["branch loobean constraint is not supported by partial inference" ~]]
73996197 [%| ["branch union constraint is not supported by partial inference" ~]]
74006198 ?: ?=(%bad -.fit)
7401− =/ missing=(unit idiag) (missing-union-tag e expected sub.state.p.value context)
7402− ?^ missing [%| u.missing]
7403− =/ nested=(unit idiag) (nested-missing-tag e typ.p.value expected sub.state.p.value next.state.p.value context)
7404− ?^ nested [%| u.nested]
74056199 ?: &(?=(%collection -.expected) =(%list name.expected))
74066200 [%| ["branch arm does not fit its expected list" ~[[context "expected list"] [(span-of e) "branch arm"]]]]
7407− ?: ?=(%flag -.expected)
7408− [%| ["branch arm does not fit its expected loobean" ~[[context "expected loobean"] [(span-of e) "branch arm"]]]]
74096201 [%| ["branch arm does not fit its expected union" ~[[context "expected union"] [(span-of e) "branch arm"]]]]
74106202 [%& expected state.p.value(sub sub.fit, next next.fit)]
74116203::
@@ -7470,37 +6262,23 @@
74706262 [%| ["list tail does not fit its expected type" ~[[context (site-type-note "expected list" target sub.state.p.tail)] [(span-of val.i.t.items.e) (site-type-note "list tail" typ.p.tail sub.state.p.tail)]]]]
74716263 [%& target state.p.tail(sub sub.fit, next next.fit)]
74726264::
7473−++ infer-open-list-items
7474− |= [items=(list expr) expected=itype env=ienv state=istate context=span]
7475− ^- iresult
7476− ?~ items [%& expected state]
7477− =/ target=itype (itype-walk expected sub.state)
7478− =/ value=iresult (infer-call-context-arg i.items target env state context)
7479− ?: ?=(%| -.value) value
7480− =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
7481− ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
7482− ?: ?=(%bad -.fit)
7483− ?: |((itype-family-related typ.p.value target sub.state.p.value) (itype-has-any-atom typ.p.value sub.state.p.value) (itype-has-any-atom target sub.state.p.value))
7484− [%| ["list item widening is not supported by partial inference" ~]]
7485− [%| ["list items do not have compatible types" ~[[context (site-type-note "expected item" target sub.state.p.value)] [(span-of i.items) (site-type-note "list item" typ.p.value sub.state.p.value)]]]]
7486− ?: (itype-has-tag (itype-normalize expected sub.fit))
7487− [%| ["list item needs context in partial inference" ~]]
7488− $(items t.items, state state.p.value(sub sub.fit, next next.fit))
7489−::
74906265++ infer-list-items
74916266 |= [items=(list expr) expected=itype env=ienv state=istate context=span]
74926267 ^- iresult
74936268 ?~ items [%& expected state]
74946269 =/ target=itype (itype-walk expected sub.state)
7495− =/ value=iresult (infer-call-context-arg i.items target env state context)
6270+ =/ value=iresult
6271+ ?: &(?=(%union -.target) (context-union-branch i.items))
6272+ (infer-union-context i.items target env state context)
6273+ ?: &(?=(%collection -.target) =(%list name.target) (context-union-branch i.items))
6274+ (infer-union-context i.items target env state context)
6275+ ?: &(?=(%collection -.target) =(%list name.target) (context-list-expression i.items))
6276+ (infer-list-context i.items target env state context)
6277+ (infer-fragment i.items env state)
74966278 ?: ?=(%| -.value) value
74976279 =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
74986280 ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
74996281 ?: ?=(%bad -.fit)
7500− =/ missing=(unit idiag) (missing-union-tag i.items target sub.state.p.value context)
7501− ?^ missing [%| u.missing]
7502− =/ nested=(unit idiag) (nested-missing-tag i.items typ.p.value target sub.state.p.value next.state.p.value context)
7503− ?^ nested [%| u.nested]
75046282 [%| ["list item does not fit its expected type" ~[[context (site-type-note "expected item" target sub.state.p.value)] [(span-of i.items) (site-type-note "list item" typ.p.value sub.state.p.value)]]]]
75056283 $(items t.items, state state.p.value(sub sub.fit, next next.fit))
75066284::
@@ -7581,11 +6359,6 @@
75816359 [%| ["list pattern needs the standard prelude in partial inference" ~]]
75826360 ?~ args.typ [%| ["list pattern is not supported by partial inference" ~]]
75836361 ?^ t.args.typ [%| ["list pattern is not supported by partial inference" ~]]
7584− =/ item-live=(unit [result=?(%yes %no %unknown) left=@ud])
7585− (itype-inhabited-proof i.args.typ sub.state caps.state 256)
7586− ?~ item-live [%| ["list element reachability needs unsupported inference" ~]]
7587− ?: =(%unknown result.u.item-live) [%| ["list element reachability needs unsupported inference" ~]]
7588− ?: =(%no result.u.item-live) [%| ["list nonempty pattern is unreachable" ~]]
75896362 ?~ arms.e [%| ["list branch is not supported by partial inference" ~]]
75906363 ?~ t.arms.e [%| ["list branch is not supported by partial inference" ~]]
75916364 ?^ t.t.arms.e [%| ["list branch is not supported by partial inference" ~]]
@@ -7598,7 +6371,7 @@
75986371 [%| ["list branch pattern is not supported by partial inference" ~]]
75996372 =/ binder=(unit [head=term tail=term]) ?:(first-empty second-name first-name)
76006373 ?~ binder [%| ["list branch pattern is not supported by partial inference" ~]]
7601− ?: |(=(head.u.binder %proj) =(tail.u.binder %proj) =(head.u.binder tail.u.binder) ?=(^ (ienv-lookup head.u.binder env)) ?=(^ (ienv-lookup tail.u.binder env)) (lien globals.state |=(n=term |(=(n head.u.binder) =(n tail.u.binder)))))
6374+ ?: |(=(head.u.binder tail.u.binder) ?=(^ (ienv-lookup head.u.binder env)) ?=(^ (ienv-lookup tail.u.binder env)) (lien globals.state |=(n=term |(=(n head.u.binder) =(n tail.u.binder)))))
76026375 [%| ["pattern binder shadows a name" ~]]
76036376 =/ extended=ienv [[head.u.binder [i.args.typ ~]] [tail.u.binder [typ ~]] env]
76046377 =/ left=iresult
@@ -7635,15 +6408,10 @@
76356408 [%| ["unit branch pattern is not supported by partial inference" ~]]
76366409 =/ binder=(unit term) ?:(first-empty second-name first-name)
76376410 ?~ binder [%| ["unit branch pattern is not supported by partial inference" ~]]
7638− ?: |(=(u.binder %proj) ?=(^ (ienv-lookup u.binder env)) (lien globals.state |=(n=term =(n u.binder))))
6411+ ?: |(?=(^ (ienv-lookup u.binder env)) (lien globals.state |=(n=term =(n u.binder))))
76396412 [%| ["pattern binder shadows a name" ~]]
76406413 =/ payload=(unit itype) (unit-union-payload typ)
76416414 ?~ payload [%| ["unit branch subject is not supported by partial inference" ~]]
7642− =/ payload-live=(unit [result=?(%yes %no %unknown) left=@ud])
7643− (itype-inhabited-proof u.payload sub.state.p.subject caps.state.p.subject 256)
7644− ?~ payload-live [%| ["unit payload reachability needs unsupported inference" ~]]
7645− ?: =(%unknown result.u.payload-live) [%| ["unit payload reachability needs unsupported inference" ~]]
7646− ?: =(%no result.u.payload-live) [%| ["unit present pattern is unreachable" ~]]
76476415 =/ extended=ienv [[u.binder [u.payload ~]] env]
76486416 =/ left=iresult
76496417 ?~ expected (infer-fragment val.x ?:(first-empty env extended) state.p.subject)
@@ -7658,700 +6426,10 @@
76586426 ?~ joined [%| ["unit branch results need unsupported inference" ~]]
76596427 [%& typ.p.left state.p.right(sub u.joined)]
76606428::
7661−:: Infer pieces in order, retaining their substitutions and pending tags.
7662−:: A bare decimal literal has no outside type constraint, so it takes its
7663−:: normal @ud default here. Other open numeric and aura variables wait for
7664−:: deferred constraints, which this fragment does not implement yet.
7665−++ infer-string-pieces
7666− |= [ps=(list piece) env=ienv state=istate]
6429+++ infer-fragment
6430+ |= [e=expr env=ienv state=istate]
76676431 ^- iresult
7668− ?~ ps [%& [%atom %t] state]
7669− ?: ?=(%text -.i.ps) $(ps t.ps)
7670− =/ item=iresult (infer-fragment p.i.ps env state)
7671− ?: ?=(%| -.item) item
7672− =/ t=itype (itype-normalize typ.p.item sub.state.p.item)
7673− ?: |(?=(%atom -.t) ?=(%any-atom -.t))
7674− $(ps t.ps, state state.p.item)
7675− ?: &(|(?=(%nvar -.t) ?=(%rnvar -.t)) ?=(%lit -.p.i.ps) =(%number form.lit.p.i.ps))
7676− $(ps t.ps, state state.p.item)
7677− ?: &(?=(%collection -.t) =(%list name.t) =(~[[%atom 'tD']] args.t))
7678− $(ps t.ps, state state.p.item)
7679− ?: &(?=(%avar -.t) (atom-var-from-cap id.t caps.state.p.item sub.state.p.item))
7680− [%| ["a generic atom in interpolation needs an aura" ~[[(span-of p.i.ps) "atom with a generic aura"]]]]
7681− ?: &(?=(%rvar -.t) (atom-var-from-cap id.t caps.state.p.item sub.state.p.item))
7682− [%| ["a generic atom in interpolation needs an aura" ~[[(span-of p.i.ps) "atom with a generic aura"]]]]
7683− ?: ?=(%cell -.t)
7684− [%| ["a cell in interpolation needs a printer" ~[[(span-of p.i.ps) "cell without a printer"]]]]
7685− [%| ["interpolation type needs unsupported inference" ~]]
7686−::
7687−:: Whole-case coverage for a known union. When a pattern may cover only
7688−:: part of a case, finite loobean refinements are tried below; other
7689−:: partial coverage stays unsupported until the general pattern matrix.
7690−+$ imatch ?(%full %none %unknown)
7691−++ union-pattern-items
7692− |= [ps=(list pattern) t=itype]
7693− ^- imatch
7694− ?~ ps %unknown
7695− ?~ t.ps (union-pattern i.ps t)
7696− =. t ?:(?=(%face -.t) body.t t)
7697− ?. ?=(%cell -.t)
7698− ?: |(?=(%atom -.t) ?=(%any-atom -.t) ?=(%flag -.t) ?=(%const -.t)) %none
7699− %unknown
7700− =/ a=imatch (union-pattern i.ps hed.t)
7701− =/ b=imatch $(ps t.ps, t tal.t)
7702− ?: |(=(%none a) =(%none b)) %none
7703− ?:(&(=(%full a) =(%full b)) %full %unknown)
7704−::
7705−++ union-pattern
7706− |= [p=pattern t=itype]
7707− ^- imatch
7708− =. t ?:(?=(%face -.t) body.t t)
7709− ?- -.p
7710− %any %full
7711− %bind %full
7712− %lit
7713− ?: ?=(%const -.t) ?:(=(val.literal.t val.lit.p) %full %none)
7714− ?: ?=(%cell -.t) %none
7715− ?: ?=(%flag -.t)
7716− ?:(|(=(0 val.lit.p) =(1 val.lit.p)) %unknown %none)
7717− %unknown
7718− %str ?:(?=(%cell -.t) %none %unknown)
7719− %cell (union-pattern-items items.p t)
7720− ==
7721−::
7722−++ union-pattern-has-bind
7723− |= p=pattern
7724− ^- ?
7725− ?: ?=(%bind -.p) &
7726− ?. ?=(%cell -.p) |
7727− (lien items.p union-pattern-has-bind)
7728−::
7729−++ union-pattern-bind-items
7730− |= [ps=(list pattern) t=itype env=ienv globals=(list term)]
7731− ^- (unit ienv)
7732− ?~ ps ~
7733− ?~ t.ps (union-pattern-bind i.ps t env globals)
7734− =. t ?:(?=(%face -.t) body.t t)
7735− ?. ?=(%cell -.t) ~
7736− =/ first=(unit ienv) (union-pattern-bind i.ps hed.t env globals)
7737− ?~ first ~
7738− $(ps t.ps, t tal.t, env u.first)
7739−::
7740−++ union-pattern-bind
7741− |= [p=pattern t=itype env=ienv globals=(list term)]
7742− ^- (unit ienv)
7743− =. t ?:(?=(%face -.t) body.t t)
7744− ?: ?=(%bind -.p)
7745− ?: |(=(name.p %proj) ?=(^ (ienv-lookup name.p env)) (lien globals |=(n=term =(n name.p)))) ~
7746− `[[name.p [t ~]] env]
7747− ?: ?=(%cell -.p) (union-pattern-bind-items items.p t env globals)
7748− `env
7749−::
7750−:: Split loobean fields into finite refinements for partial patterns.
7751−:: Keep original cases for binder types and preserve whole-case matching
7752−:: before trying refinements. Cap products at 64; unknown, empty or opaque
7753−:: shapes stay unsupported rather than implying complete pattern checking.
7754−+$ ifinite [origin=@ud base=itype part=itype]
7755−++ finite-product
7756− |= [hs=(list itype) ts=(list itype) out=(list itype)]
7757− ^- (list itype)
7758− ?~ hs out
7759− =/ rows=(list itype) (turn ts |=(t=itype [%cell i.hs t]))
7760− $(hs t.hs, out (weld rows out))
7761−::
7762−++ finite-type
7763− |= t=itype
7764− ^- (unit (list itype))
7765− ?- -.t
7766− %flag
7767− `~[[%const [%loobean %f 0 '%.y']] [%const [%loobean %f 1 '%.n']]]
7768− %face
7769− =/ body=(unit (list itype)) $(t body.t)
7770− ?~ body ~
7771− `(turn u.body |=(x=itype [%face name.t x]))
7772− %cell
7773− =/ hed=(unit (list itype)) $(t hed.t)
7774− ?~ hed ~
7775− =/ tal=(unit (list itype)) $(t tal.t)
7776− ?~ tal ~
7777− ?: (gth (mul (lent u.hed) (lent u.tal)) 64) ~
7778− `(finite-product u.hed u.tal ~)
7779− * `~[t]
7780− ==
7781−::
7782−++ finite-cases
7783− |= [xs=(list itype) out=(list ifinite) origin=@ud]
7784− ^- (unit (list ifinite))
7785− ?~ xs `out
7786− =/ parts=(unit (list itype)) (finite-type i.xs)
7787− ?~ parts ~
7788− ?: (gth (add (lent out) (lent u.parts)) 64) ~
7789− =/ rows=(list ifinite) (turn u.parts |=(t=itype [origin i.xs t]))
7790− $(xs t.xs, out (weld out rows), origin +(origin))
7791−::
7792−++ infer-known-union-whole
7793− |= [e=expr env=ienv subject=iresult]
7794− ^- (unit iresult)
7795− ?> ?=(%branch -.e)
7796− ?: ?=(%| -.subject) `subject
7797− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7798− ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
7799− =/ live=(unit (list itype)) (itype-live-cases cases.typ sub.state.p.subject caps.state.p.subject 4.096)
7800− ?~ live ~
7801− =/ cases=(list itype) u.live
7802− =/ remaining=(list itype) cases
7803− =/ arms=(list arm) arms.e
7804− =/ st=istate state.p.subject
7805− =/ answer=(unit itype) ~
7806− |-
7807− ?~ arms
7808− ?^ remaining
7809− `[%| ["missing union case {(show-itype i.remaining sub.st)}" ~]]
7810− ?~ answer `[%| ["empty union branch is not supported by partial inference" ~]]
7811− `[%& u.answer st]
7812− =/ a=arm i.arms
7813− ?: (lien remaining |=(c=itype =(%unknown (union-pattern pat.a c))))
7814− ~
7815− =/ matching=(list itype) (skim remaining |=(c=itype =(%full (union-pattern pat.a c))))
7816− ?~ matching
7817− ?: (lien cases |=(c=itype =(%full (union-pattern pat.a c))))
7818− `[%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7819− `[%| ["union pattern is not supported by partial inference" ~]]
7820− ?: &(?=(^ t.matching) (union-pattern-has-bind pat.a))
7821− `[%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7822− =/ bound=(unit ienv) (union-pattern-bind pat.a i.matching env globals.st)
7823− ?~ bound `[%| ["pattern binder shadows a name" ~]]
7824− =/ body=iresult (infer-fragment val.a u.bound st)
7825− ?: ?=(%| -.body) `body
7826− =/ result=itype (itype-normalize typ.p.body sub.state.p.body)
7827− =/ mismatch=? ?~(answer | !=((itype-normalize u.answer sub.state.p.body) result))
7828− ?: mismatch `[%| ["union branch result matching needs unsupported inference" ~]]
7829− $(arms t.arms, remaining (skim remaining |=(c=itype !=(%full (union-pattern pat.a c)))), st state.p.body, answer `result)
7830−::
7831−++ infer-known-union-context-whole
7832− |= [e=expr expected=itype env=ienv subject=iresult context=span]
7833− ^- (unit iresult)
7834− ?> ?=(%branch -.e)
7835− ?: ?=(%| -.subject) `subject
7836− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7837− ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
7838− =/ live=(unit (list itype)) (itype-live-cases cases.typ sub.state.p.subject caps.state.p.subject 4.096)
7839− ?~ live ~
7840− =/ cases=(list itype) u.live
7841− =/ remaining=(list itype) cases
7842− =/ arms=(list arm) arms.e
7843− =/ st=istate state.p.subject
7844− =/ answer=(unit itype) ~
7845− |-
7846− ?~ arms
7847− ?^ remaining
7848− `[%| ["missing union case {(show-itype i.remaining sub.st)}" ~]]
7849− ?~ answer `[%| ["empty union branch is not supported by partial inference" ~]]
7850− `[%& expected st]
7851− =/ a=arm i.arms
7852− ?: (lien remaining |=(c=itype =(%unknown (union-pattern pat.a c))))
7853− ~
7854− =/ matching=(list itype) (skim remaining |=(c=itype =(%full (union-pattern pat.a c))))
7855− ?~ matching
7856− ?: (lien cases |=(c=itype =(%full (union-pattern pat.a c))))
7857− `[%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7858− `[%| ["union pattern is not supported by partial inference" ~]]
7859− ?: &(?=(^ t.matching) (union-pattern-has-bind pat.a))
7860− `[%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7861− =/ bound=(unit ienv) (union-pattern-bind pat.a i.matching env globals.st)
7862− ?~ bound `[%| ["pattern binder shadows a name" ~]]
7863− =/ body=iresult (infer-call-context-arg val.a expected u.bound st context)
7864− ?: ?=(%| -.body) `body
7865− =/ fit=ifit (itype-fit typ.p.body expected sub.state.p.body next.state.p.body)
7866− ?: ?=(%unknown -.fit) `[%| ["union branch result constraint is not supported by partial inference" ~]]
7867− ?: ?=(%bad -.fit)
7868− =/ missing=(unit idiag) (missing-union-tag val.a expected sub.state.p.body context)
7869− ?^ missing `[%| u.missing]
7870− =/ nested=(unit idiag) (nested-missing-tag val.a typ.p.body expected sub.state.p.body next.state.p.body context)
7871− ?^ nested `[%| u.nested]
7872− `[%| ["union branch arm does not fit its expected type" ~[[context "expected type"] [(span-of val.a) "branch arm"]]]]
7873− ?: (itype-has-tag (itype-normalize expected sub.fit))
7874− `[%| ["union branch result needs context in partial inference" ~]]
7875− $(arms t.arms, remaining (skim remaining |=(c=itype !=(%full (union-pattern pat.a c)))), st state.p.body(sub sub.fit, next next.fit), answer `expected)
7876−::
7877−++ infer-known-union-finite
7878− |= [e=expr env=ienv subject=iresult expected=(unit [typ=itype context=span])]
7879− ^- iresult
7880− ?> ?=(%branch -.e)
7881− ?: ?=(%| -.subject) subject
7882− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7883− ?. ?=(%union -.typ) [%| ["branch is not supported by partial inference" ~]]
7884− =/ live=(unit (list itype)) (itype-live-cases cases.typ sub.state.p.subject caps.state.p.subject 4.096)
7885− ?~ live [%| ["union emptiness needs unsupported inference" ~]]
7886− =/ expanded=(unit (list ifinite)) (finite-cases u.live ~ 0)
7887− ?~ expanded [%| ["union pattern expansion needs unsupported inference" ~]]
7888− =/ cases=(list ifinite) u.expanded
7889− =/ remaining=(list ifinite) cases
7890− =/ arms=(list arm) arms.e
7891− =/ st=istate state.p.subject
7892− =/ answer=(unit itype) ~
7893− |-
7894− ?~ arms
7895− ?^ remaining
7896− [%| ["missing union case {(show-itype part.i.remaining sub.st)}" ~]]
7897− ?~ answer [%| ["empty union branch is not supported by partial inference" ~]]
7898− ?~ expected [%& u.answer st]
7899− [%& typ.u.expected st]
7900− =/ a=arm i.arms
7901− ?: (lien remaining |=(c=ifinite =(%unknown (union-pattern pat.a part.c))))
7902− [%| ["partial union pattern is not supported by partial inference" ~]]
7903− =/ matching=(list ifinite) (skim remaining |=(c=ifinite =(%full (union-pattern pat.a part.c))))
7904− ?~ matching
7905− ?: (lien cases |=(c=ifinite =(%full (union-pattern pat.a part.c))))
7906− [%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7907− [%| ["union pattern is not supported by partial inference" ~]]
7908− ?: &((union-pattern-has-bind pat.a) (lien t.matching |=(c=ifinite !=(origin.c origin.i.matching))))
7909− [%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7910− =/ bound=(unit ienv) (union-pattern-bind pat.a base.i.matching env globals.st)
7911− ?~ bound [%| ["pattern binder shadows a name" ~]]
7912− =/ body=iresult
7913− ?~ expected (infer-fragment val.a u.bound st)
7914− (infer-call-context-arg val.a typ.u.expected u.bound st context.u.expected)
7915− ?: ?=(%| -.body) body
7916− ?^ expected
7917− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
7918− ?: ?=(%unknown -.fit) [%| ["union branch result constraint is not supported by partial inference" ~]]
7919− ?: ?=(%bad -.fit)
7920− =/ missing=(unit idiag) (missing-union-tag val.a typ.u.expected sub.state.p.body context.u.expected)
7921− ?^ missing [%| u.missing]
7922− =/ nested=(unit idiag) (nested-missing-tag val.a typ.p.body typ.u.expected sub.state.p.body next.state.p.body context.u.expected)
7923− ?^ nested [%| u.nested]
7924− [%| ["union branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.a) "branch arm"]]]]
7925− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
7926− [%| ["union branch result needs context in partial inference" ~]]
7927− $(arms t.arms, remaining (skim remaining |=(c=ifinite !=(%full (union-pattern pat.a part.c)))), st state.p.body(sub sub.fit, next next.fit), answer `typ.u.expected)
7928− =/ result=itype (itype-normalize typ.p.body sub.state.p.body)
7929− =/ mismatch=? ?~(answer | !=((itype-normalize u.answer sub.state.p.body) result))
7930− ?: mismatch [%| ["union branch result matching needs unsupported inference" ~]]
7931− $(arms t.arms, remaining (skim remaining |=(c=ifinite !=(%full (union-pattern pat.a part.c)))), st state.p.body, answer `result)
7932−::
7933−:: Prove a one-arm record pattern covers a known, non-union subject.
7934−:: Variable or partial matches stay unsupported; binding uses the same
7935−:: scope and original payload types as the existing union matcher.
7936−++ single-structured-pattern
7937− |= e=expr
7938− ^- ?
7939− ?. ?=(%branch -.e) |
7940− ?~ arms.e |
7941− ?^ t.arms.e |
7942− =/ p=pattern pat.i.arms.e
7943− ?. ?=(%cell -.p) |
7944− !(levy items.p |=(x=pattern ?=(%bind -.x)))
7945−::
7946−++ infer-single-case-branch
7947− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
7948− ^- iresult
7949− ?> (single-structured-pattern e)
7950− ?> ?=(%branch -.e)
7951− ?> ?=(^ arms.e)
7952− =/ a=arm i.arms.e
7953− =/ subject=iresult (infer-fragment subject.e env state)
7954− ?: ?=(%| -.subject) subject
7955− =/ st=istate state.p.subject
7956− =/ typ=itype (itype-normalize typ.p.subject sub.st)
7957− ?: ?=(%union -.typ) [%| ["single-case pattern needs unsupported inference" ~]]
7958− ?. =(%full (union-pattern pat.a typ))
7959− [%| ["single-case pattern needs unsupported inference" ~]]
7960− =/ bound=(unit ienv) (union-pattern-bind pat.a typ env globals.st)
7961− ?~ bound [%| ["pattern binder shadows a name" ~]]
7962− ?~ expected (infer-fragment val.a u.bound st)
7963− =/ body=iresult (infer-call-context-arg val.a typ.u.expected u.bound st context.u.expected)
7964− ?: ?=(%| -.body) body
7965− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
7966− ?: ?=(%unknown -.fit) [%| ["single-case branch result constraint is not supported by partial inference" ~]]
7967− ?: ?=(%bad -.fit)
7968− =/ missing=(unit idiag) (missing-union-tag val.a typ.u.expected sub.state.p.body context.u.expected)
7969− ?^ missing [%| u.missing]
7970− =/ nested=(unit idiag) (nested-missing-tag val.a typ.p.body typ.u.expected sub.state.p.body next.state.p.body context.u.expected)
7971− ?^ nested [%| u.nested]
7972− [%| ["single-case branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.a) "branch arm"]]]]
7973− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
7974− [%| ["single-case branch result needs context in partial inference" ~]]
7975− [%& typ.u.expected state.p.body(sub sub.fit, next next.fit)]
7976−::
7977−:: This view is used only by pattern analysis, never exported or bound as
7978−:: the subject. Only null plus a two-binder/wildcard cell is supported; its
7979−:: tail keeps the original recursive type. Other patterns fail closed.
7980−++ jrec-match-view
7981− |= [e=expr subject=iresult]
7982− ^- iresult
7983− ?: ?=(%| -.subject) subject
7984− ?. ?=(%branch -.e) subject
7985− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7986− ?. ?=(%jrec -.typ) subject
7987− ?~ arms.e subject
7988− ?~ t.arms.e subject
7989− ?^ t.t.arms.e subject
7990− =/ x=pattern pat.i.arms.e
7991− =/ y=pattern pat.i.t.arms.e
7992− =/ empty=? &(?=(%lit -.x) =(%null form.lit.x))
7993− =/ full=pattern ?:(empty y x)
7994− ?. |(empty &(?=(%lit -.y) =(%null form.lit.y))) subject
7995− ?. ?=(%cell -.full) subject
7996− ?~ items.full subject
7997− ?~ t.items.full subject
7998− ?^ t.t.items.full subject
7999− ?. |(?=(%bind -.i.items.full) ?=(%any -.i.items.full)) subject
8000− ?. |(?=(%bind -.i.t.items.full) ?=(%any -.i.t.items.full)) subject
8001− ?: =(0 jrec-fuel.state.p.subject)
8002− [%| ["recursive mold unfolding needs unsupported inference" ~]]
8003− =/ nil=itype [%const [%null %n 0 '~']]
8004− =/ cell=itype [%cell [%face head.typ [%atom aura.typ]] [%face tail.typ typ]]
8005− [%& [%union ~[nil cell] ~ ~ ~] state.p.subject(jrec-fuel (dec jrec-fuel.state.p.subject))]
8006−::
8007−:: A bounded source-proven tree match permits flat tag patterns and
8008−:: nonbinding catch-alls. Whole-case binders cannot consume the temporary
8009−:: structural view. Pattern count and field arity are checked first.
8010−++ grec-simple-pattern
8011− |= [pat=pattern view=itype]
8012− ^- ?
8013− ?. ?=(%cell -.pat) |
8014− ?~ items.pat |
8015− =/ first=pattern i.items.pat
8016− ?. ?=(%lit -.first) |
8017− ?. =(%term form.lit.first) |
8018− =/ chosen=(unit itype) (contextual-tagged-case view val.lit.first ~)
8019− ?~ chosen |
8020− ?> ?=(%cell -.u.chosen)
8021− =/ rest=(list pattern) t.items.pat
8022− =/ arity=? ?:(?=(%cell -.tal.u.chosen) ?=([* [* ~]] rest) ?=([* ~] rest))
8023− ?. arity |
8024− (levy rest |=(p=pattern |(?=(%bind -.p) ?=(%any -.p))))
8025−::
8026−:: A catch-all with no binder is safe even when it covers both cases.
8027−:: A bound whole case still declines to avoid exporting the analysis view.
8028−++ grec-patterns-eligible
8029− |= [arms=(list arm) view=itype left=@ud]
8030− ^- ?
8031− ?~ arms &
8032− ?: =(0 left) |
8033− =/ pat=pattern pat.i.arms
8034− ?. |(?=(%any -.pat) (grec-simple-pattern pat view)) |
8035− $(arms t.arms, left (dec left))
8036−++ grec-match-view
8037− |= [e=expr subject=iresult]
8038− ^- iresult
8039− ?: ?=(%| -.subject) subject
8040− ?. ?=(%branch -.e) subject
8041− ?. (grec-direct-context typ.p.subject sub.state.p.subject) subject
8042− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
8043− ?. ?=(%grec -.typ) subject
8044− ?~ arms.e subject
8045− =/ view=(unit [view=itype left=@ud]) (grec-unfold-view typ jrec-fuel.state.p.subject)
8046− ?~ view [%| ["recursive mold unfolding needs unsupported inference" ~]]
8047− ?. (grec-patterns-eligible arms.e view.u.view 128) subject
8048− [%& view.u.view state.p.subject(jrec-fuel left.u.view)]
8049−::
8050−:: A single-arm diagnostic only probes a direct, source-typed in-scope wing;
8051−:: other subjects retain the prior single-pattern inference path.
8052−++ grec-single-wing-subject
8053− |= [e=expr env=ienv state=istate]
8054− ^- (unit iresult)
8055− ?. ?=(%wing -.e) ~
8056− ?. ?=([@ ~] names.e) ~
8057− =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
8058− ?~ scheme ~
8059− ?. (grec-direct-context typ.u.scheme sub.state) ~
8060− `(infer-fragment e env state)
8061−::
8062−++ infer-known-union-branch-subject
8063− |= [e=expr env=ienv subject=iresult]
8064− ^- iresult
8065− =. subject (grec-match-view e subject)
8066− =. subject (jrec-match-view e subject)
8067− =/ whole=(unit iresult) (infer-known-union-whole e env subject)
8068− ?~ whole (infer-known-union-finite e env subject ~)
8069− u.whole
8070−::
8071−++ infer-known-union-branch
8072− |= [e=expr env=ienv state=istate]
8073− ^- iresult
8074− ?> ?=(%branch -.e)
8075− (infer-known-union-branch-subject e env (infer-fragment subject.e env state))
8076−::
8077−++ infer-known-union-context-subject
8078− |= [e=expr expected=itype env=ienv subject=iresult context=span]
8079− ^- iresult
8080− =. subject (grec-match-view e subject)
8081− =. subject (jrec-match-view e subject)
8082− =/ whole=(unit iresult) (infer-known-union-context-whole e expected env subject context)
8083− ?~ whole (infer-known-union-finite e env subject `[expected context])
8084− u.whole
8085−::
8086−:: Limit speculative subject inference to wings and shallow calls;
8087−:: grouping is peeled linearly and cannot introduce a nested branch.
8088−++ simple-union-subject-arg
8089− |= e=expr
8090− ^- ?
8091− ?- -.e
8092− %wing &
8093− %lit &
8094− %str !(lien pieces.e |=(p=piece ?=(%expr -.p)))
8095− * |
8096− ==
8097−::
8098−++ safe-union-subject
8099− |= e=expr
8100− ^- ?
8101− ?: ?=(%group -.e) $(e inner.e)
8102− ?: ?=(%wing -.e) &
8103− ?. ?=(%call -.e) |
8104− ?. ?=(%wing -.head.e) |
8105− (levy args.e simple-union-subject-arg)
8106−::
8107−++ duplicate-loobean-arms
8108− |= e=expr
8109− ^- ?
8110− ?. ?=(%branch -.e) |
8111− ?~ arms.e |
8112− ?~ t.arms.e |
8113− ?^ t.t.arms.e |
8114− =/ x=pattern pat.i.arms.e
8115− =/ y=pattern pat.i.t.arms.e
8116− ?. &(?=(%lit -.x) ?=(%lit -.y)) |
8117− ?. &(=(%loobean form.lit.x) =(%loobean form.lit.y)) |
8118− =(val.lit.x val.lit.y)
8119−::
8120−++ union-subject-call
8121− |= e=expr
8122− ^- ?
8123− ?: ?=(%group -.e) $(e inner.e)
8124− ?=(%call -.e)
8125−::
8126−++ known-union-subject
8127− |= [e=expr env=ienv state=istate]
8128− ^- (unit iresult)
8129− ?. (safe-union-subject e) ~
8130− =/ subject=iresult (infer-fragment e env state)
8131− ?: ?=(%| -.subject) ?:((union-subject-call e) `subject ~)
8132− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
8133− ?. |(?=(%union -.typ) ?=(%jrec -.typ) &(?=(%grec -.typ) (grec-direct-context typ.p.subject sub.state.p.subject))) ~
8134− `subject
8135−::
8136−:: A direct wing with an already-known union may skip genuinely empty cases
8137−:: when checking a one-arm match. Other subjects keep their existing path.
8138−:: A directly known canonical list of an empty element contains only null.
8139−:: This helper never refines an opaque or variable-bound subject.
8140−++ empty-list-null-branch
8141− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
8142− ^- (unit iresult)
8143− ?. ?=(%branch -.e) ~
8144− ?~ arms.e ~
8145− ?^ t.arms.e ~
8146− ?. (unit-empty-pattern pat.i.arms.e) ~
8147− ?. ?=(%wing -.subject.e) ~
8148− ?. ?=([@ ~] names.subject.e) ~
8149− =/ scheme=(unit ischeme) (ienv-lookup i.names.subject.e env)
8150− ?~ scheme ~
8151− ?. ?=(%collection -.typ.u.scheme) ~
8152− ?. =(%list name.typ.u.scheme) ~
8153− ?~ prelude.state ~
8154− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb) ~
8155− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude.state)
8156− ?~ standard ~
8157− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]]) ~
8158− =/ subject=iresult (infer-fragment subject.e env state)
8159− ?: ?=(%| -.subject) ~
8160− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
8161− ?. ?=(%collection -.typ) ~
8162− ?. =(%list name.typ) ~
8163− ?~ args.typ ~
8164− ?^ t.args.typ ~
8165− =/ proof=(unit [empty=? left=@ud]) (itype-empty-proof i.args.typ sub.state.p.subject 256)
8166− ?~ proof ~
8167− ?. empty.u.proof ~
8168− ?~ expected `(infer-fragment val.i.arms.e env state.p.subject)
8169− =/ body=iresult (infer-call-context-arg val.i.arms.e typ.u.expected env state.p.subject context.u.expected)
8170− ?: ?=(%| -.body) `body
8171− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
8172− ?: ?=(%unknown -.fit) `[%| ["single-case branch result constraint is not supported by partial inference" ~]]
8173− ?: ?=(%bad -.fit) `[%| ["single-case branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.i.arms.e) "branch arm"]]]]
8174− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
8175− `[%| ["single-case branch result needs context in partial inference" ~]]
8176− `[%& typ.p.body state.p.body(sub sub.fit, next next.fit)]
8177−::
8178−++ known-empty-union-wing
8179− |= [e=expr env=ienv state=istate]
8180− ^- (unit iresult)
8181− ?. ?=(%wing -.e) ~
8182− ?. ?=([@ ~] names.e) ~
8183− =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
8184− ?~ scheme ~
8185− ?. (contextual-direct-union typ.u.scheme) ~
8186− =/ subject=iresult (infer-fragment e env state)
8187− ?: ?=(%| -.subject) ~
8188− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
8189− ?. ?=(%union -.typ) ~
8190− =/ live=(unit (list itype)) (itype-live-cases cases.typ sub.state.p.subject caps.state.p.subject 4.096)
8191− ?~ live ~
8192− ?: =(u.live cases.typ) ~
8193− `subject
8194−::
8195−:: Infer changes only against a fully known record spine. Retain the
8196−:: target type; unknown spines and repeated edits remain unsupported.
8197−++ change-spine-known
8198− |= [t=itype sub=isub]
8199− ^- ?
8200− =. t (itype-walk t sub)
8201− ?: ?=(%face -.t) &
8202− ?. ?=(%cell -.t) |
8203− =/ first=itype (itype-walk hed.t sub)
8204− ?. ?=(%face -.first) |
8205− $(t tal.t)
8206−::
8207−++ infer-change-edits
8208− |= [edits=(list edit) target=itype env=ienv state=istate seen=(list term)]
8209− ^- iresult
8210− ?~ edits [%& target state]
8211− =/ entry=edit i.edits
8212− ?: (lien seen |=(name=term =(name name.entry)))
8213− [%| ["repeated change fields are not supported by partial inference" ~]]
8214− ?. (change-spine-known target sub.state)
8215− [%| ["change target needs a known record in partial inference" ~]]
8216− =/ found=(list itype) (record-fields-named name.entry target sub.state)
8217− ?~ found
8218− [%| ["record has no field `{(trip name.entry)}`" ~[[at.entry "unknown field"]]]]
8219− ?^ t.found [%| ["change field is ambiguous in partial inference" ~]]
8220− =/ expected=itype i.found
8221− =/ value=iresult (infer-call-context-arg val.entry expected env state at.entry)
8222− ?: ?=(%| -.value) value
8223− =/ fit=ifit (itype-fit typ.p.value expected sub.state.p.value next.state.p.value)
8224− ?: ?=(%unknown -.fit) [%| ["change field constraint is not supported by partial inference" ~]]
8225− ?: ?=(%bad -.fit)
8226− [%| ["change field and replacement do not unify" ~[[at.entry (site-type-note "expected replacement" expected sub.state.p.value)] [(span-of val.entry) (site-type-note "replacement" typ.p.value sub.state.p.value)]]]]
8227− $(edits t.edits, state state.p.value(sub sub.fit, next next.fit), seen [name.entry seen])
8228−::
8229−:: Backtick constructs the canonical prelude unit, after checking its
8230−:: prepared template has the standard null and [~ u=A] cases.
8231−++ standard-unit-template
8232− |= [template=ischeme at=path]
8233− ^- ?
8234− ?. =(at /lib/jibb/prelude/jibb) |
8235− ?~ vars.template |
8236− ?^ t.vars.template |
8237− =/ v=@ud i.vars.template
8238− =/ nil=itype [%const [%null %n 0 '~']]
8239− =/ expected=itype
8240− [%union ~[nil [%cell nil [%face %u [%var v]]]] `[at %unit] `%unit ~[[%var v]]]
8241− =(typ.template expected)
8242−::
8243−:: A named missing-case diagnostic needs more than a failed fit: a case
8244−:: with that tag but the wrong payload is not a missing case. Unknown
8245−:: shapes and atom types that accept terms keep the proof conservative.
8246−+$ itag-presence ?(%yes %no %maybe)
8247−++ tag-presence-cases
8248− |= [cases=(list itype) value=@ sub=isub]
8249− ^- itag-presence
8250− ?~ cases %no
8251− =/ first=itag-presence (tag-presence i.cases value sub)
8252− ?: =(%yes first) %yes
8253− =/ rest=itag-presence $(cases t.cases)
8254− ?: =(%yes rest) %yes
8255− ?: |(=(%maybe first) =(%maybe rest)) %maybe
8256− %no
8257−::
8258−++ tag-presence
8259− |= [t=itype value=@ sub=isub]
8260− ^- itag-presence
8261− =. t (itype-walk t sub)
8262− ?- -.t
8263− %const ?:(=(value val.literal.t) %yes %no)
8264− %flag ?:(|(=(value 0) =(value 1)) %yes %no)
8265− %atom ?:(|(=(%tas aura.t) =(%ta aura.t)) %maybe %no)
8266− %face $(t body.t)
8267− %cell
8268− =/ first=itag-presence $(t hed.t)
8269− ?: =(%yes first) %yes
8270− =/ rest=itag-presence $(t tal.t)
8271− ?: =(%yes rest) %yes
8272− ?: |(=(%maybe first) =(%maybe rest)) %maybe
8273− %no
8274− %union (tag-presence-cases cases.t value sub)
8275− * %maybe
8276− ==
8277−::
8278−++ missing-union-tag
8279− |= [e=expr expected=itype sub=isub context=span]
8280− ^- (unit idiag)
8281− ?. ?=(%lit -.e) ~
8282− ?. =(%term form.lit.e) ~
8283− =. expected (itype-walk expected sub)
8284− |-
8285− ?: ?=(%face -.expected) $(expected (itype-walk body.expected sub))
8286− ?. ?=(%union -.expected) ~
8287− ?. =(%no (tag-presence-cases cases.expected val.lit.e sub)) ~
8288− =/ label=tape
8289− ?~ label.expected "union {(show-itype expected sub)}"
8290− (show-itype expected sub)
8291− `["{label} has no case `{(trip txt.lit.e)}`" ~[[context "expected union"] [(span-of e) "tag"]]]
8292−::
8293−:: Locate a missing tag inside a syntactic tuple only by replaying the
8294−:: directional fit in source order. Uncertain or earlier failures stop
8295−:: the walk, preserving the generic diagnostic rather than guessing.
8296−++ nested-missing-tag
8297− |= [e=expr actual=itype expected=itype sub=isub next=@ud context=span]
8298− ^- (unit idiag)
8299− =/ original=[left=itype right=itype] [actual expected]
8300− ?: |(?=(%var -.left.original) ?=(%avar -.left.original) ?=(%rvar -.left.original) |(?=(%nvar -.left.original) ?=(%rnvar -.left.original)) ?=(%var -.right.original) ?=(%avar -.right.original) ?=(%rvar -.right.original) |(?=(%nvar -.right.original) ?=(%rnvar -.right.original))) ~
8301− =/ fit=ifit (itype-fit actual expected sub next)
8302− ?. ?=(%bad -.fit) ~
8303− =. actual (itype-walk actual sub)
8304− =. expected (itype-walk expected sub)
8305− ?: &(?=(%face -.actual) ?=(%face -.expected))
8306− ?. =(name.actual name.expected) ~
8307− $(actual body.actual, expected body.expected)
8308− ?: ?=(%face -.actual) $(actual body.actual)
8309− ?: ?=(%face -.expected) $(expected body.expected)
8310− =/ direct=(unit idiag) (missing-union-tag e expected sub context)
8311− ?^ direct direct
8312− ?. ?=(%tuple -.e) ~
8313− (nested-missing-items items.e actual expected sub next context)
8314−::
8315−++ nested-missing-items
8316− |= [items=(list item) actual=itype expected=itype sub=isub next=@ud context=span]
8317− ^- (unit idiag)
8318− ?~ items ~
8319− ?~ t.items (nested-missing-tag val.i.items actual expected sub next context)
8320− =/ original=[left=itype right=itype] [actual expected]
8321− ?: |(?=(%var -.left.original) ?=(%avar -.left.original) ?=(%rvar -.left.original) |(?=(%nvar -.left.original) ?=(%rnvar -.left.original)) ?=(%var -.right.original) ?=(%avar -.right.original) ?=(%rvar -.right.original) |(?=(%nvar -.right.original) ?=(%rnvar -.right.original))) ~
8322− =. actual (itype-walk actual sub)
8323− =. expected (itype-walk expected sub)
8324− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8325− =/ first=ifit (itype-fit hed.actual hed.expected sub next)
8326− ?: ?=(%bad -.first)
8327− (nested-missing-tag val.i.items hed.actual hed.expected sub next context)
8328− ?. ?=(%ok -.first) ~
8329− $(items t.items, actual tal.actual, expected tal.expected, sub sub.first, next next.first)
8330−::
8331−:: A term-headed pair is the same noun as a two-item cell. Preserve the
8332−:: whole pair span for the synthetic head and the value's own span for
8333−:: the payload; unresolved term constraints follow ordinary cell inference.
8334−++ pair-as-cell
8335− |= e=expr
8336− ^- expr
8337− ?> ?=(%pair -.e)
8338− =/ head=expr [%lit at.e [%term %tas tag.e (crip ['%' (trip tag.e)])]]
8339− [%tuple at.e ~[[at.e ~ head] [(span-of val.e) ~ val.e]]]
8340−::
8341−:: A segment costs one shared step; dynamic segments are not handled yet.
8342−++ qath-static-fuel
8343− |= [segs=(list qseg) fuel=@ud]
8344− ^- (unit @ud)
8345− ?~ segs `fuel
8346− ?: =(0 fuel) ~
8347− ?. ?=(%knot -.i.segs) ~
8348− $(segs t.segs, fuel (dec fuel))
8349−::
8350−++ infer-fragment
8351− |= [e=expr env=ienv state=istate]
8352− ^- iresult
8353− ?- -.e
8354− %pair $(e (pair-as-cell e))
6432+ ?- -.e
83556433 %lit
83566434 ?- form.lit.e
83576435 %number ?: =(%ud aura.lit.e)
@@ -8365,45 +6443,10 @@
83656443 %term [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
83666444 %null [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
83676445 ==
8368− %unit
8369− ?~ prelude.state [%| ["unit construction needs the standard prelude in partial inference" ~]]
8370− =/ standard=(unit ischeme) (find-jibb-mold %unit u.prelude.state)
8371− ?~ standard [%| ["unit construction needs the standard prelude in partial inference" ~]]
8372− ?. (standard-unit-template u.standard at.u.prelude.state)
8373− [%| ["unit construction needs the standard prelude in partial inference" ~]]
8374− =/ value=iresult $(e val.e)
8375− ?: ?=(%| -.value) value
8376− =/ result=(unit itype) (template-apply u.standard ~[typ.p.value])
8377− ?~ result [%| ["unit construction is not supported by partial inference" ~]]
8378− [%& u.result state.p.value]
8379− %list
8380− ?~ prelude.state [%| ["list literal needs the standard prelude in partial inference" ~]]
8381− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
8382− [%| ["list literal needs the standard prelude in partial inference" ~]]
8383− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude.state)
8384− ?~ standard [%| ["list literal needs the standard prelude in partial inference" ~]]
8385− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]])
8386− [%| ["list literal needs the standard prelude in partial inference" ~]]
8387− =/ element=itype [%var next.state]
8388− =/ result=iresult (infer-open-list-items items.e element env state(next +(next.state)) at.e)
8389− ?: ?=(%| -.result) result
8390− [%& [%collection %list ~[element]] state.p.result]
8391− %str (infer-string-pieces pieces.e env state)
8392− %qath
8393− ?~ prelude.state [%| ["application path needs the standard prelude in partial inference" ~]]
8394− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
8395− [%| ["application path needs the standard prelude in partial inference" ~]]
8396− =/ standard=(unit ischeme) (find-jibb-mold %qath u.prelude.state)
8397− ?~ standard [%| ["application path needs the standard prelude in partial inference" ~]]
8398− ?. ?=(~ vars.u.standard) [%| ["application path mold needs unsupported inference" ~]]
8399− =/ typ=itype typ.u.standard
8400− ?. ?=(%jrec -.typ) [%| ["application path mold needs unsupported inference" ~]]
8401− ?. &(=(at.typ /lib/jibb/internal/jibb) =(%qath name.typ) =(%i head.typ) =(%ta aura.typ) =(%t tail.typ))
8402− [%| ["application path mold needs unsupported inference" ~]]
8403− ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
8404− =/ remain=(unit @ud) (qath-static-fuel segs.e (dec jrec-fuel.state))
8405− ?~ remain [%| ["application path segments need unsupported inference" ~]]
8406− [%& typ state(jrec-fuel u.remain)]
6446+ %str
6447+ =/ interpolated=? (lien pieces.e |=(p=piece ?=(%expr -.p)))
6448+ ?: interpolated [%| ["interpolation is not supported by partial inference" ~]]
6449+ [%& [%atom %t] state]
84076450 %wing
84086451 ?~ names.e [%| ["empty wing" ~]]
84096452 ?^ t.names.e
@@ -8412,7 +6455,7 @@
84126455 ?~ iface (infer-field-wing names.e env state)
84136456 =/ member=(unit ischeme) (ienv-lookup i.names.e values.u.iface)
84146457 ?~ member [%| ["module member is not available to partial inference" ~]]
8415− =. typ.u.member (itype-in-import typ.u.member u.iface i.t.names.e prelude.state)
6458+ =. typ.u.member (itype-in-import typ.u.member u.iface i.t.names.e)
84166459 =/ instance=[typ=itype state=istate] (instantiate-scheme u.member state)
84176460 [%& typ.instance state.instance]
84186461 =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
@@ -8425,20 +6468,12 @@
84256468 =/ instance=[typ=itype state=istate] (instantiate-scheme u.scheme state)
84266469 [%& typ.instance state.instance]
84276470 %group $(e inner.e)
8428− %change
8429− ?~ edits.e [%| ["a change takes at least one field" ~[[at.e "empty change"]]]]
8430− =/ target=iresult $(e [%wing at.e target.e])
8431− ?: ?=(%| -.target) target
8432− (infer-change-edits edits.e typ.p.target env state.p.target ~)
84336471 %ctor [%& [%tag next.state tag.e &] state(next +(next.state), tags [[next.state tag.e] tags.state])]
84346472 %trace
84356473 =/ traced=iresult $(e val.e)
84366474 ?: ?=(%| -.traced) traced
84376475 $(e then.e, state state.p.traced)
8438− %tuple
8439− ?: &(?=(^ defer.state) ?=(^ prelude.state))
8440− (dg-infer-tuple-items items.e env state)
8441− (infer-simple-items items.e env state)
6476+ %tuple (infer-simple-items items.e env state)
84426477 %body
84436478 ?~ defs.e $(e final.e)
84446479 =/ local-names=(list term) (global-value-names defs.e)
@@ -8449,9 +6484,6 @@
84496484 [%| ["local molds shadow a name" ~]]
84506485 =/ local-state=istate
84516486 state(globals (weld local-names globals.state), molds (weld local-molds molds.state))
8452− =/ mold-hole=(unit span) (simple-local-mold-hole defs.e)
8453− ?^ mold-hole
8454− [%| ["type hole needs a determined type" ~[[u.mold-hole "unresolved type hole"]]]]
84556487 ?. (local-molds-supported local-molds local-state)
84566488 [%| ["local molds need unsupported inference" ~]]
84576489 =/ values=(list def) (local-value-defs defs.e)
@@ -8461,38 +6493,21 @@
84616493 ?: ?=(%| -.result) result
84626494 [%& typ.p.result state.p.result(globals globals.state, molds molds.state)]
84636495 %branch
8464− ?^ defer.state (dg-boolean-branch e env state)
84656496 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
8466− ?~ t.arms.e
8467− =/ empty-list=(unit iresult) (empty-list-null-branch e env state ~)
8468− ?^ empty-list u.empty-list
8469− =/ empty-union=(unit iresult) (known-empty-union-wing subject.e env state)
8470− ?^ empty-union (infer-known-union-branch-subject e env u.empty-union)
8471− =/ single=(unit iresult) (grec-single-wing-subject subject.e env state)
8472− ?^ single (infer-known-union-branch-subject e env u.single)
8473− ?: (single-structured-pattern e) (infer-single-case-branch e env state ~)
8474− (infer-cell-branch e env state ~)
8475− ?^ t.t.arms.e (infer-known-union-branch e env state)
8476− =/ known=(unit iresult) (known-union-subject subject.e env state)
8477− ?: &(?=(^ known) ?=(%| -.u.known) !(duplicate-loobean-arms e)) u.known
8478− ?: &(?=(^ known) ?=(%& -.u.known) ?=(~ (unit-union-payload (itype-normalize typ.p.u.known sub.state.p.u.known))))
8479− (infer-known-union-branch-subject e env u.known)
6497+ ?~ t.arms.e (infer-cell-branch e env state)
6498+ ?^ t.t.arms.e [%| ["branch is not supported by partial inference" ~]]
84806499 =/ x=arm i.arms.e
84816500 =/ y=arm i.t.arms.e
84826501 ?: |((unit-empty-pattern pat.x) (unit-empty-pattern pat.y))
84836502 (infer-unit-branch e env state ~)
8484− ?. ?=(%lit -.pat.x) (infer-known-union-branch e env state)
8485− ?. ?=(%lit -.pat.y) (infer-known-union-branch e env state)
6503+ ?. ?=(%lit -.pat.x) [%| ["branch pattern is not supported by partial inference" ~]]
6504+ ?. ?=(%lit -.pat.y) [%| ["branch pattern is not supported by partial inference" ~]]
84866505 ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y))
8487− (infer-known-union-branch e env state)
8488− ?: &(?=(^ known) ?=(%& -.u.known)) (infer-known-union-branch-subject e env u.known)
6506+ [%| ["branch pattern is not supported by partial inference" ~]]
84896507 ?: =(val.lit.pat.x val.lit.pat.y)
84906508 [%| ["branch does not cover both loobeans" ~]]
84916509 =/ subject=iresult $(e subject.e)
84926510 ?: ?=(%| -.subject) subject
8493− =/ subject-type=itype (itype-normalize typ.p.subject sub.state.p.subject)
8494− ?: ?=(%union -.subject-type)
8495− [%| ["union-pattern branch subject is not supported by partial inference" ~]]
84966511 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
84976512 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
84986513 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
@@ -8519,52 +6534,74 @@
85196534 [%& typ.p.left state.p.right(sub u.joined)]
85206535 %cast
85216536 =/ target=(unit [typ=itype state=istate]) (infer-simple-shape shape.e state)
8522− ?~ target
8523− =/ diag=(unit idiag) (nested-import-invalid shape.e state)
8524− ?^ diag [%| u.diag]
8525− [%| ["cast mold is not supported by partial inference" ~]]
6537+ ?~ target [%| ["cast mold is not supported by partial inference" ~]]
85266538 =/ value=iresult
8527− (infer-call-context-arg val.e typ.u.target env state.u.target at.shape.e)
6539+ ?: &(?=(%union -.typ.u.target) (context-union-branch val.e))
6540+ (infer-union-context val.e typ.u.target env state.u.target at.shape.e)
6541+ ?: &(?=(%collection -.typ.u.target) =(%list name.typ.u.target) (context-union-branch val.e))
6542+ (infer-union-context val.e typ.u.target env state.u.target at.shape.e)
6543+ ?: &(?=(%collection -.typ.u.target) =(%list name.typ.u.target) (context-list-expression val.e))
6544+ (infer-list-context val.e typ.u.target env state.u.target at.shape.e)
6545+ $(e val.e, state state.u.target)
85286546 ?: ?=(%| -.value) value
8529− =/ shape=(unit [source=iwfields target=iwfields])
8530− (width-shape typ.p.value typ.u.target sub.state.p.value)
8531− ?^ shape [%| ["record width constraint needs unsupported inference" ~]]
85326547 =/ fit=ifit (itype-fit typ.p.value typ.u.target sub.state.p.value next.state.p.value)
85336548 ?: ?=(%unknown -.fit) [%| ["cast constraint is not supported by partial inference" ~]]
85346549 ?: ?=(%bad -.fit)
8535− =/ missing=(unit idiag) (missing-union-tag val.e typ.u.target sub.state.p.value at.shape.e)
8536− ?^ missing [%| u.missing]
8537− =/ nested=(unit idiag) (nested-missing-tag val.e typ.p.value typ.u.target sub.state.p.value next.state.p.value at.shape.e)
8538− ?^ nested [%| u.nested]
85396550 [%| ["cast mold and expression type do not unify" ~[[at.shape.e (site-type-note "cast mold" typ.u.target sub.state.p.value)] [(span-of val.e) (site-type-note "expression" typ.p.value sub.state.p.value)]]]]
8540− ?: &(?=(^ defer.state.p.value) !(dg-stable-fit typ.p.value typ.u.target sub.fit))
8541− [%| ["deferred cast fit needs stable inference" ~]]
85426551 =/ merged=itype (itype-merge-faces typ.p.value typ.u.target sub.fit)
85436552 [%& merged state.p.value(sub sub.fit, next next.fit)]
85446553 %crash [%& [%var next.state] state(next +(next.state))]
85456554 %gate
85466555 =/ sam=isample-result (infer-sample sample.e env state)
8547− ?: ?=(%| -.sam)
8548− =/ diag=(unit idiag) (sample-import-invalid sample.e env state)
8549− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
8550− [%| [p.sam ~]]
6556+ ?: ?=(%| -.sam) [%| [p.sam ~]]
85516557 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
85526558 ?: ?=(%| -.body) body
85536559 [%& [%fn typ.p.sam typ.p.body] state.p.body]
85546560 %gate-wide
85556561 =/ sam=isample-result (infer-sample sample.e env state)
8556− ?: ?=(%| -.sam)
8557− =/ diag=(unit idiag) (sample-import-invalid sample.e env state)
8558− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
8559− [%| [p.sam ~]]
6562+ ?: ?=(%| -.sam) [%| [p.sam ~]]
85606563 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
85616564 ?: ?=(%| -.body) body
85626565 [%& [%fn typ.p.sam typ.p.body] state.p.body]
85636566 %call
85646567 ?~ args.e [%| ["call has no argument" ~]]
8565− ?: (explicit-proj-call e env state)
8566− [%| ["proj needs an expected record type" ~]]
8567− (infer-call-with-head e env state (infer-fragment head.e env state))
6568+ =/ head=iresult $(e head.e)
6569+ ?: ?=(%| -.head) head
6570+ =/ head-type=itype (itype-walk typ.p.head sub.state.p.head)
6571+ =/ arg=iresult
6572+ ?^ t.args.e
6573+ ?: ?=(%fn -.head-type)
6574+ (infer-call-context-args args.e sample.head-type env state.p.head (span-of head.e))
6575+ (infer-simple-items (turn args.e |=(a=expr [(span-of a) ~ a])) env state.p.head)
6576+ ?: &(?=(%fn -.head-type) ?=(%union -.sample.head-type) (context-union-branch i.args.e))
6577+ (infer-union-context i.args.e sample.head-type env state.p.head (span-of head.e))
6578+ ?: &(?=(%fn -.head-type) ?=(%collection -.sample.head-type) =(%list name.sample.head-type) (context-union-branch i.args.e))
6579+ (infer-union-context i.args.e sample.head-type env state.p.head (span-of head.e))
6580+ ?: &(?=(%fn -.head-type) ?=(%collection -.sample.head-type) =(%list name.sample.head-type) (context-list-expression i.args.e))
6581+ (infer-list-context i.args.e sample.head-type env state.p.head (span-of head.e))
6582+ $(e i.args.e, state state.p.head)
6583+ ?: ?=(%| -.arg) arg
6584+ =/ st=istate state.p.arg
6585+ =/ ht=itype (itype-walk typ.p.head sub.st)
6586+ ?: ?=(%fn -.ht)
6587+ =/ fit=ifit (itype-fit typ.p.arg sample.ht sub.st next.st)
6588+ ?: ?=(%unknown -.fit) [%| ["call constraint is not supported by partial inference" ~]]
6589+ ?: ?=(%bad -.fit)
6590+ =/ bad=(unit [at=span typ=itype])
6591+ ?~(t.args.e ~ (call-error-site args.e typ.p.arg sample.ht sub.st next.st))
6592+ =/ whole-args=span
6593+ ?~(t.args.e (span-of i.args.e) [beg:(span-of i.args.e) end:(span-of (rear args.e))])
6594+ =/ arg-at=span ?~(bad whole-args at.u.bad)
6595+ =/ arg-type=itype ?~(bad typ.p.arg typ.u.bad)
6596+ [%| ["call's sample and argument types do not unify" ~[[(span-of head.e) (site-type-note "called gate" ht sub.st)] [arg-at (site-type-note "argument" arg-type sub.st)]]]]
6597+ ?: &((itype-has-face typ.p.arg sub.fit) (itype-face-asym typ.p.arg sample.ht sub.fit) (itype-output-may-be-cell product.ht sub.fit))
6598+ [%| ["call result face propagation is not supported by partial inference" ~]]
6599+ [%& product.ht st(sub sub.fit, next next.fit)]
6600+ =/ result=itype [%var next.st]
6601+ =/ uni=(unit isub) (itype-unify ht [%fn typ.p.arg result] sub.st)
6602+ ?~ uni
6603+ [%| ["call's sample and argument types do not unify" ~[[(span-of head.e) (site-type-note "called gate" ht sub.st)] [(span-of i.args.e) (site-type-note "argument" typ.p.arg sub.st)]]]]
6604+ [%& result st(next +(next.st), sub u.uni)]
85686605 * [%| ["expression is not supported by partial inference" ~]]
85696606 ==
85706607::
@@ -8572,322 +6609,12 @@
85726609:: failed. If an intermediate fit is uncertain, retain the whole argument
85736610:: span rather than assigning blame to a particular argument.
85746611::
8575−:: Check a call using the head already inferred in this state. Keeping
8576−:: this shared avoids evaluating or instantiating a contextual head twice.
8577−++ width-has-projections
8578− |= ps=(list iwprojection)
8579− ^- ?
8580− ?~ ps |
8581− &
8582−::
8583−+$ iwidth-elaboration [original=expr typ=itype sub=isub projections=(list iwprojection)]
8584−++ infer-width-elaboration
8585− |= [e=expr env=ienv state=istate]
8586− ^- (each iwidth-elaboration idiag)
8587− =/ out=iresult (infer-fragment e env state)
8588− ?: ?=(%| -.out) [%| p.out]
8589− [%& [e typ.p.out sub.state.p.out (flop projections.state.p.out)]]
8590−::
8591−:: Source-bound gate-layout evidence, confined to checked root gate
8592−:: definitions and direct unshadowed prelude calls. The prepared prelude
8593−:: interface and its retained source are trusted as a matching artifact.
8594−:: Layouts identify sample binder faces; they do not change call arity or
8595−:: authorize stripping nested value faces. Unknown origins use ordinary fit.
8596−++ direct-written-gates
8597− |= [ds=(list def) out=ivisited]
8598− ^- ivisited
8599− ?~ ds out
8600− ?: ?=(%mold -.i.ds) $(ds t.ds)
8601− ?. |(?=(%gate -.val.i.ds) ?=(%gate-wide -.val.i.ds)) $(ds t.ds)
8602− $(ds t.ds, out (~(put by out) name.i.ds &))
8603−++ direct-may-use-prelude
8604− |= [ds=(list def) root=ivisited heads=ivisited]
8605− ^- ?
8606− ?~ ds |
8607− ?: ?=(%mold -.i.ds) $(ds t.ds)
8608− =/ refs=(list term) (dependency-expr val.i.ds)
8609− =/ has-root=? (lien refs |=(n=term ?=(^ (~(get by root) n))))
8610− =/ has-head=? (lien refs |=(n=term ?=(^ (~(get by heads) n))))
8611− ?: &(has-root has-head) &
8612− $(ds t.ds)
8613−++ direct-unique-names
8614− |= [names=(list term) seen=ivisited]
8615− ^- ?
8616− ?~ names &
8617− ?: ?=(^ (~(get by seen) i.names)) |
8618− $(names t.names, seen (~(put by seen) i.names &))
8619−++ direct-prelude-evidence
8620− |= [ds=(list def) prelude=(unit ifile)]
8621− ^- (unit igate-prelude-evidence)
8622− ?~ prelude ~
8623− ?~ source.u.prelude ~
8624− =/ root=ivisited (direct-written-gates ds ~)
8625− =/ names=(list term) (turn values.u.prelude |=(e=[name=term scheme=ischeme] name.e))
8626− =/ heads=ivisited (graph-nameset names ~)
8627− ?. (direct-may-use-prelude ds root heads) ~
8628− =/ parsed (parse at.u.prelude u.source.u.prelude)
8629− ?: ?=(%| -.parsed) ~
8630− ?^ (duplicate-defs defs.p.parsed) ~
8631− ?. (direct-unique-names (global-value-names defs.p.parsed) ~) ~
8632− =/ gates=(map term def) (direct-checked-gates defs.p.parsed values.u.prelude)
8633− `[u.prelude gates]
8634−++ direct-checked-gates
8635− |= [ds=(list def) env=ienv]
8636− ^- (map term def)
8637− =/ names=(list term) (turn env |=(e=[name=term scheme=ischeme] name.e))
8638− =/ known=ivisited (graph-nameset names ~)
8639− =/ out=(map term def) ~
8640− |-
8641− ?~ ds out
8642− =/ d=def i.ds
8643− ?: ?=(%mold -.d) $(ds t.ds)
8644− ?. ?=(^ (~(get by known) name.d)) $(ds t.ds)
8645− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) $(ds t.ds)
8646− $(ds t.ds, out (~(put by out) name.d d))
8647−++ direct-find-gate
8648− |= [n=term ds=(list def)]
8649− ^- (unit def)
8650− ?~ ds ~
8651− ?: &(?=(%value -.i.ds) =(n name.i.ds)) `i.ds
8652− $(ds t.ds)
8653−++ direct-gate-sample
8654− |= d=def
8655− ^- (unit sample)
8656− ?. ?=(%value -.d) ~
8657− ?- -.val.d
8658− %gate `sample.val.d
8659− %gate-wide `sample.val.d
8660− * ~
8661− ==
8662−++ direct-sample-name
8663− |= sam=sample
8664− ^- (unit term)
8665− ?- -.sam
8666− %bind `name.sam
8667− %face `name.sam
8668− %pun `name.sam
8669− * ~
8670− ==
8671−++ direct-field-name
8672− |= f=field
8673− ^- (unit term)
8674− ?- -.f
8675− %face `name.f
8676− %pun `name.f
8677− * ~
8678− ==
8679−++ direct-slot-body
8680− |= [typ=itype name=(unit term)]
8681− ^- (unit itype)
8682− ?~ name `typ
8683− ?. ?=(%face -.typ) ~
8684− ?. =(name.typ u.name) ~
8685− `body.typ
8686−++ direct-invariant
8687− |= [a=itype b=itype sub=isub next=@ud]
8688− ^- ifit
8689− ?: (itype-face-asym a b sub) [%unknown ~]
8690− =/ forward=ifit (itype-fit a b sub next)
8691− ?. ?=(%ok -.forward) [%unknown ~]
8692− ?: (itype-face-asym a b sub.forward) [%unknown ~]
8693− =/ reverse=ifit (itype-fit b a sub.forward next.forward)
8694− ?. ?=(%ok -.reverse) [%unknown ~]
8695− reverse
8696−++ direct-function-fit
8697− |= [a=itype b=itype sam=sample sh=shape sub=isub next=@ud]
8698− ^- ifit
8699− ?. &(?=(%fn -.a) ?=(%fn -.b) ?=(%cell -.sam) ?=(%fn -.sh)) [%unknown ~]
8700− ?. ?=(%cell -.sample.sh) [%unknown ~]
8701− =/ as=(list sample) items.sam
8702− =/ bs=(list field) fields.sample.sh
8703− ?~ as [%unknown ~]
8704− ?~ t.as [%unknown ~]
8705− ?^ t.t.as [%unknown ~]
8706− ?~ bs [%unknown ~]
8707− ?~ t.bs [%unknown ~]
8708− ?^ t.t.bs [%unknown ~]
8709− ?. &(?=(%cell -.sample.a) ?=(%cell -.sample.b)) [%unknown ~]
8710− =/ an=(unit term) (direct-sample-name i.as)
8711− =/ bn=(unit term) (direct-field-name i.bs)
8712− ?: &(?=(^ an) ?=(^ bn) !=(u.an u.bn)) [%unknown ~]
8713− =/ x=(unit itype) (direct-slot-body hed.sample.a an)
8714− =/ y=(unit itype) (direct-slot-body hed.sample.b bn)
8715− ?~ x [%unknown ~]
8716− ?~ y [%unknown ~]
8717− =/ first=ifit (direct-invariant u.x u.y sub next)
8718− ?. ?=(%ok -.first) [%unknown ~]
8719− =. an (direct-sample-name i.t.as)
8720− =. bn (direct-field-name i.t.bs)
8721− ?: &(?=(^ an) ?=(^ bn) !=(u.an u.bn)) [%unknown ~]
8722− =/ x2=(unit itype) (direct-slot-body tal.sample.a an)
8723− =/ y2=(unit itype) (direct-slot-body tal.sample.b bn)
8724− ?~ x2 [%unknown ~]
8725− ?~ y2 [%unknown ~]
8726− =/ second=ifit (direct-invariant u.x2 u.y2 sub.first next.first)
8727− ?. ?=(%ok -.second) [%unknown ~]
8728− (direct-invariant product.a product.b sub.second next.second)
8729−:: This is a tentative proof: its caller must require closed call samples
8730−:: and repeat every positional check under the stable final substitution.
8731−++ direct-positional-fit
8732− |= [args=(list expr) slots=(list sample) actual=itype expected=itype env=ienv state=istate sub=isub next=@ud]
8733− ^- ifit
8734− ?~ args [%unknown ~]
8735− ?~ slots [%unknown ~]
8736− =/ last=? ?=(~ t.args)
8737− ?: !=(last ?=(~ t.slots)) [%unknown ~]
8738− =/ split=(unit [left=itype right=itype])
8739− ?: last `[actual expected]
8740− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8741− `[hed.actual hed.expected]
8742− ?~ split [%unknown ~]
8743− =/ x=itype left.u.split
8744− =/ y=itype right.u.split
8745− =/ expected-name=(unit term) (direct-sample-name i.slots)
8746− =/ expected-body=(unit itype) (direct-slot-body y expected-name)
8747− ?~ expected-body [%unknown ~]
8748− =. y u.expected-body
8749− =/ fit=ifit (itype-fit x y sub next)
8750− =/ accepted=? &(?=(%ok -.fit) !(itype-positional-slot-face-asym x y sub.fit))
8751− =/ result=(unit ifit)
8752− ?: accepted `fit
8753− ?. &(?=(%face -.i.slots) ?=(%fn -.shape.i.slots)) ~
8754− ?. ?=(%wing -.i.args) ~
8755− ?. ?=([@ ~] names.i.args) ~
8756− ?. (unique-value-name i.names.i.args globals.state) ~
8757− =/ source=(unit def) (~(get by gate-defs.state) i.names.i.args)
8758− ?~ source ~
8759− =/ sample=(unit sample) (direct-gate-sample u.source)
8760− ?~ sample ~
8761− =/ trial=ifit (direct-function-fit x y u.sample shape.i.slots sub next)
8762− ?. ?=(%ok -.trial) ~
8763− `trial
8764− ?~ result [%unknown ~]
8765− =. fit u.result
8766− ?: last fit
8767− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) [%unknown ~]
8768− ?. ?=(%ok -.fit) [%unknown ~]
8769− $(args t.args, slots t.slots, actual tal.actual, expected tal.expected, sub sub.fit, next next.fit)
8770−++ direct-any-gate-arg
8771− |= [args=(list expr) defs=(map term def)]
8772− ^- ?
8773− ?~ args |
8774− =/ found=?
8775− ?. ?=(%wing -.i.args) |
8776− ?. ?=([@ ~] names.i.args) |
8777− ?=(^ (~(get by defs) i.names.i.args))
8778− ?: found &
8779− $(args t.args)
8780−++ direct-gate-call-fit
8781− |= [e=expr actual=itype expected=itype env=ienv state=istate]
8782− ^- (unit ifit)
8783− ?. ?=(%call -.e) ~
8784− ?~ args.e ~
8785− ?~ t.args.e ~
8786− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8787− ?. ?=(%wing -.head.e) ~
8788− ?. ?=([@ ~] names.head.e) ~
8789− ?. ?=(~ (ienv-lookup i.names.head.e env)) ~
8790− ?. (unique-value-name i.names.head.e globals.state) ~
8791− ?. (direct-any-gate-arg args.e gate-defs.state) ~
8792− ?~ prelude.state ~
8793− ?~ source.u.prelude.state ~
8794− ?~ head-evidence.state ~
8795− ?. =(u.prelude.state iface.u.head-evidence.state) ~
8796− ?. ?=(^ (ienv-lookup i.names.head.e values.u.prelude.state)) ~
8797− =/ head=(unit def) (~(get by gates.u.head-evidence.state) i.names.head.e)
8798− ?~ head ~
8799− =/ sam=(unit sample) (direct-gate-sample u.head)
8800− ?~ sam ~
8801− ?. ?=(%cell -.u.sam) ~
8802− =/ fit=ifit (direct-positional-fit args.e items.u.sam actual expected env state sub.state next.state)
8803− ?. ?=(%ok -.fit) ~
8804− :: Enclosing inference may add constraints after this call. Only a
8805− :: closed call-sample proof can remain stable under those later bindings.
8806− =/ actual-final=itype (itype-normalize actual sub.fit)
8807− =/ expected-final=itype (itype-normalize expected sub.fit)
8808− ?^ (itype-vars actual-final) ~
8809− ?^ (itype-vars expected-final) ~
8810− ?: |((itype-has-tag actual-final) (itype-has-tag expected-final)) ~
8811− :: A later argument may resolve a variable used by an earlier slot.
8812− :: Recheck every fit and face against the completed substitution; no
8813− :: additional binding or fresh variable is permitted in the second pass.
8814− =/ verified=ifit (direct-positional-fit args.e items.u.sam actual expected env state sub.fit next.fit)
8815− ?. ?=(%ok -.verified) ~
8816− ?. &(=(sub.fit sub.verified) =(next.fit next.verified)) ~
8817− `fit
8818−::
8819−++ infer-call-with-head
8820− |= [e=expr env=ienv state=istate head=iresult]
8821− ^- iresult
8822− ?> ?=(%call -.e)
8823− ?~ args.e [%| ["call has no argument" ~]]
8824− ?: ?=(%| -.head) head
8825− =/ head-type=itype (itype-walk typ.p.head sub.state.p.head)
8826− =/ arg=iresult
8827− ?^ t.args.e
8828− ?: ?=(%fn -.head-type)
8829− (infer-call-context-args args.e sample.head-type env state.p.head (span-of head.e))
8830− (infer-simple-items (turn args.e |=(a=expr [(span-of a) ~ a])) env state.p.head)
8831− ?: ?=(%fn -.head-type)
8832− (infer-call-context-arg i.args.e sample.head-type env state.p.head (span-of head.e))
8833− (infer-fragment i.args.e env state.p.head)
8834− ?: ?=(%| -.arg) arg
8835− =/ st=istate state.p.arg
8836− =/ ht=itype (itype-walk typ.p.head sub.st)
8837− ?: ?=(%fn -.ht)
8838− =/ shape=(unit [source=iwfields target=iwfields])
8839− ?^ t.args.e ~
8840− (width-shape typ.p.arg sample.ht sub.st)
8841− ?^ shape [%| ["record width constraint needs unsupported inference" ~]]
8842− =/ fit=ifit
8843− ?^ t.args.e (itype-fit-inner typ.p.arg sample.ht sub.st next.st & |)
8844− (itype-fit typ.p.arg sample.ht sub.st next.st)
8845− =/ direct=(unit ifit)
8846− ?: ?=(%ok -.fit) ~
8847− (direct-gate-call-fit e typ.p.arg sample.ht env st)
8848− =. fit ?~(direct fit u.direct)
8849− ?: ?=(%unknown -.fit)
8850− ?~ defer.st [%| ["call constraint is not supported by partial inference" ~]]
8851− =/ edge=(unit dgo) (dg-eligible-ctor e typ.p.head typ.p.arg sample.ht st)
8852− ?~ edge [%| ["call constraint is not supported by partial inference" ~]]
8853− ?: (gth (lent obligations.st) 63) [%| ["call constraint is not supported by partial inference" ~]]
8854− [%& product.ht st(obligations [u.edge obligations.st])]
8855−
8856− ?: ?=(%bad -.fit)
8857− ?~ t.args.e
8858− =/ missing=(unit idiag) (missing-union-tag i.args.e sample.ht sub.st (span-of head.e))
8859− ?^ missing [%| u.missing]
8860− =/ nested=(unit idiag) (nested-missing-tag i.args.e typ.p.arg sample.ht sub.st next.st (span-of head.e))
8861− ?^ nested [%| u.nested]
8862− [%| ["call's sample and argument types do not unify" ~[[(span-of head.e) (site-type-note "called gate" ht sub.st)] [(span-of i.args.e) (site-type-note "argument" typ.p.arg sub.st)]]]]
8863− =/ bad=(unit [at=span typ=itype])
8864− (call-error-site args.e typ.p.arg sample.ht sub.st next.st)
8865− =/ whole-args=span
8866− [beg:(span-of i.args.e) end:(span-of (rear args.e))]
8867− =/ arg-at=span ?~(bad whole-args at.u.bad)
8868− =/ arg-type=itype ?~(bad typ.p.arg typ.u.bad)
8869− [%| ["call's sample and argument types do not unify" ~[[(span-of head.e) (site-type-note "called gate" ht sub.st)] [arg-at (site-type-note "argument" arg-type sub.st)]]]]
8870− ?: &(?=(^ defer.st) !(dg-stable-call-fit typ.p.arg sample.ht product.ht sub.fit ?=(^ t.args.e)))
8871− [%| ["deferred call fit needs stable inference" ~]]
8872− =/ face-asym=?
8873− ?^ direct |
8874− ?^ t.args.e (itype-positional-face-asym args.e typ.p.arg sample.ht sub.fit)
8875− (itype-face-asym typ.p.arg sample.ht sub.fit)
8876− ?: &((itype-has-face typ.p.arg sub.fit) face-asym (itype-output-may-be-cell product.ht sub.fit))
8877− [%| ["call result face propagation is not supported by partial inference" ~]]
8878− [%& product.ht st(sub sub.fit, next next.fit)]
8879− =/ result=itype [%var next.st]
8880− =/ uni=(unit isub) (itype-unify ht [%fn typ.p.arg result] sub.st)
8881− ?~ uni
8882− [%| ["call's sample and argument types do not unify" ~[[(span-of head.e) (site-type-note "called gate" ht sub.st)] [(span-of i.args.e) (site-type-note "argument" typ.p.arg sub.st)]]]]
8883− [%& result st(next +(next.st), sub u.uni)]
8884−::
88856612++ call-error-site
88866613 |= [args=(list expr) actual=itype expected=itype sub=isub next=@ud]
88876614 ^- (unit [at=span typ=itype])
88886615 ?~ args ~
88896616 =/ original=[left=itype right=itype] [actual expected]
8890− ?: |(?=(%var -.left.original) ?=(%avar -.left.original) ?=(%rvar -.left.original) |(?=(%nvar -.left.original) ?=(%rnvar -.left.original)) ?=(%var -.right.original) ?=(%avar -.right.original) ?=(%rvar -.right.original) |(?=(%nvar -.right.original) ?=(%rnvar -.right.original))) ~
6617+ ?: |(?=(%var -.left.original) ?=(%avar -.left.original) ?=(%nvar -.left.original) ?=(%var -.right.original) ?=(%avar -.right.original) ?=(%nvar -.right.original)) ~
88916618 =. actual (itype-walk actual sub)
88926619 =. expected (itype-walk expected sub)
88936620 ?: &(?=(%face -.expected) !?=(%face -.actual))
@@ -8902,507 +6629,34 @@
89026629 ?: ?=(%unknown -.first) ~
89036630 $(args t.args, actual tal.actual, expected tal.expected, sub sub.first, next next.first)
89046631::
8905−:: Context can help a call argument or cast value while the final fit
8906−:: checks the complete right-nested type, including any written faces.
8907−::
8908−:: Context can resolve the payload of a canonical prelude unit, but an
8909−:: unrelated union with a similar noun shape is not the same mold.
8910−++ infer-unit-context
8911− |= [e=expr expected=itype env=ienv state=istate context=span]
8912− ^- iresult
8913− ?> ?=(%unit -.e)
8914− ?> ?=(%union -.expected)
8915− ?~ prelude.state (infer-fragment e env state)
8916− =/ standard=(unit ischeme) (find-jibb-mold %unit u.prelude.state)
8917− ?~ standard (infer-fragment e env state)
8918− ?. (standard-unit-template u.standard at.u.prelude.state) (infer-fragment e env state)
8919− ?. =(origin.expected `[at.u.prelude.state %unit]) (infer-fragment e env state)
8920− ?~ args.expected (infer-fragment e env state)
8921− ?^ t.args.expected (infer-fragment e env state)
8922− =/ payload=itype i.args.expected
8923− =/ canonical=(unit itype) (template-apply u.standard ~[payload])
8924− ?~ canonical (infer-fragment e env state)
8925− ?> ?=(%union -.u.canonical)
8926− ?. =((itype-normalize expected(label ~) sub.state) (itype-normalize u.canonical(label ~) sub.state))
8927− (infer-fragment e env state)
8928− =/ value=iresult (infer-call-context-arg val.e payload env state context)
8929− ?: ?=(%| -.value) value
8930− =/ fit=ifit (itype-fit typ.p.value payload sub.state.p.value next.state.p.value)
8931− ?: ?=(%unknown -.fit) [%| ["unit payload constraint is not supported by partial inference" ~]]
8932− ?: ?=(%bad -.fit)
8933− =/ missing=(unit idiag) (missing-union-tag val.e payload sub.state.p.value context)
8934− ?^ missing [%| u.missing]
8935− =/ nested=(unit idiag) (nested-missing-tag val.e typ.p.value payload sub.state.p.value next.state.p.value context)
8936− ?^ nested [%| u.nested]
8937− [%| ["unit payload does not fit its expected type" ~[[context (site-type-note "expected unit payload" payload sub.state.p.value)] [(span-of val.e) (site-type-note "payload" typ.p.value sub.state.p.value)]]]]
8938− [%& expected state.p.value(sub sub.fit, next next.fit)]
8939−::
8940−:: A known gate may receive an enclosing target before its argument is
8941−:: inferred when its result is open or a direct, matching named generic
8942−:: union. Opaque, recursive, tag-constrained and variable-bound union
8943−:: results keep the existing directional path.
8944−++ infer-contextual-call
8945− |= [e=expr expected=itype env=ienv state=istate]
8946− ^- iresult
8947− ?> ?=(%call -.e)
8948− ?~ args.e [%| ["call has no argument" ~]]
8949− =/ head=iresult (infer-fragment head.e env state)
8950− ?: ?=(%| -.head) head
8951− =/ ht=itype (itype-walk typ.p.head sub.state.p.head)
8952− ?. ?=(%fn -.ht) (infer-call-with-head e env state head)
8953− =/ result=itype (itype-walk product.ht sub.state.p.head)
8954− =/ eligible=?
8955− ?: ?=(%var -.result) &
8956− :: A direct known generic union may receive the same nominal result
8957− :: context before its arguments are checked. Variable-bound origins,
8958− :: pending tags, recursive identities and unknown atoms stay open.
8959− ?. &(?=(%union -.product.ht) ?=(%union -.result) ?=(%union -.expected)) |
8960− ?~ origin.result |
8961− ?. =(origin.result origin.expected) |
8962− ?~ args.result |
8963− ?. =((lent args.result) (lent args.expected)) |
8964− ?: |((itype-has-tag (itype-normalize result sub.state.p.head)) (itype-has-tag (itype-normalize expected sub.state.p.head))) |
8965− ?: |((itype-has-recursive (itype-normalize result sub.state.p.head)) (itype-has-recursive (itype-normalize expected sub.state.p.head))) |
8966− ?: |((itype-has-any-atom result sub.state.p.head) (itype-has-any-atom expected sub.state.p.head)) |
8967− &
8968− ?. eligible (infer-call-with-head e env state head)
8969− ?: |(?=(%var -.expected) ?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected)) (itype-has-tag (itype-normalize expected sub.state.p.head)))
8970− (infer-call-with-head e env state head)
8971− =/ sub=(unit isub) (itype-unify result expected sub.state.p.head)
8972− ?~ sub (infer-call-with-head e env state head)
8973− (infer-call-with-head e env state [%& typ.p.head state.p.head(sub u.sub)])
8974−::
8975−:: An eligible fully faced literal receives context by name, in source order.
8976−++ width-literal-fields
8977− |= [items=(list item) axis=@ud fuel=@ud]
8978− ^- (unit iwfields)
8979− =/ order=(list iwfield) ~
8980− =/ index=(map term iwfield) *(map term iwfield)
8981− |-
8982− ?~ items ~
8983− ?: =(0 fuel) ~
8984− ?~ face.i.items ~
8985− =/ at-axis=@ud ?~(t.items axis (mul 2 axis))
8986− =/ entry=iwfield [u.face.i.items at-axis [%noun ~]]
8987− ?: ?=(^ (~(get by index) name.entry)) ~
8988− =. index (~(put by index) name.entry entry)
8989− =. order [entry order]
8990− ?~ t.items `[(flop order) index]
8991− $(items t.items, axis +((mul 2 axis)), fuel (dec fuel))
8992−++ width-infer-items
8993− |= [items=(list item) expected=(map term iwfield) env=ienv state=istate context=span]
8994− ^- iresult
8995− ?~ items [%| ["empty record is not supported" ~]]
8996− ?~ face.i.items [%| ["record face needs unsupported inference" ~]]
8997− =/ field=(unit iwfield) (~(get by expected) u.face.i.items)
8998− =/ head=iresult
8999− ?~ field (infer-fragment val.i.items env state)
9000− (infer-call-context-arg val.i.items typ.u.field env state context)
9001− ?: ?=(%| -.head) head
9002− =/ typ=itype [%face u.face.i.items typ.p.head]
9003− ?~ t.items [%& typ state.p.head]
9004− =/ tail=iresult $(items t.items, state state.p.head)
9005− ?: ?=(%| -.tail) tail
9006− [%& [%cell typ typ.p.tail] state.p.tail]
9007−++ width-infer-literal
9008− |= [e=expr expected=itype env=ienv state=istate context=span]
9009− ^- (unit iresult)
9010− ?. ?=(%tuple -.e) ~
9011− ?. |(?=(%cell -.expected) ?=(%face -.expected)) ~
9012− =/ source=(unit iwfields) (width-literal-fields items.e 1 4.096)
9013− =/ target=(unit iwfields) (width-scan expected sub.state 1 4.096)
9014− ?~ source ~
9015− ?~ target ~
9016− ?: (lth (lent order.u.source) (lent order.u.target)) ~
9017− ?. (width-in-order order.u.source order.u.target)
9018− `(infer-simple-items items.e env state)
9019− `(width-infer-items items.e index.u.target env state context)
9020−::
9021−:: Experimental intrinsic recognition; real bindings retain normal calls.
9022−++ explicit-proj-call
9023− |= [e=expr env=ienv state=istate]
9024− ^- ?
9025− ?. ?=(%call -.e) |
9026− ?. ?=([* ~] args.e) |
9027− ?. ?=(%wing -.head.e) |
9028− ?. =(names.head.e ~[%proj]) |
9029− ?: ?=(^ (ienv-lookup %proj env)) |
9030− ?: (lien globals.state |=(n=term =(n %proj))) |
9031− ?~ prelude.state &
9032− ?:(?=(^ (ienv-lookup %proj values.u.prelude.state)) | &)
9033−++ infer-proj-source
9034− |= [e=expr expected=itype env=ienv state=istate context=span]
9035− ^- iresult
9036− ?: ?=(%group -.e) $(e inner.e)
9037− =/ literal=(unit iresult) (width-infer-literal e expected env state context)
9038− ?^ literal u.literal
9039− (infer-fragment e env state)
9040−++ infer-proj-context
9041− |= [e=expr expected=itype env=ienv state=istate context=span]
9042− ^- iresult
9043− ?> ?=(%call -.e)
9044− ?~ args.e [%| ["proj needs one record" ~]]
9045− ?. |(?=(%cell -.expected) ?=(%face -.expected)) [%| ["proj needs an expected record type" ~]]
9046− =/ value=iresult (infer-proj-source i.args.e expected env state context)
9047− ?: ?=(%| -.value) value
9048− =/ shape=(unit [source=iwfields target=iwfields])
9049− (width-proj-shape typ.p.value expected sub.state.p.value)
9050− ?~ shape [%| ["proj needs a known record containing its expected fields" ~]]
9051− =/ project=(unit iwidth-result) (width-project u.shape sub.state.p.value next.state.p.value)
9052− ?~ project [%| ["proj constraint needs unsupported inference" ~]]
9053− =/ st=istate state.p.value(sub sub.u.project, next next.u.project)
9054− [%& expected st(projections [[at.e e typ.p.value expected steps.u.project] projections.st])]
9055−::
9056−:: A known literal singleton in a direct union can contextualize a
9057−:: loobean literal of the same noun. Only explicit singleton and cell
9058−:: competitors are considered; opaque or variable cases stay unknown.
9059−++ explicit-singleton-in-union
9060− |= [t=itype noun=@]
9061− ^- ?
9062− ?. ?=(%union -.t) |
9063− =/ cases=(list itype) cases.t
9064− =/ found=? |
9065− |-
9066− ?~ cases found
9067− =/ c=itype i.cases
9068− ?: ?=(%cell -.c) $(cases t.cases)
9069− ?. ?=(%const -.c) |
9070− ?: =(noun val.literal.c)
9071− ?: found |
9072− $(cases t.cases, found &)
9073− $(cases t.cases)
9074−::
9075−:: Select a written literal-headed case only when every competing case is
9076−:: also an explicit singleton-headed cell and exactly one matches. Opaque,
9077−:: variable-bound and differently shaped cases keep inference unchanged.
9078−:: This first slice supplies context to a directly called payload. Plain
9079−:: literal data and other expressions retain their existing inference path.
9080−++ contextual-atomic-arguments
9081− |= args=(list expr)
9082− ^- ?
9083− ?~ args &
9084− ?. ?=(?(%lit %wing %ctor) -.i.args) |
9085− $(args t.args)
9086−++ contextual-direct-payload-call
9087− |= e=expr
9088− ^- ?
9089− ?: ?=(%group -.e) $(e inner.e)
9090− ?. ?=(%call -.e) |
9091− ?. ?=(%wing -.head.e) |
9092− ?~ args.e |
9093− (contextual-atomic-arguments args.e)
9094−::
9095−:: A walked variable may have concealed a union inside a substituted
9096−:: structure before this arm was called. Decline in that case rather than
9097−:: deriving provenance from the already-walked type.
9098−++ contextual-simple-sub
9099− |= sub=isub
9100− ^- ?
9101− ?~ sub &
9102− ?: ?=(?(%cell %face %fn %union %collection) -.val.i.sub) |
9103− $(sub t.sub)
9104−::
9105−:: Check the syntactic root before scanning; scan substitutions once.
9106−++ grec-direct-context
9107− |= [expected=itype sub=isub]
9108− ^- ?
9109− =/ left=@ud 4.096
9110− |-
9111− ?: ?=(%face -.expected)
9112− ?: =(0 left) |
9113− $(expected body.expected, left (dec left))
9114− ?. ?=(%grec -.expected) |
9115− ?~ sub &
9116− ?: =(0 left) |
9117− ?: ?=(?(%cell %face %fn %union %collection %grec) -.val.i.sub) |
9118− $(sub t.sub, left (dec left))
9119−++ contextual-direct-union
9120− |= target=itype
9121− ^- ?
9122− ?: ?=(%face -.target) $(target body.target)
9123− ?=(%union -.target)
9124−++ contextual-tagged-case
9125− |= [target=itype tag=@ sub=isub]
9126− ^- (unit itype)
9127− ?. ?=(%union -.target) ~
9128− =/ remaining=(list itype) cases.target
9129− =/ found=(unit itype) ~
9130− =/ seen=(set @) *(set @)
9131− |-
9132− ?~ remaining found
9133− =/ c=itype i.remaining
9134− ?. ?=(%cell -.c) ~
9135− =/ head=itype hed.c
9136− ?. ?=(%const -.head) ~
9137− ?: (~(has in:..zuse seen) val.literal.head) ~
9138− =. seen (~(put in:..zuse seen) val.literal.head)
9139− ?: =(tag val.literal.head)
9140− $(remaining t.remaining, found `c)
9141− $(remaining t.remaining)
9142−::
9143−:: A bounded syntactic screen: no nested branch, cast, gate or local body
9144−:: can re-enter cell-branch retry during either inference attempt.
9145−++ closed-cell-retry-safe
9146− |= [todo=(list expr) fuel=@ud]
9147− ^- ?
9148− ?~ todo &
9149− ?: =(0 fuel) |
9150− =/ e=expr i.todo
9151− =. fuel (dec fuel)
9152− ?+ -.e |
9153− %lit $(todo t.todo)
9154− %wing $(todo t.todo)
9155− %ctor $(todo t.todo)
9156− %path $(todo t.todo)
9157− %crash $(todo t.todo)
9158− %str
9159− ?. (levy pieces.e |=(p=piece ?=(%text -.p))) |
9160− $(todo t.todo)
9161− %group $(todo [inner.e t.todo])
9162− %pair $(todo [val.e t.todo])
9163− %unit $(todo [val.e t.todo])
9164− %list $(todo (weld items.e t.todo))
9165− %tuple $(todo (weld (turn items.e |=(i=item val.i)) t.todo))
9166− %change $(todo (weld (turn edits.e |=(ed=edit val.ed)) t.todo))
9167− %call $(todo [head.e (weld args.e t.todo)])
9168− %trace $(todo [val.e then.e t.todo])
9169− ==
9170−::
9171−++ closed-cell-sub-safe
9172− |= [sub=isub fuel=@ud]
9173− ^- ?
9174− ?~ sub &
9175− ?: =(0 fuel) |
9176− ?: ?=(?(%cell %face %fn %union %collection %grec %jrec %recursive) -.val.i.sub) |
9177− $(sub t.sub, fuel (dec fuel))
9178−::
9179−++ closed-cell-branch-eligible
9180− |= [e=expr expected=itype sub=isub]
9181− ^- ?
9182− ?. &(?=(%branch -.e) ?=(%cell -.expected) (closed-cell-sub-safe sub 512)) |
9183− ?~ arms.e |
9184− ?~ t.arms.e |
9185− ?^ t.t.arms.e |
9186− =/ x=arm i.arms.e
9187− =/ y=arm i.t.arms.e
9188− ?. &(?=(%lit -.pat.x) ?=(%lit -.pat.y)) |
9189− ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y)) |
9190− ?: =(val.lit.pat.x val.lit.pat.y) |
9191− (closed-cell-retry-safe ~[subject.e val.x val.y] 512)
9192−::
9193−:: Attempt ordinary inference first; retry from the same state only for
9194−:: the bounded non-reentrant syntax above. Preserve original value faces.
9195−++ infer-closed-cell-branch
9196− |= [e=expr expected=itype env=ienv state=istate context=span]
9197− ^- iresult
9198− ?> (closed-cell-branch-eligible e expected sub.state)
9199− ?> ?=(%branch -.e)
9200− ?> ?=(^ arms.e)
9201− ?> ?=(^ t.arms.e)
9202− =/ ordinary=iresult (infer-fragment e env state)
9203− =/ ordinary-good=?
9204− ?: ?=(%| -.ordinary) |
9205− =/ fit=ifit (itype-fit typ.p.ordinary expected sub.state.p.ordinary next.state.p.ordinary)
9206− ?=(%ok -.fit)
9207− ?: ordinary-good ordinary
9208− =/ attempt=(unit iresult)
9209− =/ x=arm i.arms.e
9210− =/ y=arm i.t.arms.e
9211− =/ subject=iresult (infer-fragment subject.e env state)
9212− ?: ?=(%| -.subject) ~
9213− =/ subject-type=itype (itype-normalize typ.p.subject sub.state.p.subject)
9214− ?: ?=(%union -.subject-type) ~
9215− =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
9216− ?~ su ~
9217− =/ left=iresult (infer-call-context-arg val.x expected env state.p.subject(sub u.su) context)
9218− ?: ?=(%| -.left) ~
9219− =/ lf=ifit (itype-fit typ.p.left expected sub.state.p.left next.state.p.left)
9220− ?. ?=(%ok -.lf) ~
9221− =/ right=iresult (infer-call-context-arg val.y expected env state.p.left(sub sub.lf, next next.lf) context)
9222− ?: ?=(%| -.right) ~
9223− =/ rf=ifit (itype-fit typ.p.right expected sub.state.p.right next.state.p.right)
9224− ?. ?=(%ok -.rf) ~
9225− =/ sub=isub sub.rf
9226− =/ next=@ud next.rf
9227− =/ lt=itype (itype-normalize typ.p.left sub)
9228− =/ rt=itype (itype-normalize typ.p.right sub)
9229− =/ et=itype (itype-normalize expected sub)
9230− ?. =(lt rt) ~
9231− ?: |(?=(^ (itype-vars lt)) ?=(^ (itype-vars rt)) ?=(^ (itype-vars et))) ~
9232− ?: |((itype-has-tag lt) (itype-has-tag rt) (itype-has-tag et)) ~
9233− =/ lcheck=ifit (itype-fit typ.p.left expected sub next)
9234− ?. ?=(%ok -.lcheck) ~
9235− ?. &(=(sub.lcheck sub) =(next.lcheck next)) ~
9236− =/ rcheck=ifit (itype-fit typ.p.right expected sub next)
9237− ?. ?=(%ok -.rcheck) ~
9238− ?. &(=(sub.rcheck sub) =(next.rcheck next)) ~
9239− `[%& typ.p.left state.p.right(sub sub, next next)]
9240− ?~ attempt ordinary
9241− u.attempt
6632+:: Context can help each argument while the final fit still checks the
6633+:: complete right-nested sample, including any faces on its positions.
92426634::
92436635++ infer-call-context-arg
92446636 |= [e=expr expected=itype env=ienv state=istate context=span]
92456637 ^- iresult
9246− ?: &(?=(^ defer.state) ?=(%branch -.e)) (infer-fragment e env state)
9247− ?: &(?=(^ defer.state) ?=(^ prelude.state) ?=(%tuple -.e))
9248− (infer-fragment e env state)
9249− ?: ?=(%pair -.e) $(e (pair-as-cell e))
9250− ?: ?=(%group -.e) $(e inner.e)
9251− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
9252− ?: ?=(%trace -.e)
9253− =/ traced=iresult (infer-fragment val.e env state)
9254− ?: ?=(%| -.traced) traced
9255− $(e then.e, state state.p.traced)
92566638 =/ target=itype (itype-walk expected sub.state)
92576639 |-
92586640 ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
9259− ?: (explicit-proj-call e env state)
9260− (infer-proj-context e expected env state context)
9261− :: Experimental construction only for a source-proven direct target.
9262− :: Decline any walked structural binding to retain raw-variable provenance.
9263− ?: &(?=(%grec -.target) ?=(%tuple -.e) (grec-direct-context expected sub.state))
9264− =/ unfolded=(unit [view=itype left=@ud]) (grec-unfold-view target jrec-fuel.state)
9265− ?~ unfolded [%| ["recursive mold unfolding needs unsupported inference" ~]]
9266− ?~ items.e [%| ["recursive mold constructor needs unsupported inference" ~]]
9267− =/ first=item i.items.e
9268− ?. &(?=(~ face.first) ?=(%lit -.val.first) =(%term form.lit.val.first))
9269− [%| ["recursive mold constructor needs unsupported inference" ~]]
9270− =/ chosen=(unit itype) (contextual-tagged-case view.u.unfolded val.lit.val.first sub.state)
9271− ?~ chosen [%| ["recursive mold constructor has no matching case" ~]]
9272− =/ value=iresult (infer-call-context-items items.e u.chosen env state(jrec-fuel left.u.unfolded) context)
9273− ?: ?=(%| -.value) value
9274− =/ fit=ifit (itype-fit typ.p.value u.chosen sub.state.p.value next.state.p.value)
9275− ?: ?=(%unknown -.fit) [%| ["recursive mold case needs unsupported inference" ~]]
9276− ?: ?=(%bad -.fit) [%| ["recursive mold case does not fit its source shape" ~]]
9277− [%& target state.p.value(sub sub.fit, next next.fit)]
9278− :: Only the source-proven one-layer cell is exposed. Each recursive
9279− :: descent consumes one written tuple; named values use ordinary fit.
9280− ?: &(?=(%jrec -.target) ?=(%lit -.e) =(%null form.lit.e))
9281− ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
9282− [%& target state(jrec-fuel (dec jrec-fuel.state))]
9283− ?: &(?=(%jrec -.target) ?=(%tuple -.e))
9284− ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
9285− =. state state(jrec-fuel (dec jrec-fuel.state))
9286− =/ shape=itype
9287− [%cell [%face head.target [%atom aura.target]] [%face tail.target target]]
9288− =/ value=iresult (infer-call-context-items items.e shape env state context)
9289− ?: ?=(%| -.value) value
9290− =/ fit=ifit (itype-fit typ.p.value shape sub.state.p.value next.state.p.value)
9291− ?: ?=(%unknown -.fit) [%| ["recursive mold cell constraint needs unsupported inference" ~]]
9292− ?: ?=(%bad -.fit) [%| ["recursive mold cell does not fit its source shape" ~]]
9293− [%& target state.p.value(sub sub.fit, next next.fit)]
9294− ?: ?=(%call -.e) (infer-contextual-call e target env state)
9295− =/ empty-list=(unit iresult) (empty-list-null-branch e env state `[target context])
9296− ?^ empty-list u.empty-list
9297− ?: (single-structured-pattern e)
9298− ?> ?=(%branch -.e)
9299− =/ empty-union=(unit iresult) (known-empty-union-wing subject.e env state)
9300− ?^ empty-union (infer-known-union-context-subject e target env u.empty-union context)
9301− =/ single=(unit iresult) (grec-single-wing-subject subject.e env state)
9302− ?^ single (infer-known-union-context-subject e target env u.single context)
9303− (infer-single-case-branch e env state `[target context])
9304− ?: (cell-binder-pattern e)
9305− (infer-cell-branch e env state `[target context])
9306− :: In an explicit singleton context retain the written loobean noun;
9307− :: the ordinary singleton fit compares its noun, not its spelling.
9308− =/ singleton=(unit itype)
9309− ?. ?=(%lit -.e) ~
9310− ?. =(%loobean form.lit.e) ~
9311− ?. |(?=(%const -.target) &(?=(%union -.expected) (explicit-singleton-in-union expected val.lit.e))) ~
9312− `[%const lit.e]
9313− ?^ singleton [%& u.singleton state]
9314− =/ known=(unit iresult)
9315− ?: ?=(%branch -.e) (known-union-subject subject.e env state)
9316− ~
9317− ?: &(?=(^ known) ?=(%| -.u.known) !(duplicate-loobean-arms e)) u.known
9318− ?: &(?=(^ known) ?=(%& -.u.known) ?=(~ (unit-union-payload (itype-normalize typ.p.u.known sub.state.p.u.known))))
9319− (infer-known-union-context-subject e target env u.known context)
9320− ?: &(?=(%union -.target) ?=(%unit -.e))
9321− (infer-unit-context e target env state context)
9322− ?: (closed-cell-branch-eligible e expected sub.state)
9323− (infer-closed-cell-branch e expected env state context)
9324− ?: &(?=(%flag -.target) (context-union-branch e))
9325− (infer-union-context e target env state context)
93266641 ?: &(?=(%union -.target) (context-union-branch e))
93276642 (infer-union-context e target env state context)
93286643 ?: &(?=(%collection -.target) =(%list name.target) (context-union-branch e))
93296644 (infer-union-context e target env state context)
93306645 ?: &(?=(%collection -.target) =(%list name.target) (context-list-expression e))
93316646 (infer-list-context e target env state context)
9332− :: A literal-headed tuple can receive the unique case's payload
9333− :: context. The ordinary final fit still checks the complete union.
9334− =/ selected=(unit itype)
9335− ?. &((contextual-simple-sub sub.state) (contextual-direct-union expected) ?=(%union -.target) ?=(%tuple -.e) ?=(^ items.e)) ~
9336− ?~ t.items.e ~
9337− ?^ t.t.items.e ~
9338− ?. (contextual-direct-payload-call val.i.t.items.e) ~
9339− =/ first=item i.items.e
9340− ?. &(?=(~ face.first) ?=(%lit -.val.first) |(=(%term form.lit.val.first) =(%null form.lit.val.first) =(%loobean form.lit.val.first))) ~
9341− (contextual-tagged-case target val.lit.val.first sub.state)
9342− ?^ selected
9343− ?> ?=(%tuple -.e)
9344− :: On this bounded shallow-call shape, preserve any inference that
9345− :: already fits before trying the new contextual path. Neither pass
9346− :: can recursively select a nested tuple from the atomic arguments.
9347− =/ ordinary=(unit iresult)
9348− =/ initial=iresult (infer-fragment e env state)
9349− ?: ?=(%| -.initial) ~
9350− =/ fit=ifit (itype-fit typ.p.initial target sub.state.p.initial next.state.p.initial)
9351− ?. ?=(%ok -.fit) ~
9352− `initial
9353− ?^ ordinary u.ordinary
9354− =/ value=iresult (infer-call-context-items items.e u.selected env state context)
9355− ?: ?=(%| -.value) value
9356− =/ fit=ifit (itype-fit typ.p.value u.selected sub.state.p.value next.state.p.value)
9357− ?: ?=(%unknown -.fit) [%| ["tagged case needs unsupported inference" ~]]
9358− ?: ?=(%bad -.fit) [%| ["tagged case does not fit its expected type" ~[[context "expected union case"] [(span-of e) "value"]]]]
9359− [%& typ.p.value state.p.value(sub sub.fit, next next.fit)]
9360− ?: &(?=(%cell -.target) ?=(%tuple -.e))
9361− (infer-call-context-items items.e target env state context)
93626647 (infer-fragment e env state)
93636648::
9364−:: Preserve each written face; the final complete sample fit checks faces.
9365−:: A tuple or positional field face belongs to the enclosing sample,
9366−:: not to the expression at that position. A second face, if present,
9367−:: is part of the value's own expected type.
9368−++ projection-field-target
9369− |= expected=itype
9370− ^- itype
9371− ?:(?=(%face -.expected) body.expected expected)
9372−::
9373−++ infer-call-context-items
9374− |= [items=(list item) expected=itype env=ienv state=istate context=span]
9375− ^- iresult
9376− ?~ items [%| ["empty cell is not supported by partial inference" ~]]
9377− ?~ t.items
9378− =/ last=iresult (infer-call-context-arg val.i.items (projection-field-target expected) env state context)
9379− ?: ?=(%| -.last) last
9380− =/ typ=itype typ.p.last
9381− =. typ ?~(face.i.items typ [%face u.face.i.items typ])
9382− [%& typ state.p.last]
9383− =/ target=itype (itype-walk expected sub.state)
9384− |-
9385− ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
9386− ?. ?=(%cell -.target) (infer-simple-items items env state)
9387− =/ head=iresult (infer-call-context-arg val.i.items (projection-field-target hed.target) env state context)
9388− ?: ?=(%| -.head) head
9389− =/ typ=itype typ.p.head
9390− =. typ ?~(face.i.items typ [%face u.face.i.items typ])
9391− =/ tail=iresult (infer-call-context-items t.items tal.target env state.p.head context)
9392− ?: ?=(%| -.tail) tail
9393− [%& [%cell typ typ.p.tail] state.p.tail]
9394−::
93956649++ infer-call-context-args
93966650 |= [args=(list expr) expected=itype env=ienv state=istate context=span]
93976651 ^- iresult
93986652 ?~ args [%| ["call has no argument" ~]]
9399− ?~ t.args (infer-call-context-arg i.args (projection-field-target expected) env state context)
6653+ ?~ t.args (infer-call-context-arg i.args expected env state context)
94006654 =/ target=itype (itype-walk expected sub.state)
94016655 |-
94026656 ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
94036657 ?. ?=(%cell -.target)
94046658 (infer-simple-items (turn args |=(a=expr [(span-of a) ~ a])) env state)
9405− =/ head=iresult (infer-call-context-arg i.args (projection-field-target hed.target) env state context)
6659+ =/ head=iresult (infer-call-context-arg i.args hed.target env state context)
94066660 ?: ?=(%| -.head) head
94076661 =/ tail=iresult (infer-call-context-args t.args tal.target env state.p.head context)
94086662 ?: ?=(%| -.tail) tail
@@ -9423,55 +6677,11 @@
94236677 ?: ?=(%| -.tail) tail
94246678 [%& [%cell ht typ.p.tail] state.p.tail]
94256679::
9426−:: A single all-binder cell pattern covers a known cell spine; the final
9427−:: binder captures the remaining noun. Other pattern matrices stay partial.
9428−::
9429−:: Validate binders before reading the subject, preserving shadow-error
9430−:: precedence. The last binder receives the entire remaining tail.
9431−++ cell-pattern-names
9432− |= [pats=(list pattern) env=ienv globals=(list term) seen=(list term)]
9433− ^- (each (list term) @t)
9434− ?~ pats [%& ~]
9435− ?. ?=(%bind -.i.pats) [%| 'branch pattern is not supported by partial inference']
9436− =/ name=term name.i.pats
9437− ?: |(=(name %proj) ?=(^ (ienv-lookup name env)) (lien globals |=(n=term =(n name))) (lien seen |=(n=term =(n name))))
9438− [%| 'pattern shadows a name']
9439− =/ rest=(each (list term) @t) $(pats t.pats, seen [name seen])
9440− ?: ?=(%| -.rest) rest
9441− [%& [name p.rest]]
9442−::
9443−++ cell-pattern-types
9444− |= [names=(list term) env=ienv next=@ud]
9445− ^- [typ=itype env=ienv next=@ud]
9446− ?~ names !!
9447− =/ head=itype [%var next]
9448− =/ scope=ienv [[i.names [head ~]] env]
9449− ?~ t.names [head scope +(next)]
9450− =/ tail=[typ=itype env=ienv next=@ud] $(names t.names, env scope, next +(next))
9451− [[%cell head typ.tail] env.tail next.tail]
9452−::
9453−:: At every position that must be a cell, opaque or sum types may still
9454−:: contain cells. Do not report a definite mismatch without unfolding them.
9455−++ cell-pattern-spine-unknown
9456− |= [typ=itype names=(list term) sub=isub]
9457− ^- ?
9458− ?~ names |
9459− ?~ t.names |
9460− =. typ (itype-walk typ sub)
9461− ?: ?=(%cell -.typ) $(typ tal.typ, names t.names)
9462− |(?=(%union -.typ) ?=(%collection -.typ) ?=(%recursive -.typ) ?=(%jrec -.typ) ?=(%grec -.typ) ?=(%noun -.typ) ?=(%fn -.typ) ?=(%tag -.typ))
9463−::
9464−++ cell-binder-pattern
9465− |= e=expr
9466− ^- ?
9467− ?. ?=(%branch -.e) |
9468− ?~ arms.e |
9469− ?^ t.arms.e |
9470− ?. ?=(%cell -.pat.i.arms.e) |
9471− !(single-structured-pattern e)
6680+:: A single two-binder cell pattern covers every value of a cell type.
6681+:: No other pattern matrix is implemented here.
94726682::
94736683++ infer-cell-branch
9474− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
6684+ |= [e=expr env=ienv state=istate]
94756685 ^- iresult
94766686 ?> ?=(%branch -.e)
94776687 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
@@ -9480,31 +6690,25 @@
94806690 =/ pats=(list pattern) items.pat.arm
94816691 ?~ pats [%| ["branch pattern is not supported by partial inference" ~]]
94826692 ?~ t.pats [%| ["branch pattern is not supported by partial inference" ~]]
9483− =/ names=(each (list term) @t) (cell-pattern-names pats env globals.state ~)
9484− ?: ?=(%| -.names) [%| [(trip p.names) ~]]
6693+ ?^ t.t.pats [%| ["branch pattern is not supported by partial inference" ~]]
6694+ ?. ?=(%bind -.i.pats) [%| ["branch pattern is not supported by partial inference" ~]]
6695+ ?. ?=(%bind -.i.t.pats) [%| ["branch pattern is not supported by partial inference" ~]]
6696+ =/ one=term name.i.pats
6697+ =/ two=term name.i.t.pats
6698+ ?: |(=(one two) ?=(^ (ienv-lookup one env)) ?=(^ (ienv-lookup two env)) (lien globals.state |=(x=term |(=(x one) =(x two)))))
6699+ [%| ["pattern shadows a name" ~]]
94856700 =/ subject=iresult (infer-fragment subject.e env state)
94866701 ?: ?=(%| -.subject) subject
94876702 =/ st=istate state.p.subject
9488− =/ subject-type=itype (itype-normalize typ.p.subject sub.st)
9489− ?: (itype-has-recursive subject-type)
6703+ ?: (itype-has-recursive (itype-normalize typ.p.subject sub.st))
94906704 [%| ["recursive pattern is not supported by partial inference" ~]]
94916705 ?: (itype-has-face typ.p.subject sub.st)
94926706 [%| ["record patterns are not supported by partial inference" ~]]
9493− ?: (cell-pattern-spine-unknown subject-type p.names sub.st)
9494− [%| ["cell pattern subject is not supported by partial inference" ~]]
9495− =/ binders=[typ=itype env=ienv next=@ud] (cell-pattern-types p.names env next.st)
9496− =/ sub=(unit isub) (itype-unify typ.p.subject typ.binders sub.st)
6707+ =/ head=itype [%var next.st]
6708+ =/ tail=itype [%var +(next.st)]
6709+ =/ sub=(unit isub) (itype-unify typ.p.subject [%cell head tail] sub.st)
94976710 ?~ sub [%| ["cell pattern does not match the subject type" ~]]
9498− =. st st(next next.binders, sub u.sub)
9499− ?~ expected (infer-fragment val.arm env.binders st)
9500− =/ body=iresult (infer-call-context-arg val.arm typ.u.expected env.binders st context.u.expected)
9501− ?: ?=(%| -.body) body
9502− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
9503− ?: ?=(%unknown -.fit) [%| ["cell branch result constraint is not supported by partial inference" ~]]
9504− ?: ?=(%bad -.fit) [%| ["cell branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.arm) "branch arm"]]]]
9505− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
9506− [%| ["cell branch result needs context in partial inference" ~]]
9507− [%& typ.u.expected state.p.body(sub sub.fit, next next.fit)]
6711+ (infer-fragment val.arm [[one [head ~]] [two [tail ~]] env] st(next (add 2 next.st), sub u.sub))
95086712::
95096713++ show-itype
95106714 |= [t=itype sub=isub]
@@ -9517,20 +6721,12 @@
95176721 %avar
95186722 ?: (lth id.t 26) [(add 65 id.t) ~]
95196723 "T{<id.t>}"
9520− %rvar
9521− ?: (lth id.t 26) [(add 65 id.t) ~]
9522− "T{<id.t>}"
95236724 %nvar
95246725 ?: (lth id.t 26) [(add 65 id.t) ~]
95256726 "T{<id.t>}"
9526− %rnvar
9527− ?: (lth id.t 26) [(add 65 id.t) ~]
9528− "T{<id.t>}"
95296727 %atom "@{(trip aura.t)}"
95306728 %any-atom "@"
95316729 %flag "?"
9532− %noun "*"
9533− %empty "!!"
95346730 %tag (trip txt.literal.t)
95356731 %const (trip txt.literal.t)
95366732 %union
@@ -9538,8 +6734,6 @@
95386734 ?~ args.t (trip u.label.t)
95396735 "({(trip u.label.t)} {(show-itype-cases args.t sub)})"
95406736 %recursive ?~(label.t "recursive mold" (trip u.label.t))
9541− %jrec ?~(label.t "recursive mold" (trip u.label.t))
9542− %grec ?~(label.t "recursive mold" "({(trip u.label.t)} {(show-itype-cases args.t sub)})")
95436737 %collection "({(trip name.t)} {(show-itype-cases args.t sub)})"
95446738 %face "[{(trip name.t)}={(show-itype-context body.t sub)}]"
95456739 %fn "$-({(show-itype-context sample.t sub)} {(show-itype-context product.t sub)})"
@@ -9575,21 +6769,15 @@
95756769 ^- ?
95766770 ?- -.typ
95776771 %nvar &
9578− %rnvar &
95796772 %var |
95806773 %avar |
9581− %rvar |
95826774 %atom |
95836775 %any-atom |
95846776 %flag |
9585− %noun |
9586− %empty |
95876777 %tag |
95886778 %const |
95896779 %union |((lien cases.typ |=(c=itype (itype-has-nvar c))) (lien args.typ |=(c=itype (itype-has-nvar c))))
95906780 %recursive |
9591− %jrec |
9592− %grec (lien args.typ |=(c=itype (itype-has-nvar c)))
95936781 %collection (lien args.typ |=(c=itype (itype-has-nvar c)))
95946782 %face $(typ body.typ)
95956783 %fn |($(typ sample.typ) $(typ product.typ))
@@ -9600,7 +6788,7 @@
96006788 |= [label=tape typ=itype sub=isub]
96016789 ^- tape
96026790 =/ normalized=itype (itype-normalize typ sub)
9603− ?: |(?=(%var -.normalized) ?=(%avar -.normalized) ?=(%rvar -.normalized) (itype-has-nvar normalized) (itype-has-tag normalized) (itype-has-union normalized)) label
6791+ ?: |(?=(%var -.normalized) ?=(%avar -.normalized) (itype-has-nvar normalized) (itype-has-tag normalized) (itype-has-union normalized)) label
96046792 ?: (itype-has-hidden-recursive normalized) label
96056793 =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
96066794 ?: (gth (lent vars) 26) label
@@ -9622,7 +6810,6 @@
96226810 ?+ -.resolved ~
96236811 %var `id.resolved
96246812 %avar `id.resolved
9625− %rvar `id.resolved
96266813 ==
96276814 ?~ ident $(caps t.caps)
96286815 ?: =(n u.ident) &
@@ -9637,7 +6824,6 @@
96376824 ?+ -.resolved ~
96386825 %var `id.resolved
96396826 %avar `id.resolved
9640− %rvar `id.resolved
96416827 ==
96426828 ?~ ident $(caps t.caps)
96436829 ?: =(n u.ident) `i.caps
@@ -9652,7 +6838,6 @@
96526838 ?+ -.resolved ~
96536839 %var `id.resolved
96546840 %avar `id.resolved
9655− %rvar `id.resolved
96566841 ==
96576842 ?~ ident $(caps t.caps)
96586843 =/ found=(unit icap) (cap-with-id u.ident t.caps sub)
@@ -9668,7 +6853,6 @@
96686853 ?+ -.resolved ~
96696854 %var `id.resolved
96706855 %avar `id.resolved
9671− %rvar `id.resolved
96726856 ==
96736857 ?~ ident &
96746858 ?: (cap-id-in u.ident t.caps sub) &
@@ -9683,8 +6867,8 @@
96836867 ^- ?
96846868 ?~ caps |
96856869 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
9686− ?: |(?=(%avar -.resolved) ?=(%rvar -.resolved))
9687− ?: =(n +.resolved) &
6870+ ?: ?=(%avar -.resolved)
6871+ ?: =(n id.resolved) &
96886872 $(caps t.caps)
96896873 $(caps t.caps)
96906874::
@@ -9694,20 +6878,14 @@
96946878 ?- -.t
96956879 %var |
96966880 %avar =(n id.t)
9697− %rvar =(n id.t)
96986881 %nvar |
9699− %rnvar |
97006882 %atom |
97016883 %any-atom |
97026884 %flag |
9703− %noun |
9704− %empty |
97056885 %tag |
97066886 %const |
97076887 %union |((lien cases.t |=(c=itype (has-atom-var n c))) (lien args.t |=(c=itype (has-atom-var n c))))
97086888 %recursive |
9709− %jrec |
9710− %grec (lien args.t |=(c=itype (has-atom-var n c)))
97116889 %collection (lien args.t |=(c=itype (has-atom-var n c)))
97126890 %face $(t body.t)
97136891 %fn |($(t sample.t) $(t product.t))
@@ -9747,10 +6925,6 @@
97476925 =/ out=tape ""
97486926 |-
97496927 ?~ vars out
9750− ?: (itype-var-is-restricted i.vars t)
9751− =/ sep=tape ?:(printed ", " " where ")
9752− =/ clause=tape "{sep}{(show-itype [%rvar i.vars] ~)} is an atom other than ?"
9753− $(vars t.vars, printed &, out (weld out clause))
97546928 ?: (itype-var-is-atom i.vars t)
97556929 =/ sep=tape ?:(printed ", " " where ")
97566930 =/ clause=tape "{sep}{(show-itype [%avar i.vars] ~)} is an atom"
@@ -9759,9 +6933,9 @@
97596933::
97606934:: Build the supported part of the value environment in dependency order.
97616935:: Each pass adds successful definitions. Forward references become
9762−:: available on a later pass; unsupported syntax does not enter the
9763−:: environment. Generalized definitions are closed, so a use instantiates
9764−:: its variables afresh.
6936+:: available on a later pass; mutually recursive groups and unsupported
6937+:: syntax do not enter the environment. Generalized definitions are closed, so a
6938+:: use instantiates its variables afresh.
97656939::
97666940++ global-value-names
97676941 |= ds=(list def)
@@ -9851,8 +7025,6 @@
98517025++ infer-recursive-gate
98527026 |= [d=def env=ienv state=istate]
98537027 ^- iresult
9854− ?^ defer.state [%| ["deferred recursive inference is unsupported" ~]]
9855− =. gate-defs.state ~
98567028 ?. ?=(%value -.d) [%| ["recursive definition is not a gate" ~]]
98577029 ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
98587030 [%| ["recursive definition is not a gate" ~]]
@@ -9864,15 +7036,7 @@
98647036 %gate-wide (infer-sample sample.gate env state)
98657037 * !!
98667038 ==
9867− ?: ?=(%| -.sam)
9868− =/ diag=(unit idiag)
9869− ?- -.gate
9870− %gate (sample-import-invalid sample.gate env state)
9871− %gate-wide (sample-import-invalid sample.gate env state)
9872− * ~
9873− ==
9874− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
9875− [%| [p.sam ~]]
7039+ ?: ?=(%| -.sam) [%| [p.sam ~]]
98767040 =/ id=@ud next.state.p.sam
98777041 =/ product=itype ?~(result [%var id] u.result)
98787042 =/ st=istate state.p.sam(next +(id))
@@ -9890,546 +7054,42 @@
98907054 ?~ uni [%| ["recursive gate constraint is not supported by partial inference" ~]]
98917055 [%& [%fn typ.p.sam typ.p.out] state.p.out(sub u.uni)]
98927056::
9893−++ dependency-root
9894− |= names=(list term)
9895− ^- (list term)
9896− ?~ names ~
9897− ~[(rear names)]
9898−::
9899−++ dependency-exprs
9900− |= xs=(list expr)
9901− ^- (list term)
9902− ?~ xs ~
9903− =/ first=(list term) (dependency-expr i.xs)
9904− (weld first $(xs t.xs))
7057+++ add-supported-defs
7058+ |= [ds=(list def) env=ienv molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile)]
7059+ ^- ienv
7060+ ?~ ds env
7061+ =/ d=def i.ds
7062+ ?: ?=(%mold -.d) $(ds t.ds)
7063+ ?. (unique-value-name name.d globals) $(ds t.ds)
7064+ ?^ (ienv-lookup name.d env) $(ds t.ds)
7065+ =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
7066+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude]
7067+ =/ result=iresult (infer-fragment val.d env initial)
7068+ =? result ?=(%| -.result) (infer-recursive-gate d env initial)
7069+ ?: ?=(%| -.result) $(ds t.ds)
7070+ ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
7071+ =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
7072+ ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
7073+ ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
7074+ =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
7075+ ?: (gth (lent vars) 26) $(ds t.ds)
7076+ $(ds t.ds, env [[name.d [typ vars]] env])
99057077::
9906−++ dependency-pieces
9907− |= xs=(list piece)
9908− ^- (list term)
9909− ?~ xs ~
9910− =/ first=(list term)
9911− ?- -.i.xs
9912− %expr (dependency-expr p.i.xs)
9913− %text ~
9914− ==
9915− (weld first $(xs t.xs))
7078+++ resolve-supported-defs
7079+ |= [ds=(list def) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile)]
7080+ ^- ienv
7081+ =/ env=ienv ~
7082+ |-
7083+ =/ next=ienv (add-supported-defs ds env molds globals externals surs mark-externals marks jimports reserved-molds at prelude)
7084+ ?: =(next env) env
7085+ $(env next)
99167086::
9917−++ dependency-qsegs
9918− |= xs=(list qseg)
9919− ^- (list term)
9920− ?~ xs ~
9921− =/ first=(list term)
9922− ?- -.i.xs
9923− %expr (dependency-expr p.i.xs)
9924− %knot ~
9925− ==
9926− (weld first $(xs t.xs))
7087++| %union-analysis
99277088::
9928−++ dependency-items
9929− |= xs=(list item)
9930− ^- (list term)
9931− ?~ xs ~
9932− =/ first=(list term) (dependency-expr val.i.xs)
9933− (weld first $(xs t.xs))
9934−::
9935−++ dependency-edits
9936− |= xs=(list edit)
9937− ^- (list term)
9938− ?~ xs ~
9939− =/ first=(list term) (dependency-expr val.i.xs)
9940− (weld first $(xs t.xs))
9941−::
9942−++ dependency-arms
9943− |= xs=(list arm)
9944− ^- (list term)
9945− ?~ xs ~
9946− =/ first=(list term) (dependency-expr val.i.xs)
9947− (weld first $(xs t.xs))
9948−::
9949−++ dependency-defs
9950− |= xs=(list def)
9951− ^- (list term)
9952− ?~ xs ~
9953− =/ first=(list term)
9954− ?: ?=(%value -.i.xs) (dependency-expr val.i.xs)
9955− ~
9956− (weld first $(xs t.xs))
9957−::
9958−++ dependency-expr
9959− |= e=expr
9960− ^- (list term)
9961− ?- -.e
9962− %str (dependency-pieces pieces.e)
9963− %qath (dependency-qsegs segs.e)
9964− %wing (dependency-root names.e)
9965− %change
9966− =/ first=(list term) (dependency-root target.e)
9967− =/ last=(list term) (dependency-edits edits.e)
9968− (weld first last)
9969− %pair (dependency-expr val.e)
9970− %unit (dependency-expr val.e)
9971− %group (dependency-expr inner.e)
9972− %list (dependency-exprs items.e)
9973− %tuple (dependency-items items.e)
9974− %gate (dependency-expr body.e)
9975− %gate-wide (dependency-expr body.e)
9976− %call
9977− =/ first=(list term) (dependency-expr head.e)
9978− =/ last=(list term) (dependency-exprs args.e)
9979− (weld first last)
9980− %cast (dependency-expr val.e)
9981− %trace
9982− =/ first=(list term) (dependency-expr val.e)
9983− =/ last=(list term) (dependency-expr then.e)
9984− (weld first last)
9985− %branch
9986− =/ first=(list term) (dependency-expr subject.e)
9987− =/ last=(list term) (dependency-arms arms.e)
9988− (weld first last)
9989− %body
9990− =/ first=(list term) (dependency-defs defs.e)
9991− =/ last=(list term) (dependency-expr final.e)
9992− (weld first last)
9993− * ~
9994− ==
9995−::
9996−:: Infer a cyclic component with one monomorphic seed per gate. All members
9997−:: must succeed before any scheme is available; pending constraints and
9998−:: unresolved branch joins remain partial.
9999−+$ igate-entry [name=term typ=itype body=expr env=ienv caps=icaps]
10000−+$ igate-seeds (each [entries=(list igate-entry) state=istate] idiag)
10001−++ seed-gate-group
10002− |= [ds=(list def) env=ienv state=istate]
10003− ^- igate-seeds
10004− ?~ ds [%& [~ state]]
10005− =/ d=def i.ds
10006− ?. ?=(%value -.d) [%| ["recursive group contains a non-gate" ~]]
10007− =/ gate=expr val.d
10008− ?. |(?=(%gate -.gate) ?=(%gate-wide -.gate))
10009− [%| ["recursive group contains a non-gate" ~]]
10010− =/ initial=istate (reserve-def-caps gate state)
10011− =/ sam=isample-result
10012− ?- -.gate
10013− %gate (infer-sample sample.gate env initial)
10014− %gate-wide (infer-sample sample.gate env initial)
10015− * !!
10016− ==
10017− ?: ?=(%| -.sam) [%| [p.sam ~]]
10018− =/ body=expr
10019− ?- -.gate
10020− %gate body.gate
10021− %gate-wide body.gate
10022− * !!
10023− ==
10024− =/ seed=itype [%fn typ.p.sam [%var next.state.p.sam]]
10025− =/ entry=igate-entry [name.d seed body env.p.sam caps.state.p.sam]
10026− =/ after=istate state.p.sam(next +(next.state.p.sam), caps caps.state)
10027− =/ rest=igate-seeds $(ds t.ds, state after)
10028− ?: ?=(%| -.rest) rest
10029− [%& [[entry entries.p.rest] state.p.rest]]
10030−::
10031−++ group-seed-env
10032− |= [entries=(list igate-entry) env=ienv]
10033− ^- ienv
10034− ?~ entries env
10035− [[name.i.entries [typ.i.entries ~]] $(entries t.entries)]
10036−::
10037−++ infer-gate-group-bodies
10038− |= [entries=(list igate-entry) seeds=ienv state=istate]
10039− ^- igate-seeds
10040− ?~ entries [%& [~ state]]
10041− =/ entry=igate-entry i.entries
10042− ?> ?=(%fn -.typ.entry)
10043− =/ scope=ienv (weld seeds env.entry)
10044− =/ out=iresult (infer-fragment body.entry scope state(caps caps.entry))
10045− ?: ?=(%| -.out) out
10046− =/ uni=(unit isub) (itype-unify product.typ.entry typ.p.out sub.state.p.out)
10047− ?~ uni [%| ["recursive group constraint is not supported by partial inference" ~]]
10048− =. caps.entry caps.state.p.out
10049− =/ after=istate state.p.out(sub u.uni, caps caps.state)
10050− =/ rest=igate-seeds $(entries t.entries, state after)
10051− ?: ?=(%| -.rest) rest
10052− [%& [[entry entries.p.rest] state.p.rest]]
10053−::
10054−++ group-schemes
10055− |= [entries=(list igate-entry) env=ienv outer=istate state=istate]
10056− ^- (each ienv idiag)
10057− ?~ entries [%& ~]
10058− =/ entry=igate-entry i.entries
10059− =/ merged=(unit [first=icap second=icap]) (merged-capitals caps.entry sub.state)
10060− ?^ merged
10061− [%| ["distinct type variables must not be forced equal" ~[[at.first.u.merged "first type variable"] [at.second.u.merged "second type variable"]]]]
10062− ?: (constrained-capitals caps.entry sub.state)
10063− [%| ["explicit capital constraints are not supported by partial inference" ~]]
10064− =/ typ=itype (itype-normalize typ.entry sub.state)
10065− ?: (itype-has-nvar typ) [%| ["recursive group needs unsupported inference" ~]]
10066− ?: |((itype-has-tag typ) (itype-has-hidden-generic typ) (itype-has-hidden-recursive typ) (unsupported-atom-vars typ caps.entry binders.state sub.state))
10067− [%| ["recursive group needs unsupported inference" ~]]
10068− =/ free=(list @ud) (weld (free-env-vars env sub.state) (free-cap-vars caps.outer sub.state))
10069− =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
10070− =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
10071− ?: (gth (lent vars) 26) [%| ["recursive group needs too many type variables" ~]]
10072− =/ rest=(each ienv idiag) $(entries t.entries)
10073− ?: ?=(%| -.rest) rest
10074− [%& [[name.entry [typ vars]] p.rest]]
10075−::
10076−++ infer-gate-group
10077− |= [ds=(list def) env=ienv state=istate]
10078− ^- ilocal-result
10079− ?^ defer.state [%| ["deferred recursive inference is unsupported" ~]]
10080− =/ names=(list term) (global-value-names ds)
10081− ?. (levy names |=(n=term (unique-value-name n names)))
10082− [%| ["recursive group contains duplicate names" ~]]
10083− ?: (lien names |=(n=term ?=(^ (ienv-lookup n env))))
10084− [%| ["recursive group shadows a name" ~]]
10085− =/ scoped=istate state(globals (weld names globals.state), gate-defs ~)
10086− =/ seeded=igate-seeds (seed-gate-group ds env scoped)
10087− ?: ?=(%| -.seeded) seeded
10088− =/ seeds=ienv (group-seed-env entries.p.seeded ~)
10089− =/ body=igate-seeds (infer-gate-group-bodies entries.p.seeded seeds state.p.seeded)
10090− ?: ?=(%| -.body) body
10091− :: Per-member ownership through mutual recursion is not implemented.
10092− ?: !=(projections.state.p.body projections.state)
10093− [%| ["record projection in recursive groups needs unsupported inference" ~]]
10094− ?: !=(holes.state.p.body holes.state)
10095− [%| ["holes in recursive groups need unsupported inference" ~]]
10096− ?: (pending-tags tags.state.p.body sub.state.p.body)
10097− [%| ["recursive group has unresolved literal constraints" ~]]
10098− =/ schemes=(each ienv idiag) (group-schemes entries.p.body env state state.p.body)
10099− ?: ?=(%| -.schemes) schemes
10100− [%& [(weld p.schemes env) state.p.body(globals globals.state)]]
10101−::
10102−++ width-finalize
10103− |= [ps=(list iwprojection) sub=isub visible=(list @ud)]
10104− ^- (unit (list iwprojection))
10105− ?~ ps `~
10106− ?: (lien t.ps |=(p=iwprojection =(at.p at.i.ps))) ~
10107− =/ src=itype (default-decimals (itype-normalize source.i.ps sub))
10108− =/ dst=itype (default-decimals (itype-normalize target.i.ps sub))
10109− ?: |((itype-has-nvar src) (itype-has-nvar dst) (itype-has-tag src) (itype-has-tag dst)) ~
10110− =/ vars=(list @ud) (weld (itype-vars src) (itype-vars dst))
10111− ?. (levy vars |=(n=@ud (lien visible |=(v=@ud =(n v))))) ~
10112− =/ rest=(unit (list iwprojection)) $(ps t.ps)
10113− ?~ rest ~
10114− =/ entry=iwprojection i.ps
10115− =. entry entry(source src, target dst)
10116− `[entry u.rest]
10117−::
10118−++ add-supported-defs
10119− |= [ds=(list def) all-defs=(list def) checked=(map term def) heads=(unit igate-prelude-evidence) env=ienv molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile) artifacts=(list iwidth-definition)]
10120− ^- [env=ienv artifacts=(list iwidth-definition)]
10121− (add-supported-defs-core ds all-defs checked heads env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts ~)
10122−::
10123−
10124−+$ iresolved [env=ienv grouped=(list term) artifacts=(list iwidth-definition)]
10125−+$ iadj (map term (list term))
10126−+$ ivisited (map term ?)
10127−+$ iwork (list [name=term done=?])
10128−+$ iwresult [seen=ivisited order=(list term)]
10129−+$ icresult [seen=ivisited component=(list term)]
10130−+$ icomponents (list (list term))
10131−++ graph-nameset
10132− |= [names=(list term) seen=ivisited]
10133− ^- ivisited
10134− ?~ names seen
10135− $(names t.names, seen (~(put by seen) i.names &))
10136−::
10137−++ graph-edges
10138− |= [name=term graph=iadj]
10139− ^- (list term)
10140− =/ found=(unit (list term)) (~(get by graph) name)
10141− ?~ found ~
10142− u.found
10143−::
10144−++ graph-make-forward
10145− |= [ds=(list def) names=ivisited graph=iadj]
10146− ^- iadj
10147− ?~ ds graph
10148− ?. ?=(%value -.i.ds) $(ds t.ds)
10149− =/ deps=(list term) (dependency-expr val.i.ds)
10150− =. deps (skim deps |=(n=term ?=(^ (~(get by names) n))))
10151− $(ds t.ds, graph (~(put by graph) name.i.ds deps))
10152−::
10153−++ graph-add-reverse
10154− |= [name=term edges=(list term) reverse=iadj]
10155− ^- iadj
10156− ?~ edges reverse
10157− =/ prior=(list term) (graph-edges i.edges reverse)
10158− $(edges t.edges, reverse (~(put by reverse) i.edges [name prior]))
10159−::
10160−++ graph-reverse
10161− |= [names=(list term) graph=iadj reverse=iadj]
10162− ^- iadj
10163− ?~ names reverse
10164− =. reverse (graph-add-reverse i.names (graph-edges i.names graph) reverse)
10165− $(names t.names)
10166−::
10167−++ graph-order
10168− |= [todo=iwork seen=ivisited order=(list term) graph=iadj]
10169− ^- iwresult
10170− ?~ todo [seen order]
10171− =/ event=[name=term done=?] i.todo
10172− ?: done.event $(todo t.todo, order [name.event order])
10173− ?: ?=(^ (~(get by seen) name.event)) $(todo t.todo)
10174− =. seen (~(put by seen) name.event &)
10175− =/ children=iwork (turn (graph-edges name.event graph) |=(n=term [n |]))
10176− $(todo (weld children [[name.event &] t.todo]))
10177−::
10178−++ graph-collect
10179− |= [todo=(list term) seen=ivisited component=(list term) graph=iadj]
10180− ^- icresult
10181− ?~ todo [seen component]
10182− ?: ?=(^ (~(get by seen) i.todo)) $(todo t.todo)
10183− =. seen (~(put by seen) i.todo &)
10184− $(todo (weld (graph-edges i.todo graph) t.todo), component [i.todo component])
10185−::
10186−++ graph-collect-all
10187− |= [order=(list term) seen=ivisited graph=iadj comps=icomponents]
10188− ^- icomponents
10189− ?~ order comps
10190− ?: ?=(^ (~(get by seen) i.order)) $(order t.order)
10191− =/ found=icresult (graph-collect ~[i.order] seen ~ graph)
10192− $(order t.order, seen seen.found, comps [component.found comps])
10193−::
10194−:: Two depth-first passes find components before group inference. Maps
10195−:: preserve the graph identity; duplicate global names fail closed.
10196−++ graph-components
10197− |= [ds=(list def) names=(list term)]
10198− ^- icomponents
10199− =/ nameset=ivisited ~
10200− =/ pending=(list term) names
10201− |-
10202− ?^ pending
10203− ?: ?=(^ (~(get by nameset) i.pending)) ~
10204− $(pending t.pending, nameset (~(put by nameset) i.pending &))
10205− =/ graph=iadj (graph-make-forward ds nameset ~)
10206− =/ reverse=iadj (graph-reverse names graph ~)
10207− =/ order=iwresult (graph-order (turn names |=(n=term [n |])) ~ ~ graph)
10208− (graph-collect-all order.order ~ reverse ~)
10209−::
10210−++ graph-cycle
10211− |= [component=(list term) graph=iadj]
10212− ^- ?
10213− ?~ component |
10214− ?^ t.component &
10215− (lien (graph-edges i.component graph) |=(x=term =(x i.component)))
10216−::
10217−++ add-groups
10218− |= [ds=(list def) components=icomponents graph=iadj env=ienv grouped=(list term) artifacts=(list iwidth-definition) state=istate]
10219− ^- iresolved
10220− ?~ components [env grouped artifacts]
10221− =/ component=(list term) i.components
10222− ?. (graph-cycle component graph) $(components t.components)
10223− ?: (lien component |=(n=term ?=(^ (ienv-lookup n env)))) $(components t.components)
10224− =/ members=(list def)
10225− %+ skim ds
10226− |= d=def
10227− &(?=(%value -.d) (lien component |=(n=term =(n name.d))))
10228− ?. =((lent members) (lent component)) $(components t.components)
10229− ?. (levy component |=(n=term (unique-value-name n globals.state))) $(components t.components)
10230− =/ result=ilocal-result (infer-gate-group members env state)
10231− ?: ?=(%| -.result) $(components t.components)
10232− $(components t.components, env env.p.result, grouped (weld component grouped))
10233−::
10234−++ resolve-groups
10235− |= [ds=(list def) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile)]
10236− ^- iresolved
10237− (resolve-groups-core ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude ~)
10238−::
10239−
10240−+$ iadded-definition
10241− [env=ienv checked=(map term def) artifacts=(list iwidth-definition)]
10242−++ add-supported-result
10243− |= [d=def result=iresult initial=istate env=ienv checked=(map term def) artifacts=(list iwidth-definition)]
10244− ^- (unit iadded-definition)
10245− ?> ?=(%value -.d)
10246− ?: ?=(%| -.result) ~
10247− =. state.p.result (promote-restricted-numbers state.p.result env)
10248− =. state.p.result (default-hole-numbers holes.state.p.result holes.initial state.p.result env !(itype-has-gate (itype-normalize typ.p.result sub.state.p.result)))
10249− ?^ (unresolved-hole holes.state.p.result holes.initial state.p.result) ~
10250− ?: (constrained-capitals caps.state.p.result sub.state.p.result) ~
10251− =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
10252− ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) ~
10253− ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) ~
10254− =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
10255− ?: (gth (lent vars) 26) ~
10256− =/ finalized=(unit (list iwprojection))
10257− (width-finalize projections.state.p.result sub.state.p.result vars)
10258− ?~ finalized ~
10259− =? artifacts ?=(^ u.finalized)
10260− [[name.d val.d typ sub.state.p.result (flop u.finalized)] artifacts]
10261− =? checked |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) (~(put by checked) name.d d)
10262− `[[[name.d [typ vars]] env] checked artifacts]
10263−++ add-supported-defs-core
10264− |= [ds=(list def) all-defs=(list def) checked=(map term def) heads=(unit igate-prelude-evidence) env=ienv molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile) artifacts=(list iwidth-definition) index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])]
10265− ^- [env=ienv artifacts=(list iwidth-definition)]
10266− ?~ ds [env artifacts]
10267− =/ d=def i.ds
10268− ?: ?=(%mold -.d) $(ds t.ds)
10269− ?. (unique-value-name name.d globals) $(ds t.ds)
10270− ?^ (ienv-lookup name.d env) $(ds t.ds)
10271− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10272− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~ ~ ~]
10273− =. grec-index.initial index
10274− =. gate-defs.initial checked
10275− =. head-evidence.initial heads
10276− =. initial (reserve-def-caps val.d initial)
10277− =/ result=iresult (infer-fragment val.d env initial)
10278− =? result ?=(%| -.result) (infer-recursive-gate d env initial)
10279− =/ added=(unit iadded-definition)
10280− (add-supported-result d result initial env checked artifacts)
10281− ?~ added $(ds t.ds)
10282− $(ds t.ds, env env.u.added, checked checked.u.added, artifacts artifacts.u.added)
10283−::
10284−++ resolve-groups-core
10285− |= [ds=(list def) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile) index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])]
10286− ^- iresolved
10287− =/ env=ienv ~
10288− =/ grouped=(list term) ~
10289− =/ artifacts=(list iwidth-definition) ~
10290− =/ names=(list term) (global-value-names ds)
10291− =/ nameset=ivisited (graph-nameset names ~)
10292− =/ graph=iadj (graph-make-forward ds nameset ~)
10293− =/ components=icomponents (graph-components ds names)
10294− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10295− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude)
10296− |-
10297− =/ next=[env=ienv artifacts=(list iwidth-definition)]
10298− (add-supported-defs-core ds ds (direct-checked-gates ds env) heads env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts index)
10299− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~ ~ ~]
10300− =. grec-index.initial index
10301− =/ out=iresolved (add-groups ds components graph env.next grouped artifacts.next initial)
10302− ?: =(env env.out) out
10303− $(env env.out, grouped grouped.out, artifacts artifacts.out)
10304−::
10305−++ resolve-supported-defs
10306− |= [ds=(list def) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile)]
10307− ^- ienv
10308− env:(resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude)
10309−::
10310−:: A diagnostic-only proof for a narrow syntactic value cycle. Every
10311−:: edge is an unqualified wing in a supported expression, and samples
10312−:: may not shadow global bindings. Unknown forms yield no conclusion.
10313−+$ icyclesite [name=term at=span]
10314−+$ icycle [name=term first=span next=span]
10315−++ cycle-sites-list
10316− |= [xs=(list expr) globals=(list term) locals=(list term)]
10317− ^- (unit (list icyclesite))
10318− ?~ xs `~
10319− =/ first=(unit (list icyclesite)) (cycle-sites i.xs globals locals)
10320− ?~ first ~
10321− =/ tail=(unit (list icyclesite)) $(xs t.xs)
10322− ?~ tail ~
10323− `(weld u.first u.tail)
10324−::
10325−++ cycle-sample-name
10326− |= [sam=sample globals=(list term) locals=(list term)]
10327− ^- (unit (unit term))
10328− ?- -.sam
10329− %bind
10330− ?: (lien (weld globals locals) |=(n=term =(n name.sam))) ~
10331− ``name.sam
10332− %face
10333− ?: (lien (weld globals locals) |=(n=term =(n name.sam))) ~
10334− ``name.sam
10335− %bare `~
10336− * ~
10337− ==
10338−::
10339−++ cycle-sites
10340− |= [e=expr globals=(list term) locals=(list term)]
10341− ^- (unit (list icyclesite))
10342− ?- -.e
10343− %wing
10344− ?. ?=([@ ~] names.e) ~
10345− `~[[i.names.e at.e]]
10346− %lit `~
10347− %str
10348− ?: (lien pieces.e |=(p=piece ?=(%expr -.p))) ~
10349− `~
10350− %group $(e inner.e)
10351− %body ?~(defs.e $(e final.e) ~)
10352− %cast $(e val.e)
10353− %gate
10354− =/ binder=(unit (unit term)) (cycle-sample-name sample.e globals locals)
10355− ?~ binder ~
10356− =/ nested=(list term) ?~(u.binder locals [u.u.binder locals])
10357− $(e body.e, locals nested)
10358− %gate-wide
10359− =/ binder=(unit (unit term)) (cycle-sample-name sample.e globals locals)
10360− ?~ binder ~
10361− =/ nested=(list term) ?~(u.binder locals [u.u.binder locals])
10362− $(e body.e, locals nested)
10363− %call
10364− =/ first=(unit (list icyclesite)) $(e head.e)
10365− ?~ first ~
10366− =/ tail=(unit (list icyclesite)) (cycle-sites-list args.e globals locals)
10367− ?~ tail ~
10368− `(weld u.first u.tail)
10369− * ~
10370− ==
10371−::
10372−++ cycle-definitely-atom
10373− |= e=expr
10374− ^- ?
10375− ?: ?=(%group -.e) $(e inner.e)
10376− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
10377− ?. ?=(%cast -.e) |
10378− |(?=(%aura -.shape.e) ?=(%flag -.shape.e))
10379−::
10380−++ cycle-proof-group
10381− |= [members=(list def) globals=(list term)]
10382− ^- ?
10383− ?~ members &
10384− ?. ?=(%value -.i.members) |
10385− ?. (unique-value-name name.i.members globals) |
10386− ?. ?=(^ (cycle-sites val.i.members globals ~)) |
10387− $(members t.members)
10388−::
10389−++ cycle-find-site
10390− |= [sites=(list icyclesite) component=(list term)]
10391− ^- (unit span)
10392− ?~ sites ~
10393− ?: (lien component |=(n=term =(n name.i.sites))) `at.i.sites
10394− $(sites t.sites)
10395−::
10396−++ cycle-group-errors
10397− |= [members=(list def) component=(list term) globals=(list term)]
10398− ^- (list icycle)
10399− ?~ members ~
10400− =/ d=def i.members
10401− ?> ?=(%value -.d)
10402− =/ tail=(list icycle) $(members t.members)
10403− ?. (cycle-definitely-atom val.d) tail
10404− =/ sites=(unit (list icyclesite)) (cycle-sites val.d globals ~)
10405− ?~ sites tail
10406− =/ found=(unit span) (cycle-find-site u.sites component)
10407− ?~ found tail
10408− [[name.d at.d u.found] tail]
10409−::
10410−++ definite-value-cycles
10411− |= [ds=(list def) globals=(list term)]
10412− ^- (list icycle)
10413− =/ names=(list term) (global-value-names ds)
10414− =/ graph=iadj (graph-make-forward ds (graph-nameset names ~) ~)
10415− =/ components=icomponents (graph-components ds names)
10416− =/ out=(list icycle) ~
10417− |-
10418− ?~ components out
10419− =/ component=(list term) i.components
10420− ?. (graph-cycle component graph) $(components t.components)
10421− =/ members=(list def)
10422− (skim ds |=(d=def &(?=(%value -.d) (lien component |=(n=term =(n name.d))))))
10423− ?. =((lent members) (lent component)) $(components t.components)
10424− ?. (cycle-proof-group members globals) $(components t.components)
10425− $(components t.components, out (weld (cycle-group-errors members component globals) out))
10426−::
10427−+| %union-analysis
10428−::
10429−:: A conservative projection of written molds onto noun shapes. The
10430−:: result %unknown never establishes either overlap or disjointness.
10431−:: Gates, applications, imports and recursive references stay unknown;
10432−:: another position in a cell may nevertheless prove two cases apart.
7089+:: A conservative projection of written molds onto noun shapes. The
7090+:: result %unknown never establishes either overlap or disjointness.
7091+:: Gates, applications, imports and recursive references stay unknown;
7092+:: another position in a cell may nevertheless prove two cases apart.
104337093::
104347094+$ upat
104357095 $~ [%unknown ~]
@@ -10546,257 +7206,6 @@
105467206 %overlap
105477207 %unknown
105487208::
10549−:: A source-only fallback for literal-tagged cells and one-hop local
10550−:: generic applications. It screens all work before ordinary inference.
10551−++ union-simple-shape-budget
10552− |= [s=shape fuel=@ud vars=(unit (list @t))]
10553− ^- (unit @ud)
10554− ?: =(0 fuel) ~
10555− =. fuel (dec fuel)
10556− ?- -.s
10557− ?(%aura %noun %void %flag) `fuel
10558− %tvar
10559− ?~ vars `fuel
10560− ?:((lien u.vars |=(n=@t =(n name.s))) `fuel ~)
10561− %const
10562− ?. |(=(%term form.lit.s) =(%null form.lit.s) =(%loobean form.lit.s)) ~
10563− ?: &(=(%loobean form.lit.s) !|(=(0 val.lit.s) =(1 val.lit.s))) ~
10564− `fuel
10565− %cell (union-simple-fields-budget fields.s fuel vars)
10566− %fn
10567− =/ left=(unit @ud) $(s sample.s, fuel fuel)
10568− ?~ left ~
10569− $(s product.s, fuel u.left)
10570− * ~
10571− ==
10572−++ union-simple-fields-budget
10573− |= [fields=(list field) fuel=@ud vars=(unit (list @t))]
10574− ^- (unit @ud)
10575− ?~ fields `fuel
10576− ?: =(0 fuel) ~
10577− =/ field-shape=shape
10578− ?- -.i.fields
10579− %bare shape.i.fields
10580− %face shape.i.fields
10581− %pun [%ref at.i.fields ~[name.i.fields]]
10582− ==
10583− =/ head=(unit @ud) (union-simple-shape-budget field-shape (dec fuel) vars)
10584− ?~ head ~
10585− $(fields t.fields, fuel u.head)
10586−++ union-source-find
10587− |= [n=term molds=imolds fuel=@ud]
10588− ^- (unit [body=shape left=@ud])
10589− =/ found=(unit shape) ~
10590− |-
10591− ?~ molds
10592− ?~ found ~
10593− `[u.found fuel]
10594− ?: =(0 fuel) ~
10595− ?: =(n name.i.molds)
10596− ?^ found ~
10597− $(molds t.molds, fuel (dec fuel), found `body.i.molds)
10598− $(molds t.molds, fuel (dec fuel))
10599−++ union-source-args-budget
10600− |= [vars=(list @t) args=(list shape) fuel=@ud]
10601− ^- (unit @ud)
10602− =/ seen=(set @t) *(set @t)
10603− |-
10604− ?~ vars ?~(args `fuel ~)
10605− ?~ args ~
10606− ?: =(0 fuel) ~
10607− ?: (~(has in:..zuse seen) i.vars) ~
10608− =/ arg=(unit @ud) (union-simple-shape-budget i.args (dec fuel) ~)
10609− ?~ arg ~
10610− $(vars t.vars, args t.args, fuel u.arg, seen (~(put in:..zuse seen) i.vars))
10611−++ union-source-cell-tag
10612− |= s=shape
10613− ^- (unit @)
10614− ?. ?=(%cell -.s) ~
10615− ?~ fields.s ~
10616− ?~ t.fields.s ~
10617− ?. ?=(%bare -.i.fields.s) ~
10618− =/ head=shape shape.i.fields.s
10619− ?. ?=(%const -.head) ~
10620− ?. |(=(%term form.lit.head) =(%null form.lit.head) =(%loobean form.lit.head)) ~
10621− ?: &(=(%loobean form.lit.head) !|(=(0 val.lit.head) =(1 val.lit.head))) ~
10622− `val.lit.head
10623−++ union-source-case-tag
10624− |= [s=shape molds=imolds fuel=@ud]
10625− ^- (unit [tag=@ left=@ud])
10626− ?: ?=(%cell -.s)
10627− =/ tag=(unit @) (union-source-cell-tag s)
10628− ?~ tag ~
10629− =/ left=(unit @ud) (union-simple-shape-budget s fuel ~)
10630− ?~ left ~
10631− `[u.tag u.left]
10632− ?. ?=(%apply -.s) ~
10633− ?. ?=([@ ~] ref.s) ~
10634− ?: =(0 fuel) ~
10635− =/ found=(unit [body=shape left=@ud]) (union-source-find i.ref.s molds (dec fuel))
10636− ?~ found ~
10637− ?. ?=(%generic -.body.u.found) ~
10638− ?~ vars.body.u.found ~
10639− =/ tag=(unit @) (union-source-cell-tag body.body.u.found)
10640− ?~ tag ~
10641− =/ args=(unit @ud) (union-source-args-budget vars.body.u.found args.s left.u.found)
10642− ?~ args ~
10643− =/ left=(unit @ud) (union-simple-shape-budget body.body.u.found u.args `vars.body.u.found)
10644− ?~ left ~
10645− `[u.tag u.left]
10646−++ union-source-distinct-tags
10647− |= [cases=(list shape) molds=imolds fuel=@ud]
10648− ^- ?
10649− =/ seen=(set @) *(set @)
10650− =/ has-application=? |
10651− |-
10652− ?~ cases has-application
10653− ?: =(0 fuel) |
10654− =/ item=(unit [tag=@ left=@ud]) (union-source-case-tag i.cases molds (dec fuel))
10655− ?~ item |
10656− ?: (~(has in:..zuse seen) tag.u.item) |
10657− $(cases t.cases, fuel left.u.item, seen (~(put in:..zuse seen) tag.u.item), has-application |(has-application ?=(%apply -.i.cases)))
10658−::
10659−:: This inference-only screen bounds inherited work that the small source
10660−:: slice may consult. It does not authenticate a caller-created state.
10661−++ union-state-leaf
10662− |= t=itype
10663− ^- ?
10664− ?=(?(%var %avar %rvar %nvar %rnvar %atom %any-atom %flag %noun %empty %const) -.t)
10665−++ union-state-params-budget
10666− |= [params=iparams fuel=@ud]
10667− ^- (unit @ud)
10668− ?~ params `fuel
10669− ?: =(0 fuel) ~
10670− ?. (union-state-leaf typ.i.params) ~
10671− $(params t.params, fuel (dec fuel))
10672−++ union-state-sub-budget
10673− |= [sub=isub fuel=@ud]
10674− ^- (unit @ud)
10675− ?~ sub `fuel
10676− ?: =(0 fuel) ~
10677− ?. (union-state-leaf val.i.sub) ~
10678− $(sub t.sub, fuel (dec fuel))
10679−++ union-state-caps-budget
10680− |= [caps=icaps fuel=@ud]
10681− ^- (unit @ud)
10682− ?~ caps `fuel
10683− ?: =(0 fuel) ~
10684− $(caps t.caps, fuel (dec fuel))
10685−++ union-state-active-budget
10686− |= [active=(list term) fuel=@ud]
10687− ^- (unit @ud)
10688− ?~ active `fuel
10689− ?: =(0 fuel) ~
10690− $(active t.active, fuel (dec fuel))
10691−++ union-state-tags-budget
10692− |= [tags=(list ipending) fuel=@ud]
10693− ^- (unit @ud)
10694− ?~ tags `fuel
10695− ?: =(0 fuel) ~
10696− $(tags t.tags, fuel (dec fuel))
10697−++ union-source-state-safe
10698− |= [state=istate fuel=@ud]
10699− ^- ?
10700− ?^ grec-index.state |
10701− ?^ holes.state |
10702− ?^ defer.state |
10703− ?^ obligations.state |
10704− =/ params=(unit @ud) (union-state-params-budget params.state fuel)
10705− ?~ params |
10706− =/ sub=(unit @ud) (union-state-sub-budget sub.state u.params)
10707− ?~ sub |
10708− =/ caps=(unit @ud) (union-state-caps-budget caps.state u.sub)
10709− ?~ caps |
10710− =/ active=(unit @ud) (union-state-active-budget active.state u.caps)
10711− ?~ active |
10712− ?=(^ (union-state-tags-budget tags.state u.active))
10713−::
10714−:: Positive overlap witnesses from parsed, one-hop local source only.
10715−:: Unknown or exhausted work returns no witness, never disjointness.
10716−+$ uow-case [at=span head=@ payload=upat]
10717−++ union-overlap-primitive
10718− |= s=shape
10719− ^- (unit upat)
10720− ?- -.s
10721− %aura `[%atom ~]
10722− %noun `[%all ~]
10723− %void `[%empty ~]
10724− %flag `[%flag ~]
10725− %const
10726− ?. |(=(%term form.lit.s) =(%null form.lit.s) =(%loobean form.lit.s)) ~
10727− ?: &(=(%loobean form.lit.s) !|(=(0 val.lit.s) =(1 val.lit.s))) ~
10728− `[%atom `val.lit.s]
10729− * ~
10730− ==
10731−++ union-overlap-case
10732− |= [s=shape molds=imolds fuel=@ud]
10733− ^- (unit [item=uow-case left=@ud])
10734− ?: =(0 fuel) ~
10735− =. fuel (dec fuel)
10736− :: Each body has exactly two fields; an application has exactly one
10737− :: parameter and one concrete primitive argument. The full mold table
10738− :: is scanned to establish unique ownership.
10739− =/ expanded=(unit [body=shape param=(unit [name=@t pat=upat]) left=@ud])
10740− ?: ?=(%cell -.s) `[s ~ fuel]
10741− ?. ?=(%apply -.s) ~
10742− ?. ?=([@ ~] ref.s) ~
10743− ?. ?=([* ~] args.s) ~
10744− ?: =(0 fuel) ~
10745− =/ found=(unit [body=shape left=@ud]) (union-source-find i.ref.s molds (dec fuel))
10746− ?~ found ~
10747− ?. ?=(%generic -.body.u.found) ~
10748− ?. ?=([@ ~] vars.body.u.found) ~
10749− ?: =(0 left.u.found) ~
10750− =/ argument=(unit upat) (union-overlap-primitive i.args.s)
10751− ?~ argument ~
10752− `[body.body.u.found `[i.vars.body.u.found u.argument] (dec left.u.found)]
10753− ?~ expanded ~
10754− =/ body=shape body.u.expanded
10755− ?. ?=(%cell -.body) ~
10756− ?. ?=([* * ~] fields.body) ~
10757− :: Charge the cell, two fields, and the head and payload nodes.
10758− ?: (lth left.u.expanded 5) ~
10759− =/ head=(unit @) (union-source-cell-tag body)
10760− ?~ head ~
10761− =/ field=field i.t.fields.body
10762− =/ payload=shape
10763− ?- -.field
10764− %bare shape.field
10765− %face shape.field
10766− %pun [%ref at.field ~[name.field]]
10767− ==
10768− =/ pattern=(unit upat)
10769− ?: ?=(%tvar -.payload)
10770− ?~ param.u.expanded ~
10771− ?. =(name.payload name.u.param.u.expanded) ~
10772− `pat.u.param.u.expanded
10773− (union-overlap-primitive payload)
10774− ?~ pattern ~
10775− `[[at.s u.head u.pattern] (sub left.u.expanded 5)]
10776−++ union-overlap-against
10777− |= [first=uow-case rest=(list shape) molds=imolds fuel=@ud]
10778− ^- (unit [witness=(unit upair) left=@ud])
10779− ?~ rest `[~ fuel]
10780− ?: =(0 fuel) ~
10781− =/ other=(unit [item=uow-case left=@ud]) (union-overlap-case i.rest molds (dec fuel))
10782− ?~ other ~
10783− ?: &(=(head.first head.item.u.other) =(%overlap (union-relate payload.first payload.item.u.other)))
10784− `[`[at.first at.item.u.other %overlap] left.u.other]
10785− $(rest t.rest, fuel left.u.other)
10786−++ union-source-overlap
10787− |= [cases=(list shape) molds=imolds fuel=@ud]
10788− ^- (unit upair)
10789− ?~ cases ~
10790− ?~ t.cases ~
10791− ?: =(0 fuel) ~
10792− =/ first=(unit [item=uow-case left=@ud]) (union-overlap-case i.cases molds (dec fuel))
10793− ?~ first ~
10794− =/ found=(unit [witness=(unit upair) left=@ud])
10795− (union-overlap-against item.u.first t.cases molds left.u.first)
10796− ?~ found ~
10797− ?^ witness.u.found witness.u.found
10798− $(cases t.cases, fuel left.u.found)
10799−::
108007209++ union-pairs
108017210 |= [cases=(list shape) molds=imolds]
108027211 ^- (list upair)
@@ -10810,151 +7219,15 @@
108107219 [at.first at.second (union-relate a (project-union-mold second molds ~))]
108117220 (weld pairs $(cases t.cases))
108127221::
10813−:: A closed structural mold supplies no equation to determine a hole.
10814−:: Applications, references, unbound capitals and unions are unproved.
10815−++ simple-mold-hole
10816− |= sh=shape
10817− ^- (unit (unit span))
10818− ?: ?=(%generic -.sh)
10819− ?~ vars.sh ~
10820− ?. (distinct-params vars.sh) ~
10821− (simple-mold-hole-in body.sh vars.sh)
10822− (simple-mold-hole-in sh ~)
10823−++ simple-mold-hole-in
10824− |= [sh=shape vars=(list @t)]
10825− ^- (unit (unit span))
10826− ?- -.sh
10827− %hole ``at.sh
10828− ?(%aura %noun %void %flag %const) `~
10829− %tvar ?:((lien vars |=(v=@t =(v name.sh))) `~ ~)
10830− %cell (simple-mold-field-holes fields.sh vars)
10831− %fn
10832− =/ a=(unit (unit span)) $(sh sample.sh)
10833− ?~ a ~
10834− =/ b=(unit (unit span)) $(sh product.sh)
10835− ?~ b ~
10836− `?~(u.a u.b u.a)
10837− %generic ~
10838− * ~
10839− ==
10840−++ simple-mold-field-holes
10841− |= [fields=(list field) vars=(list @t)]
10842− ^- (unit (unit span))
10843− ?~ fields `~
10844− =/ f=field i.fields
10845− =/ first=(unit (unit span))
10846− ?- -.f
10847− %face (simple-mold-hole-in shape.f vars)
10848− %bare (simple-mold-hole-in shape.f vars)
10849− %pun ~
10850− ==
10851− ?~ first ~
10852− =/ rest=(unit (unit span)) $(fields t.fields)
10853− ?~ rest ~
10854− `?~(u.first u.rest u.first)
10855−++ simple-local-mold-hole
10856− |= defs=(list def)
10857− ^- (unit span)
10858− ?~ defs ~
10859− ?. ?=(%mold -.i.defs) $(defs t.defs)
10860− =/ found=(unit (unit span)) (simple-mold-hole shape.i.defs)
10861− ?~ found $(defs t.defs)
10862− ?^ u.found u.found
10863− $(defs t.defs)
10864−::
10865−:: A partial prelude may omit unsupported declarations, but may not
10866−:: publish an interface while a named mold's hole remains unchecked.
10867−++ shape-has-hole
10868− |= sh=shape
10869− ^- ?
10870− ?- -.sh
10871− %hole &
10872− %path (lien segs.sh |=(s=pseg ?=(%inferred -.s)))
10873− %apply (lien args.sh shape-has-hole)
10874− %union (lien cases.sh shape-has-hole)
10875− %cell (lien fields.sh field-has-hole)
10876− %fn |($(sh sample.sh) $(sh product.sh))
10877− %generic $(sh body.sh)
10878− * |
10879− ==
10880−++ field-has-hole
10881− |= f=field
10882− ^- ?
10883− ?- -.f
10884− %face (shape-has-hole shape.f)
10885− %bare (shape-has-hole shape.f)
10886− %pun |
10887− ==
10888−++ named-mold-has-hole
10889− |= ds=(list def)
10890− ^- ?
10891− ?~ ds |
10892− ?: &(?=(%mold -.i.ds) (shape-has-hole shape.i.ds)) &
10893− $(ds t.ds)
10894−::
10895−++ sample-has-hole
10896− |= sam=sample
10897− ^- ?
10898− ?- -.sam
10899− %face (shape-has-hole shape.sam)
10900− %bare (shape-has-hole shape.sam)
10901− %cell (lien items.sam sample-has-hole)
10902− * |
10903− ==
10904−++ def-has-hole
10905− |= d=def
10906− ^- ?
10907− ?- -.d
10908− %mold (shape-has-hole shape.d)
10909− %value (expr-has-hole val.d)
10910− ==
10911−++ expr-has-hole
10912− |= e=expr
10913− ^- ?
10914− ?- -.e
10915− %str (lien pieces.e |=(p=piece ?:(?=(%expr -.p) (expr-has-hole p.p) |)))
10916− %qath (lien segs.e |=(p=qseg ?:(?=(%expr -.p) (expr-has-hole p.p) |)))
10917− %change (lien edits.e |=(p=edit (expr-has-hole val.p)))
10918− %pair $(e val.e)
10919− %unit $(e val.e)
10920− %group $(e inner.e)
10921− %list (lien items.e expr-has-hole)
10922− %tuple (lien items.e |=(i=item (expr-has-hole val.i)))
10923− ?(%gate %gate-wide) |((sample-has-hole sample.e) $(e body.e))
10924− %cast |((shape-has-hole shape.e) $(e val.e))
10925− %call |($(e head.e) (lien args.e expr-has-hole))
10926− %trace |($(e val.e) $(e then.e))
10927− %branch |($(e subject.e) (lien arms.e |=(a=arm (expr-has-hole val.a))))
10928− %body |((lien defs.e def-has-hole) $(e final.e))
10929− * |
10930− ==
10931−++ hole-values-present
10932− |= [ds=(list def) env=ienv]
10933− ^- ?
10934− ?~ ds &
10935− ?. ?=(%value -.i.ds) $(ds t.ds)
10936− ?: (expr-has-hole val.i.ds)
10937− ?. ?=(^ (ienv-lookup name.i.ds env)) |
10938− $(ds t.ds)
10939− $(ds t.ds)
109407222++ show-partial-mold
109417223 |= [file=path src=@t d=def molds=imolds]
109427224 ^- @t
109437225 ?> ?=(%mold -.d)
109447226 =/ sh=shape shape.d
10945− =/ hole=(unit (unit span)) (simple-mold-hole sh)
10946− ?: &(?=(^ hole) ?=(^ u.hole))
10947− =/ text=@t (show-error src [file line.beg.u.u.hole col.beg.u.u.hole "unresolved type hole"])
10948− (of-wain:format ~[(crip "+$ {(trip name.d)}: type hole needs a determined type") text])
109497227 =? sh ?=(%generic -.sh) body.sh
109507228 ?. ?=(%union -.sh) (crip "+$ {(trip name.d)}: not checked")
109517229 =/ pairs=(list upair) (union-pairs cases.sh molds)
109527230 =/ overlapping=(list upair) (skim pairs |=(p=upair =(%overlap relation.p)))
10953− =. overlapping
10954− ?^ overlapping overlapping
10955− ?. (lien pairs |=(p=upair =(%unknown relation.p))) ~
10956− =/ witness=(unit upair) (union-source-overlap cases.sh molds 256)
10957− ?~(witness ~ ~[u.witness])
109587231 ?^ overlapping
109597232 =/ p=upair i.overlapping
109607233 =/ summary=@t (crip "+$ {(trip name.d)}: overlapping cases; mold not checked")
@@ -10962,9 +7235,7 @@
109627235 =/ second=@t (show-error src [file line.beg.second.p col.beg.second.p "overlapping case"])
109637236 (of-wain:format ~[summary first second])
109647237 ?: (lien pairs |=(p=upair =(%unknown relation.p)))
10965− ?. (union-source-distinct-tags cases.sh molds 256)
10966− (crip "+$ {(trip name.d)}: case disjointness unresolved; mold not checked")
10967− (crip "+$ {(trip name.d)}: cases proven disjoint; mold not checked")
7238+ (crip "+$ {(trip name.d)}: case disjointness unresolved; mold not checked")
109687239 (crip "+$ {(trip name.d)}: cases proven disjoint; mold not checked")
109697240::
109707241:: +show-inference-diagnostic: a partial report with both source sites
@@ -10979,21 +7250,6 @@
109797250 (show-error src [file line.beg.at.site col.beg.at.site note.site])
109807251 (of-wain:format [summary excerpts])
109817252::
10982−:: Both written field sites are shown in the source that declares them.
10983−++ show-duplicate-fields
10984− |= [file=path src=@t diagnostic=idiag]
10985− ^- @t
10986− =/ excerpts=(list @t)
10987− %+ turn sites.diagnostic
10988− |= site=[at=span note=tape]
10989− (show-error src [file line.beg.at.site col.beg.at.site note.site])
10990− (of-wain:format [(crip msg.diagnostic) excerpts])
10991−::
10992−++ duplicate-fields-report
10993− |= [file=path src=@t diagnostic=idiag]
10994− ^- @t
10995− (of-wain:format ~['partial inference; module not checked' (show-duplicate-fields file src diagnostic)])
10996−::
109977253:: +golden-types: a partial report; it does not claim the module checks
109987254::
109997255++ golden-types
@@ -11021,189 +7277,8 @@
110217277+$ jbundle (list jsource)
110227278+$ jcache (list [at=path iface=ifile])
110237279+$ jfile-result (each [iface=ifile cache=jcache] @t)
11024−:: Overlap evidence retains the exact source that supplied its spans.
11025−:: Ordinary Jibb imports preserve this evidence through the resolver.
11026−+$ jfile-overlap [file=path source=@t name=term cases=upair]
11027−+$ jfile-failure [message=@t overlap=(unit jfile-overlap)]
11028−+$ jfile-detailed-result (each [iface=ifile cache=jcache] jfile-failure)
110297280+$ jimports-result (each [resolved=ijimports cache=jcache] @t)
11030−:: Preserve an imported overlap's original file and source across the graph.
11031−+$ jimports-detailed-result (each [resolved=ijimports cache=jcache] jfile-failure)
11032−::
11033−:: Written record fields each have their own lexical record scope.
11034−+$ written-fields (map term span)
11035−++ duplicate-written-field
11036− |= [name=term at=span seen=written-fields]
11037− ^- (unit idiag)
11038− =/ prior=(unit span) (~(get by seen) name)
11039− ?~ prior ~
11040− `["record field `{(trip name)}` is repeated" ~[[u.prior "first field"] [at "repeated field"]]]
11041−++ duplicate-shapes
11042− |= xs=(list shape)
11043− ^- (unit idiag)
11044− ?~ xs ~
11045− =/ first (duplicate-shape i.xs)
11046− ?^ first first
11047− $(xs t.xs)
11048−++ duplicate-fields
11049− |= [fields=(list field) seen=written-fields]
11050− ^- (unit idiag)
11051− ?~ fields ~
11052− =/ f=field i.fields
11053− =/ n=(unit term)
11054− ?- -.f
11055− %face `name.f
11056− %pun `name.f
11057− %bare ~
11058− ==
11059− =/ dup=(unit idiag) ?~(n ~ (duplicate-written-field u.n at.f seen))
11060− ?^ dup dup
11061− =/ inner=(unit idiag)
11062− ?- -.f
11063− %face (duplicate-shape shape.f)
11064− %pun ~
11065− %bare (duplicate-shape shape.f)
11066− ==
11067− ?^ inner inner
11068− $(fields t.fields, seen ?~(n seen (~(put by seen) u.n at.f)))
11069−++ duplicate-shape
11070− |= s=shape
11071− ^- (unit idiag)
11072− ?- -.s
11073− %cell (duplicate-fields fields.s ~)
11074− %apply (duplicate-shapes args.s)
11075− %union (duplicate-shapes cases.s)
11076− %fn
11077− =/ left (duplicate-shape sample.s)
11078− ?^ left left
11079− (duplicate-shape product.s)
11080− %generic (duplicate-shape body.s)
11081− * ~
11082− ==
11083−++ duplicate-samples
11084− |= [items=(list sample) seen=written-fields]
11085− ^- (unit idiag)
11086− ?~ items ~
11087− =/ a=sample i.items
11088− =/ n=(unit term)
11089− ?- -.a
11090− %bind `name.a
11091− %face `name.a
11092− %pun `name.a
11093− * ~
11094− ==
11095− =/ dup=(unit idiag) ?~(n ~ (duplicate-written-field u.n at.a seen))
11096− ?^ dup dup
11097− =/ inner (duplicate-sample a)
11098− ?^ inner inner
11099− $(items t.items, seen ?~(n seen (~(put by seen) u.n at.a)))
11100−++ duplicate-sample
11101− |= s=sample
11102− ^- (unit idiag)
11103− ?- -.s
11104− %cell (duplicate-samples items.s ~)
11105− %face (duplicate-shape shape.s)
11106− %bare (duplicate-shape shape.s)
11107− * ~
11108− ==
11109−++ duplicate-exprs
11110− |= xs=(list expr)
11111− ^- (unit idiag)
11112− ?~ xs ~
11113− =/ first (duplicate-expr i.xs)
11114− ?^ first first
11115− $(xs t.xs)
11116−++ duplicate-items
11117− |= [items=(list item) seen=written-fields]
11118− ^- (unit idiag)
11119− ?~ items ~
11120− =/ a=item i.items
11121− =/ dup=(unit idiag) ?~(face.a ~ (duplicate-written-field u.face.a at.a seen))
11122− ?^ dup dup
11123− =/ inner (duplicate-expr val.a)
11124− ?^ inner inner
11125− $(items t.items, seen ?~(face.a seen (~(put by seen) u.face.a at.a)))
11126−++ duplicate-pieces
11127− |= pieces=(list piece)
11128− ^- (unit idiag)
11129− ?~ pieces ~
11130− =/ first=(unit idiag) ?:(?=(%expr -.i.pieces) (duplicate-expr p.i.pieces) ~)
11131− ?^ first first
11132− $(pieces t.pieces)
11133−++ duplicate-qsegs
11134− |= segs=(list qseg)
11135− ^- (unit idiag)
11136− ?~ segs ~
11137− =/ first=(unit idiag) ?:(?=(%expr -.i.segs) (duplicate-expr p.i.segs) ~)
11138− ?^ first first
11139− $(segs t.segs)
11140−++ duplicate-edits
11141− |= edits=(list edit)
11142− ^- (unit idiag)
11143− ?~ edits ~
11144− =/ first (duplicate-expr val.i.edits)
11145− ?^ first first
11146− $(edits t.edits)
11147−++ duplicate-arms
11148− |= arms=(list arm)
11149− ^- (unit idiag)
11150− ?~ arms ~
11151− =/ first (duplicate-expr val.i.arms)
11152− ?^ first first
11153− $(arms t.arms)
11154−++ duplicate-defs
11155− |= defs=(list def)
11156− ^- (unit idiag)
11157− ?~ defs ~
11158− =/ first=(unit idiag)
11159− ?- -.i.defs
11160− %mold (duplicate-shape shape.i.defs)
11161− %value (duplicate-expr val.i.defs)
11162− ==
11163− ?^ first first
11164− $(defs t.defs)
11165−++ duplicate-expr
11166− |= e=expr
11167− ^- (unit idiag)
11168− ?- -.e
11169− %str (duplicate-pieces pieces.e)
11170− %qath (duplicate-qsegs segs.e)
11171− %change (duplicate-edits edits.e)
11172− %pair (duplicate-expr val.e)
11173− %unit (duplicate-expr val.e)
11174− %group (duplicate-expr inner.e)
11175− %list (duplicate-exprs items.e)
11176− %tuple (duplicate-items items.e ~)
11177− %gate-wide
11178− =/ first (duplicate-sample sample.e)
11179− ?^ first first
11180− (duplicate-expr body.e)
11181− %gate
11182− =/ first (duplicate-sample sample.e)
11183− ?^ first first
11184− (duplicate-expr body.e)
11185− %cast
11186− =/ first (duplicate-shape shape.e)
11187− ?^ first first
11188− (duplicate-expr val.e)
11189− %call
11190− =/ first (duplicate-expr head.e)
11191− ?^ first first
11192− (duplicate-exprs args.e)
11193− %trace
11194− =/ first (duplicate-expr val.e)
11195− ?^ first first
11196− (duplicate-expr then.e)
11197− %branch
11198− =/ first (duplicate-expr subject.e)
11199− ?^ first first
11200− (duplicate-arms arms.e)
11201− %body
11202− =/ first (duplicate-defs defs.e)
11203− ?^ first first
11204− (duplicate-expr final.e)
11205− * ~
11206− ==
7281+::
112077282++ import-binding-names
112087283 |= imports=(list import)
112097284 ^- (list term)
@@ -11216,60 +7291,6 @@
112167291 ==
112177292 [n $(imports t.imports)]
112187293::
11219−++ reserved-proj-sample
11220− |= sam=sample
11221− ^- ?
11222− ?- -.sam
11223− %bind =(name.sam %proj)
11224− %face =(name.sam %proj)
11225− %pun =(name.sam %proj)
11226− %cell (lien items.sam reserved-proj-sample)
11227− * |
11228− ==
11229−++ reserved-proj-pattern
11230− |= p=pattern
11231− ^- ?
11232− ?- -.p
11233− %bind =(name.p %proj)
11234− %cell (lien items.p reserved-proj-pattern)
11235− * |
11236− ==
11237−++ reserved-proj-def
11238− |= d=def
11239− ^- ?
11240− ?: =(name.d %proj) &
11241− ?: ?=(%value -.d) (reserved-proj-expr val.d)
11242− |
11243−++ reserved-proj-expr
11244− |= e=expr
11245− ^- ?
11246− ?- -.e
11247− %str (lien pieces.e |=(p=piece ?:(?=(%expr -.p) (reserved-proj-expr p.p) |)))
11248− %qath (lien segs.e |=(p=qseg ?:(?=(%expr -.p) (reserved-proj-expr p.p) |)))
11249− %change (lien edits.e |=(p=edit (reserved-proj-expr val.p)))
11250− %pair $(e val.e)
11251− %unit $(e val.e)
11252− %group $(e inner.e)
11253− %list (lien items.e reserved-proj-expr)
11254− %tuple (lien items.e |=(i=item (reserved-proj-expr val.i)))
11255− ?(%gate %gate-wide) |((reserved-proj-sample sample.e) $(e body.e))
11256− %cast $(e val.e)
11257− %call |($(e head.e) (lien args.e reserved-proj-expr))
11258− %trace |($(e val.e) $(e then.e))
11259− %branch |($(e subject.e) (lien arms.e |=(a=arm |((reserved-proj-pattern pat.a) (reserved-proj-expr val.a)))))
11260− %body |((lien defs.e reserved-proj-def) $(e final.e))
11261− * |
11262− ==
11263−::
11264−++ module-has-reserved-proj
11265− |= mod=module
11266− ^- ?
11267− =/ imported=(list term) (import-binding-names imports.mod)
11268− =/ vals=(list term) (global-value-names defs.mod)
11269− =/ molds=imolds (collect-simple-molds defs.mod)
11270− =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11271− |((lien (weld imported (weld vals mold-names)) |=(n=term =(n %proj))) (lien defs.mod reserved-proj-def))
11272−::
112737294++ module-scope-valid
112747295 |= [mod=module prelude-values=(list term) prelude-molds=(list term)]
112757296 ^- ?
@@ -11277,7 +7298,6 @@
112777298 =/ vals=(list term) (global-value-names defs.mod)
112787299 =/ molds=imolds (collect-simple-molds defs.mod)
112797300 =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11280− ?: (module-has-reserved-proj mod) |
112817301 ?. %+ levy imported
112827302 |= n=term
112837303 &((unique-value-name n imported) !(lien vals |=(v=term =(n v))) !(lien mold-names |=(m=term =(n m))) !(lien prelude-values |=(v=term =(n v))) !(lien prelude-molds |=(m=term =(n m))))
@@ -11285,59 +7305,6 @@
112857305 ?. (levy vals |=(n=term &((unique-value-name n vals) !(lien prelude-values |=(v=term =(n v)))))) |
112867306 (levy mold-names |=(n=term &((unique-value-name n mold-names) !(lien prelude-molds |=(m=term =(n m))))))
112877307::
11288−:: In an API file or before main's kind is known, a lone `+$ poke`
11289−:: may be a declaration rather than a mold that shadows the prelude. Do not call
11290−:: that one collision definite, and do not hide unrelated scope errors.
11291−++ pending-declared-poke
11292− |= [at=path mod=module prelude-values=(list term) prelude-molds=(list term)]
11293− ^- ?
11294− ?. (lien prelude-molds |=(n=term =(%poke n))) |
11295− ?. |(?=([%ui %api @ %jibb ~] at) (lien defs.mod |=(d=def &(?=(%value -.d) =(%main name.d))))) |
11296− =/ pokes=(list def)
11297− (skim defs.mod |=(d=def &(?=(%mold -.d) =(%poke name.d))))
11298− ?~ pokes |
11299− ?^ t.pokes |
11300− =/ remaining=(list def)
11301− (skim defs.mod |=(d=def !&(?=(%mold -.d) =(%poke name.d))))
11302− (module-scope-valid mod(defs remaining) prelude-values prelude-molds)
11303−::
11304−:: A detailed failure is attached only to the first mold that actually
11305−:: failed in this check, using that module's checked source mold table.
11306−+$ imold-failure [message=@t overlap=(unit [name=term cases=upair])]
11307−:: Validate a generic wrapper without an unbounded duplicate-name pass.
11308−++ module-mold-params-valid
11309− |= [vars=(list @t) seen=(set @t) fuel=@ud]
11310− ^- ?
11311− ?~ vars &
11312− ?: =(0 fuel) |
11313− ?: (~(has in:..zuse seen) i.vars) |
11314− $(vars t.vars, seen (~(put in:..zuse seen) i.vars), fuel (dec fuel))
11315−++ module-mold-overlap
11316− |= [m=[name=term body=shape] molds=imolds]
11317− ^- (unit upair)
11318− =/ sh=shape body.m
11319− =/ valid=?
11320− ?. ?=(%generic -.sh) &
11321− ?~ vars.sh |
11322− (module-mold-params-valid vars.sh *(set @t) 256)
11323− ?. valid ~
11324− =? sh ?=(%generic -.sh) body.sh
11325− ?. ?=(%union -.sh) ~
11326− (union-source-overlap cases.sh molds 256)
11327−++ module-mold-types-detail
11328− |= [molds=imolds state=istate]
11329− ^- (each imold-types imold-failure)
11330− ?~ molds [%& ~]
11331− =/ m=[name=term body=shape] i.molds
11332− =/ t=(unit [template=ischeme state=istate])
11333− (infer-mold-template body.m state(active [name.m active.state], in-mold &))
11334− ?~ t
11335− =/ overlap=(unit upair) (module-mold-overlap m molds.state)
11336− [%| ['module mold needs unsupported inference' ?~(overlap ~ `[name.m u.overlap])]]
11337− =. typ.template.u.t (label-direct-union typ.template.u.t body.m name.m state)
11338− =/ rest=(each imold-types imold-failure) $(molds t.molds)
11339− ?: ?=(%| -.rest) rest
11340− [%& [[name.m template.u.t] p.rest]]
113417308++ module-mold-types
113427309 |= [molds=imolds state=istate]
113437310 ^- (each imold-types @t)
@@ -11353,9 +7320,9 @@
113537320::
113547321:: Prepare a provisional interface from the trusted vendored source.
113557322:: Every declared name remains reserved, but only molds and values this
11356−:: fragment can infer are usable. Unsupported bodies are not validated.
11357−:: An optional internal source supplies the prelude's one supported import;
11358−:: clients cannot import that path directly. Named unions retain their origin.
7323+:: fragment can infer are usable. Unsupported bodies are not validated,
7324+:: and imports into the prelude are not supported yet. The fixed origin
7325+:: gives its named unions the same identity in every importing module.
113597326::
113607327:: Recognize only the complete standard prelude list shape. Its recursive
113617328:: tail uses the same parameter and the unqualified list name. The reader
@@ -11395,20 +7362,6 @@
113957362 ?. ?=(%tvar -.i.args.tail) |
113967363 =(var name.i.args.tail)
113977364::
11398−++ prelude-label
11399− |= [typ=itype name=term vars=(list @ud)]
11400− ^- itype
11401− ?: ?=(%jrec -.typ) typ(label `name)
11402− ?: ?=(%grec -.typ)
11403− ?. (identity-union-parameters vars args.typ) typ(label ~)
11404− typ(label `name)
11405− ?. ?=(%union -.typ) typ
11406− ?. (identity-union-parameters vars args.typ)
11407− ?~ origin.typ typ
11408− ?: =(at.u.origin.typ /lib/jibb/internal/jibb) typ(label ~)
11409− typ
11410− typ(label `name)
11411−::
114127365++ partial-prelude-molds
114137366 |= [molds=imolds state=istate]
114147367 ^- imold-types
@@ -11421,129 +7374,22 @@
114217374 (infer-mold-template body.m state(active [name.m active.state], in-mold &))
114227375 ?~ out $(molds t.molds)
114237376 =. typ.template.u.out (label-direct-union typ.template.u.out body.m name.m state)
11424− =. typ.template.u.out (prelude-label typ.template.u.out name.m vars.template.u.out)
114257377 [[name.m template.u.out] $(molds t.molds)]
114267378::
11427−:: A compiler-owned interface available only to the dedicated
11428−:: internal-prelude preparation path, never the ordinary module resolver.
11429−++ private-primitive-interface
11430− ^- ifile
11431− =/ a=itype [%avar 0]
11432− =/ pair=itype [%cell a a]
11433− =/ b=itype [%rvar 0]
11434− =/ plus=ischeme [[%fn [%cell b b] b] ~[0]]
11435− =/ minus=ischeme [[%fn b b] ~[0]]
11436− =/ greater=ischeme [[%fn pair [%flag ~]] ~[0]]
11437− =/ utf8=itype [%atom 'tD']
11438− =/ tape=itype [%collection %list ~[utf8]]
11439− =/ codepoints=itype [%collection %list ~[[%atom %c]]]
11440− =/ text-trip=ischeme [[%fn [%atom %t] tape] ~]
11441− =/ text-tuba=ischeme [[%fn tape codepoints] ~]
11442− [~[[%raw-add plus] [%raw-dec minus] [%raw-gth greater] [%raw-trip text-trip] [%raw-tuba text-tuba]] ~ /lib/jibb/primitives/jibb ~ ~ ~ ~ ~]
11443−::
11444−++ infer-private-internal
11445− |= [src=@t public-source=@t]
11446− ^- (unit ifile)
11447− =/ at=path /lib/jibb/internal/jibb
11448− =/ parsed (parse at src)
11449− ?: ?=(%| -.parsed) ~
11450− =/ mod=module p.parsed
11451− ?^ (duplicate-defs defs.mod) ~
11452− ?~ imports.mod
11453− =/ built=jfile-result (infer-jibb-file at src ~ ~ ~ ~[at] ~ ~ ~ ~)
11454− ?: ?=(%| -.built) ~
11455− `iface.p.built
11456− ?. ?=([[%jibb *] ~] imports.mod) ~
11457− ?. =(path.i.imports.mod /lib/jibb/primitives) ~
11458− ?. (module-scope-valid mod ~ ~) ~
11459− =/ vals=(list term) (global-value-names defs.mod)
11460− ?: (lien vals |=(n=term =(n %main))) ~
11461− =/ molds=imolds (collect-simple-molds defs.mod)
11462− =/ globals=(list term) (weld (import-binding-names imports.mod) vals)
11463− :: The private source can use the public list and unit molds before the
11464− :: prelude is otherwise prepared. Re-read the trusted public source here
11465− :: and admit only its validated canonical templates; do not accept schemes
11466− :: supplied independently by the caller.
11467− =/ public=(each module error) (parse /lib/jibb/prelude/jibb public-source)
11468− ?: ?=(%| -.public) ~
11469− ?^ (duplicate-defs defs.p.public) ~
11470− ?. (module-scope-valid p.public ~ ~) ~
11471− =/ source-molds=imolds (collect-simple-molds defs.p.public)
11472− =/ written-list=(unit shape) (find-simple-mold %list source-molds)
11473− =/ source-list=(unit ischeme)
11474− ?~ written-list ~
11475− ?. (standard-prelude-list u.written-list) ~
11476− `[[%collection %list ~[[%var 0]]] ~[0]]
11477− :: Derive the public unit template from its actual source, then compare
11478− :: the complete nominal template before making it available privately.
11479− =/ unit-decl=(unit shape) (find-simple-mold %unit source-molds)
11480− =/ source-unit=(unit ischeme)
11481− ?~ unit-decl ~
11482− =/ unit-molds=imolds ~[[%unit u.unit-decl]]
11483− =/ unit-state=istate [0 ~ ~ ~ unit-molds ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | /lib/jibb/prelude/jibb ~[%unit] ~ ~ 256 ~ ~ ~ ~ ~ ~]
11484− =/ unit-types=imold-types (partial-prelude-molds unit-molds unit-state)
11485− =/ unit-iface=ifile [~ unit-types /lib/jibb/prelude/jibb ~ ~ ~ ~ ~]
11486− =/ found=(unit ischeme) (find-jibb-mold %unit unit-iface)
11487− ?~ found ~
11488− ?. (standard-unit-template u.found /lib/jibb/prelude/jibb) ~
11489− found
11490− =/ primitive=ifile private-primitive-interface
11491− =? primitive ?=(^ source-list)
11492− primitive(molds [[%list u.source-list] molds.primitive])
11493− =? primitive ?=(^ source-unit)
11494− primitive(molds [[%unit u.source-unit] molds.primitive])
11495− =/ js=ijimports ~[[face.i.imports.mod primitive]]
11496− =/ reserved=(list term) ~[face.i.imports.mod]
11497− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11498− =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ js reserved ~ ~ ~ | at top ~ ~ 256 ~ ~ ~ ~ ~ ~]
11499− =/ mts=(each imold-types @t) (module-mold-types molds state)
11500− =/ usable=(unit imold-types)
11501− ?: ?=(%& -.mts) `p.mts
11502− :: Missing public templates may make an unrelated internal mold
11503− :: unavailable. Validate all molds once with isolated canonical
11504− :: templates before admitting only those inferred using the actual
11505− :: source-backed templates. The proof interface is never exported.
11506− ?. |(?=(~ source-list) ?=(~ source-unit)) ~
11507− =/ nil=itype [%const [%null %n 0 '~']]
11508− =/ canonical-unit=ischeme
11509− [[%union ~[nil [%cell nil [%face %u [%var 0]]]] `[/lib/jibb/prelude/jibb %unit] `%unit ~[[%var 0]]] ~[0]]
11510− =/ canonical-list=ischeme [[%collection %list ~[[%var 0]]] ~[0]]
11511− =/ proof-primitive=ifile private-primitive-interface
11512− =. molds.proof-primitive ~[[%list canonical-list] [%unit canonical-unit]]
11513− =/ proof-imports=ijimports ~[[face.i.imports.mod proof-primitive]]
11514− =/ proof=(each imold-types @t) (module-mold-types molds state(jimports proof-imports))
11515− ?: ?=(%| -.proof) ~
11516− `(partial-prelude-molds molds state)
11517− ?~ usable ~
11518− =/ resolution=iresolved (resolve-groups defs.mod molds globals ~ ~ ~ ~ js reserved at ~)
11519− =/ env=ienv env.resolution
11520− ?. (module-values-complete defs.mod env) ~
11521− `[env u.usable at ~ artifacts.resolution ~ `src ~]
11522−::
11523−++ partial-prelude-interface-with-internal
11524− |= [src=@t internal-source=(unit @t)]
7379+++ partial-prelude-interface
7380+ |= src=@t
115257381 ^- (unit ifile)
115267382 ?: =(0 src) ~
115277383 =/ at=path /lib/jibb/prelude/jibb
115287384 =/ parsed (parse at src)
115297385 ?: ?=(%| -.parsed) ~
11530− ?: (named-mold-has-hole defs.p.parsed) ~
11531− ?^ (duplicate-defs defs.p.parsed) ~
11532− =/ private=(unit ijimports)
11533− ?~ imports.p.parsed `~
11534− ?. ?=([[%jibb *] ~] imports.p.parsed) ~
11535− ?. =(path.i.imports.p.parsed /lib/jibb/internal) ~
11536− ?~ internal-source ~
11537− =/ built=(unit ifile) (infer-private-internal u.internal-source src)
11538− ?~ built ~
11539− `~[[face.i.imports.p.parsed u.built]]
11540− ?~ private ~
7386+ ?^ imports.p.parsed ~
115417387 ?~ defs.p.parsed ~
115427388 ?. (module-scope-valid p.parsed ~ ~) ~
115437389 =/ ds=(list def) defs.p.parsed
115447390 =/ molds=imolds (collect-simple-molds ds)
115457391 =/ names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11546− =/ globals=(list term) (weld (import-binding-names imports.p.parsed) (global-value-names ds))
7392+ =/ globals=(list term) (global-value-names ds)
115477393 :: Remove raw list before inferring any template, so an altered list
115487394 :: cannot leak through an alias. Its name remains reserved either way.
115497395 =/ declared=? (lien names |=(name=term =(%list name)))
@@ -11551,38 +7397,11 @@
115517397 =? env-molds declared
115527398 (skim molds |=(m=[name=term body=shape] !=(%list name.m)))
115537399 =/ reserved=(list term) ?:(declared ~[%list] ~)
11554− =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ u.private reserved ~ ~ ~ | at names ~ ~ 256 ~ ~ ~ ~ ~ ~]
11555− :: Other prelude molds may use list only after its source has passed
11556− :: the standard-list check. The raw declaration remains removed.
11557− =/ declared-list=(unit shape) (find-simple-mold %list molds)
11558− =/ mold-prelude=(unit ifile)
11559− ?~ declared-list ~
11560− ?. (standard-prelude-list u.declared-list) ~
11561− `[~ ~[[%list [[%collection %list ~[[%var 0]]] ~[0]]]] at ~ ~ ~ ~ ~]
11562− =/ mt=imold-types (partial-prelude-molds molds state(prelude mold-prelude))
11563− =/ partial=ifile [~ mt at ~ ~ ~ ~ ~]
11564− :: An explicitly qualified re-export must resolve. Other unsupported
11565− :: prelude declarations remain reserved but absent from the interface.
11566− =/ required=imolds
11567− %+ skim molds
11568− |= m=[name=term body=shape]
11569− =/ sh=shape body.m
11570− ?. ?=(%ref -.sh) |
11571− ?~ names.sh |
11572− ?=(^ t.names.sh)
11573− ?. (levy required |=(m=[name=term body=shape] ?=(^ (find-jibb-mold name.m partial)))) ~
11574− =/ resolution=iresolved (resolve-groups ds env-molds globals ~ ~ ~ ~ u.private reserved at `partial)
11575− =/ env=ienv env.resolution
11576− ?. (hole-values-present ds env) ~
11577− =/ deps=(list iwidth-dependency)
11578− ?~ u.private ~
11579− ~[[at.interface.i.u.private source.interface.i.u.private elaborations.interface.i.u.private]]
11580− `[env mt at ~ artifacts.resolution deps `src ~]
11581−::
11582−++ partial-prelude-interface
11583− |= src=@t
11584− ^- (unit ifile)
11585− (partial-prelude-interface-with-internal src ~)
7400+ =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ ~ reserved ~ ~ ~ | at names ~]
7401+ =/ mt=imold-types (partial-prelude-molds molds state)
7402+ =/ partial=ifile [~ mt at]
7403+ =/ env=ienv (resolve-supported-defs ds env-molds globals ~ ~ ~ ~ ~ reserved at `partial)
7404+ `[env mt at]
115867405::
115877406+$ iprelude [iface=ifile values=(list term) molds=(list term)]
115887407::
@@ -11597,17 +7416,6 @@
115977416 =/ ms=(list term) (turn (collect-simple-molds defs.p.parsed) |=(m=[name=term body=shape] name.m))
115987417 `[u.iface vals ms]
115997418::
11600−++ prepare-prelude-with-internal
11601− |= [src=@t internal-source=@t]
11602− ^- (unit iprelude)
11603− =/ iface=(unit ifile) (partial-prelude-interface-with-internal src `internal-source)
11604− ?~ iface ~
11605− =/ parsed (parse /lib/jibb/prelude/jibb src)
11606− ?: ?=(%| -.parsed) ~
11607− =/ vals=(list term) (global-value-names defs.p.parsed)
11608− =/ ms=(list term) (turn (collect-simple-molds defs.p.parsed) |=(m=[name=term body=shape] name.m))
11609− `[u.iface vals ms]
11610−::
116117419++ module-values-complete
116127420 |= [ds=(list def) env=ienv]
116137421 ^- ?
@@ -11628,1308 +7436,52 @@
116287436 ?: =(at at.i.cache) `iface.i.cache
116297437 $(cache t.cache)
116307438::
11631−:: These certificates retain the complete checked source closure. The
11632−:: trusted host must supply the identical prepared prelude and reader nouns.
11633−:: Exact bundle equality binds all source paths and versions; the set
11634−:: retains transitive paths for active-cycle checks. Request-bearing graphs
11635−:: alone have a size limit; incompatible diamond evidence fails closed.
11636−++ request-graph-requests-add
11637− |= [pending=(list irequest-evidence) acc=(list irequest-evidence) fuel=@ud]
11638− ^- (unit (list irequest-evidence))
11639− ?~ pending `acc
11640− ?: =(0 fuel) ~
11641− =/ hit=(list irequest-evidence)
11642− (skim acc |=(x=irequest-evidence &(=(api-at.x api-at.i.pending) =(name.x name.i.pending))))
11643− ?^ hit
11644− ?. ?=([* ~] hit) ~
11645− ?. =(i.hit i.pending) ~
11646− $(pending t.pending, fuel (dec fuel))
11647− $(pending t.pending, acc [i.pending acc], fuel (dec fuel))
11648−++ request-graph-inputs-match
11649− |= [g=irequest-graph externals=iexternals marks=imark-externals modules=jbundle values=(list term) molds=(list term) prelude=(unit ifile)]
11650− ^- ?
11651− ?& =(bundle-input.g modules)
11652− =(prelude-input.g prelude)
11653− =(prelude-values.g values)
11654− =(prelude-molds.g molds)
11655− =(externals.g externals)
11656− =(marks.g marks)
11657− ==
11658−++ request-graph-merge
11659− |= [imports=ijimports g=irequest-graph fuel=@ud]
11660− ^- (unit irequest-graph)
11661− ?~ imports `g
11662− ?: =(0 fuel) ~
11663− =/ child=ifile interface.i.imports
11664− ?~ graph.child ~
11665− =/ cg=irequest-graph u.graph.child
11666− ?. ?& =(bundle-input.g bundle-input.cg)
11667− =(prelude-input.g prelude-input.cg)
11668− =(prelude-values.g prelude-values.cg)
11669− =(prelude-molds.g prelude-molds.cg)
11670− =(externals.g externals.cg)
11671− =(marks.g marks.cg)
11672− ==
11673− ~
11674− =/ merged=(set path) (~(uni in:..zuse paths.g) paths.cg)
11675− =/ rs=(unit (list irequest-evidence))
11676− (request-graph-requests-add requests.cg requests.g (add 1 (lent requests.cg)))
11677− ?~ rs ~
11678− ?: &(?=(^ u.rs) |((gth (lent ~(tap in:..zuse merged)) 256) (gth (lent u.rs) 256))) ~
11679− $(imports t.imports, g g(paths merged, requests u.rs), fuel (dec fuel))
11680−++ request-graph-reusable
11681− |= [f=ifile src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) values=(list term) molds=(list term) prelude=(unit ifile)]
11682− ^- ?
11683− ?~ source.f |
11684− ?. =(u.source.f src) |
11685− ?~ graph.f |
11686− =/ g=irequest-graph u.graph.f
11687− ?. (request-graph-inputs-match g externals marks modules values molds prelude) |
11688− ?. (~(has in:..zuse paths.g) at.f) |
11689− !(lien active |=(p=path (~(has in:..zuse paths.g) p)))
11690−::
116917439++ resolve-jibb-imports
116927440 |= [imports=(list import) externals=iexternals mark-externals=imark-externals modules=jbundle active=(list path) prelude-values=(list term) prelude-molds=(list term) cache=jcache prelude=(unit ifile)]
116937441 ^- jimports-result
11694− =/ result=jimports-detailed-result
11695− (resolve-jibb-imports-detailed imports externals mark-externals modules active prelude-values prelude-molds cache prelude)
11696− ?: ?=(%| -.result) [%| message.p.result]
11697− [%& p.result]
11698−++ resolve-jibb-imports-detailed
11699− |= [imports=(list import) externals=iexternals mark-externals=imark-externals modules=jbundle active=(list path) prelude-values=(list term) prelude-molds=(list term) cache=jcache prelude=(unit ifile)]
11700− ^- jimports-detailed-result
117017442 ?~ imports [%& [~ cache]]
117027443 ?. ?=(%jibb -.i.imports) $(imports t.imports)
117037444 =/ at=path (weld path.i.imports `path`~[%jibb])
11704− ?: =(at /lib/jibb/internal/jibb)
11705− [%| ['the prelude internal module is private' ~]]
11706− ?: =(at /lib/jibb/primitives/jibb)
11707− [%| ['the prelude primitive interface is private' ~]]
117087445 ?: (lien active |=(p=path =(p at)))
11709− [%| [(crip "import cycle at {(spud at)}") ~]]
7446+ [%| (crip "import cycle at {(spud at)}")]
117107447 =/ found=jbundle (skim modules |=(m=jsource =(at at.m)))
11711− ?~ found [%| [(crip "module source missing: {(spud at)}") ~]]
11712− ?^ t.found [%| [(crip "duplicate module sources: {(spud at)}") ~]]
7448+ ?~ found [%| (crip "module source missing: {(spud at)}")]
7449+ ?^ t.found [%| (crip "duplicate module sources: {(spud at)}")]
117137450 =/ cached=(unit ifile) (find-jibb-cache at cache)
11714− =/ iface=jfile-detailed-result
11715− ?^ cached
11716− ?. =(at.u.cached at) [%| ['cached module identity needs unsupported inference' ~]]
11717− ?~ graph.u.cached
11718− :: A detached legacy interface has unknown evidence. Rebuild it
11719− :: against the current graph, without retaining any stale entry.
11720− =/ clean=jcache (skim cache |=(x=[at=path iface=ifile] !=(at.x at)))
11721− (infer-jibb-file-detailed at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds clean prelude)
11722− ?. (request-graph-reusable u.cached source.i.found externals mark-externals modules active prelude-values prelude-molds prelude)
11723− [%| ['cached module evidence needs unsupported inference' ~]]
11724− [%& [u.cached cache]]
11725− (infer-jibb-file-detailed at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
7451+ =/ iface=jfile-result
7452+ ?^ cached [%& [u.cached cache]]
7453+ (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
117267454 ?: ?=(%| -.iface) [%| p.iface]
11727− =/ rest=jimports-detailed-result $(imports t.imports, cache cache.p.iface)
7455+ =/ rest=jimports-result $(imports t.imports, cache cache.p.iface)
117287456 ?: ?=(%| -.rest) rest
117297457 [%& [[[face.i.imports iface.p.iface] resolved.p.rest] cache.p.rest]]
117307458::
11731−:: Provisional declaration extraction only; this does not derive asks,
11732−:: validate imported types, or claim that an API module has checked.
11733−+$ iapi-path [at=span name=term segments=(list pseg) full=term diffs=(list term) scry=(unit (list pseg))]
11734−++ api-path-mark
11735− |= [sh=shape marks=(list term)]
11736− ^- (unit term)
11737− ?. ?=(%ref -.sh) ~
11738− ?. ?=([@ ~] names.sh) ~
11739− ?. (unique-value-name i.names.sh marks) ~
11740− `i.names.sh
11741−::
11742−++ api-path-diffs
11743− |= [shapes=(list shape) marks=(list term) used=(list term)]
11744− ^- (unit (list term))
11745− ?~ shapes `~
11746− =/ n=(unit term) (api-path-mark i.shapes marks)
11747− ?~ n ~
11748− ?: (lien used |=(x=term =(x u.n))) ~
11749− =/ rest=(unit (list term)) $(shapes t.shapes, used [u.n used])
11750− ?~ rest ~
11751− `[u.n u.rest]
11752−::
11753−++ api-path-payload
11754− |= [sh=shape marks=(list term)]
11755− ^- (unit [full=term diffs=(list term)])
11756− =/ direct=(unit term) (api-path-mark sh marks)
11757− ?^ direct `[u.direct ~]
11758− ?. ?=(%apply -.sh) ~
11759− ?. =(~[%facts] ref.sh) ~
11760− ?~ args.sh ~
11761− ?~ t.args.sh ~
11762− =/ full=(unit term) (api-path-mark i.args.sh marks)
11763− ?~ full ~
11764− =/ diffs=(unit (list term)) (api-path-diffs t.args.sh marks ~[u.full])
11765− ?~ diffs ~
11766− `[u.full u.diffs]
11767−::
11768−+$ iapi-parameter [name=term aura=@ta at=span]
11769−++ api-path-parameters
11770− |= [segments=(list pseg) seen=(list term)]
11771− ^- (unit (list iapi-parameter))
11772− ?~ segments `~
11773− ?: ?=(%knot -.i.segments) $(segments t.segments)
11774− =/ seg=pseg i.segments
11775− ?. ?=(%typed -.seg) ~
11776− ?: =(0 aura.seg) ~
11777− ?: (lien seen |=(n=term =(n name.seg))) ~
11778− =/ rest=(unit (list iapi-parameter)) $(segments t.segments, seen [name.seg seen])
11779− ?~ rest ~
11780− `[[name.seg aura.seg at.seg] u.rest]
11781−::
11782−++ api-scry-parameters-compatible
11783− |= [scry=(list iapi-parameter) watch=(list iapi-parameter)]
11784− ^- ?
11785− ?~ scry &
11786− ?. (lien watch |=(p=iapi-parameter &(=(name.p name.i.scry) =(aura.p aura.i.scry)))) |
11787− $(scry t.scry)
11788−::
11789−++ api-path-one
11790− |= [sh=shape marks=(list term)]
11791− ^- (unit iapi-path)
11792− ?. ?=(%cell -.sh) ~
11793− =/ fs=(list field) fields.sh
11794− ?~ fs ~
11795− ?~ t.fs ~
11796− ?~ t.t.fs ~
11797− ?: (gth (lent fs) 4) ~
11798− ?. ?=(%bare -.i.fs) ~
11799− =/ tag=shape shape.i.fs
11800− ?. ?=(%const -.tag) ~
11801− ?. =(%term form.lit.tag) ~
11802− =/ name=term val.lit.tag
11803− ?. (jibb-face-name name) ~
11804− ?. ?=(%bare -.i.t.fs) ~
11805− =/ path-shape=shape shape.i.t.fs
11806− ?. ?=(%path -.path-shape) ~
11807− ?. ?=(%bare -.i.t.t.fs) ~
11808− =/ payload=(unit [full=term diffs=(list term)]) (api-path-payload shape.i.t.t.fs marks)
11809− ?~ payload ~
11810− =/ scry=(unit (unit (list pseg)))
11811− ?~ t.t.t.fs `~
11812− =/ entry=field i.t.t.t.fs
11813− ?. ?=(%face -.entry) ~
11814− ?. =(%scry name.entry) ~
11815− ?. ?=(%path -.shape.entry) ~
11816− ``segs.shape.entry
11817− ?~ scry ~
11818− =/ params=(unit (list iapi-parameter)) (api-path-parameters segs.path-shape ~)
11819− ?~ params ~
11820− ?^ u.scry
11821− =/ scry-params=(unit (list iapi-parameter)) (api-path-parameters u.u.scry ~)
11822− ?~ scry-params ~
11823− ?. (api-scry-parameters-compatible u.scry-params u.params) ~
11824− `[at.sh name segs.path-shape full.u.payload diffs.u.payload u.scry]
11825− `[at.sh name segs.path-shape full.u.payload diffs.u.payload u.scry]
11826−::
11827−++ api-path-many
11828− |= [shapes=(list shape) marks=(list term) seen=(list term)]
11829− ^- (unit (list iapi-path))
11830− ?~ shapes `~
11831− =/ one=(unit iapi-path) (api-path-one i.shapes marks)
11832− ?~ one ~
11833− ?: (lien seen |=(n=term =(n name.u.one))) ~
11834− =/ rest=(unit (list iapi-path)) $(shapes t.shapes, seen [name.u.one seen])
11835− ?~ rest ~
11836− `[u.one u.rest]
11837−::
11838−++ api-path-declaration
11839− |= [sh=shape marks=(list term)]
11840− ^- (unit (list iapi-path))
11841− ?: ?=(%union -.sh) (api-path-many cases.sh marks ~)
11842− (api-path-many ~[sh] marks ~)
11843−::
11844−:: Derived gates share the value namespace. /% marks name molds; /- and
11845−:: /= also introduce faces that cannot be shadowed by a derived value.
11846−++ api-import-faces
11847− |= imports=(list import)
11848− ^- (list term)
11849− ?~ imports ~
11850− ?- -.i.imports
11851− %mark $(imports t.imports)
11852− %sur [name.i.imports $(imports t.imports)]
11853− %jibb [face.i.imports $(imports t.imports)]
11854− ==
11855−::
11856−++ api-derived-names-valid
11857− |= [paths=(list iapi-path) poke-names=(list term) mod=module prelude-values=(list term)]
11858− ^- ?
11859− =/ path-names=(list term) (turn paths |=(p=iapi-path name.p))
11860− =/ derived=(list term) (weld path-names poke-names)
11861− ?: (lien derived |=(n=term =(n %proj))) |
11862− =/ outer=(list term) (weld prelude-values (weld (global-value-names defs.mod) (api-import-faces imports.mod)))
11863− (levy derived |=(n=term &((unique-value-name n derived) !(lien outer |=(x=term =(n x))))))
11864−::
11865−:: Analysis only. Successful external entries must be unchanged results
11866−:: produced for the declared marks; no request interface is produced.
11867−+$ iapi-mark-type [name=term typ=itype]
11868−+$ iapi-path-typed [path=iapi-path full=itype diffs=(list iapi-mark-type)]
11869−++ api-diff-types
11870− |= [names=(list term) externals=imark-externals declared=(list term)]
11871− ^- (unit (list iapi-mark-type))
11872− ?~ names `~
11873− =/ typ=(unit itype) (find-imported-mark i.names externals declared)
11874− ?~ typ ~
11875− =/ tail=(unit (list iapi-mark-type)) $(names t.names)
11876− ?~ tail ~
11877− `[[i.names u.typ] u.tail]
11878−::
11879−++ api-path-types
11880− |= [paths=(list iapi-path) externals=imark-externals declared=(list term)]
11881− ^- (unit (list iapi-path-typed))
11882− ?~ paths `~
11883− =/ full=(unit itype) (find-imported-mark full.i.paths externals declared)
11884− ?~ full ~
11885− =/ diffs=(unit (list iapi-mark-type)) (api-diff-types diffs.i.paths externals declared)
11886− ?~ diffs ~
11887− =/ tail=(unit (list iapi-path-typed)) $(paths t.paths)
11888− ?~ tail ~
11889− `[[i.paths u.full u.diffs] u.tail]
11890−::
11891−++ api-poke-mark-names
11892− |= [pokes=(list def) declared=(list term)]
11893− ^- (unit (list term))
11894− ?~ pokes `~
11895− ?^ t.pokes ~
11896− =/ d=def i.pokes
11897− ?. ?=(%mold -.d) ~
11898− =/ sh=shape shape.d
11899− ?: ?=(%union -.sh) (api-path-diffs cases.sh declared ~)
11900− =/ name=(unit term) (api-path-mark sh declared)
11901− ?~ name ~
11902− `~[u.name]
11903−::
11904−++ api-path-analysis
11905− |= [mod=module externals=imark-externals prelude-values=(list term) prelude-molds=(list term)]
11906− ^- (unit (list iapi-path-typed))
11907− ?: (lien defs.mod def-has-hole) ~
11908− ?^ (duplicate-defs defs.mod) ~
11909− =/ ds=(list def) defs.mod
11910− =/ declarations=(list def)
11911− (skim ds |=(d=def &(?=(%mold -.d) =(%paths name.d))))
11912− ?. ?=([* ~] declarations) ~
11913− =/ pokes=(list def)
11914− (skim ds |=(d=def &(?=(%mold -.d) =(%poke name.d))))
11915− ?: (gth (lent pokes) 1) ~
11916− =/ ordinary=(list def)
11917− (skim ds |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
11918− ?. (module-scope-valid mod(defs ordinary) prelude-values prelude-molds) ~
11919− =/ declared=(list term) (collect-mark-imports imports.mod)
11920− =/ poke-names=(unit (list term)) (api-poke-mark-names pokes declared)
11921− ?~ poke-names ~
11922− =/ decl=def i.declarations
11923− ?> ?=(%mold -.decl)
11924− =/ paths=(unit (list iapi-path)) (api-path-declaration shape.decl declared)
11925− ?~ paths ~
11926− ?. (api-derived-names-valid u.paths u.poke-names mod prelude-values) ~
11927− (api-path-types u.paths externals declared)
11928−::
11929−:: Source/graph entry for path analysis only. The returned paths retain
11930−:: reader-derived mark types and import resolution has checked reachable
11931−:: Jibb dependencies. This is not an API interface or a module check.
11932−++ api-path-analysis-source
11933− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
11934− ^- (each (list iapi-path-typed) @t)
11935− ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path analysis requires /ui/api/<agent>.jibb']
11936− =/ parsed (parse file src)
11937− ?: ?=(%| -.parsed) [%| 'API path source does not parse']
11938− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11939− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
11940− ?~ prepared [%| 'API path analysis needs the prepared prelude']
11941− =/ prelude=(unit ifile) `iface.u.prepared
11942− =/ deps=jimports-result
11943− (resolve-jibb-imports imports.p.parsed externals marks modules ~[file] values.u.prepared molds.u.prepared ~ prelude)
11944− ?: ?=(%| -.deps) [%| p.deps]
11945− =/ paths=(unit (list iapi-path-typed))
11946− (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
11947− ?~ paths [%| 'API path declaration needs unsupported analysis']
11948− [%& u.paths]
11949−::
11950−:: Analysis evidence retains the API source, the prepared interface, the
11951−:: caller's reader results and the resolved Jibb dependency cache alongside
11952−:: the typed path declarations. Reader results and prepared interfaces are
11953−:: trusted inputs: this does not verify their underlying Hoon source/version,
11954−:: create requests or check the provenance of arbitrary values.
11955−+$ iapi-path-evidence
11956− [at=path source=@t prepared=iprelude externals=iexternals marks=imark-externals dependencies=jcache paths=(list iapi-path-typed)]
11957−++ api-path-evidence-source
11958− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
11959− ^- (each iapi-path-evidence @t)
11960− ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path evidence requires /ui/api/<agent>.jibb']
11961− =/ parsed (parse file src)
11962− ?: ?=(%| -.parsed) [%| 'API path evidence source does not parse']
11963− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11964− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
11965− ?~ prepared [%| 'API path evidence needs the prepared prelude']
11966− =/ public=ifile iface.u.prepared
11967− =/ deps=jimports-result
11968− (resolve-jibb-imports imports.p.parsed externals marks modules ~[file] values.u.prepared molds.u.prepared ~ `public)
11969− ?: ?=(%| -.deps) [%| p.deps]
11970− =/ paths=(unit (list iapi-path-typed))
11971− (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
11972− ?~ paths [%| 'API path declaration needs unsupported analysis']
11973− [%& [file src u.prepared externals marks cache.p.deps u.paths]]
11974−:: Graph-aware variant preserves the caller active stack and cache.
11975−++ api-path-evidence-graph
11976− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
11977− ^- (each iapi-path-evidence @t)
11978− ?~ active [%| 'API analysis needs an active graph']
11979− ?. =(i.active file) [%| 'API analysis active graph does not start at the source']
11980− ?: (lien t.active |=(p=path =(p file))) [%| 'API analysis active graph contains a cycle']
11981− ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path evidence requires /ui/api/<agent>.jibb']
11982− =/ parsed (parse file src)
11983− ?: ?=(%| -.parsed) [%| 'API path evidence source does not parse']
11984− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11985− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
11986− ?~ prepared [%| 'API path evidence needs the prepared prelude']
11987− =/ public=ifile iface.u.prepared
11988− =/ deps=jimports-result
11989− (resolve-jibb-imports imports.p.parsed externals marks modules active values.u.prepared molds.u.prepared cache `public)
11990− ?: ?=(%| -.deps) [%| p.deps]
11991− =/ paths=(unit (list iapi-path-typed))
11992− (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
11993− ?~ paths [%| 'API path declaration needs unsupported analysis']
11994− [%& [file src u.prepared externals marks cache.p.deps u.paths]]
11995−::
11996−:: This query classifies a unique path declaration only. Missing evidence
11997−:: or a nonunique name is unknown; it proves nothing about an ask value.
11998−:: Like prepared interfaces, the supplied evidence is a trusted host input.
11999−++ api-path-watchability
12000− |= [evidence=(unit iapi-path-evidence) case-name=term]
12001− ^- ?(%watchable %not-watchable %unknown)
12002− ?~ evidence %unknown
12003− =/ found=(list iapi-path-typed)
12004− (skim paths.u.evidence |=(p=iapi-path-typed =(name.path.p case-name)))
12005− ?. ?=([* ~] found) %unknown
12006− ?~ scry.path.i.found %watchable
12007− %not-watchable
12008−::
12009−:: These are declaration-derived request components, not a callable gate,
12010−:: an ask value, or proof of a value's provenance. Keep the exact trusted
12011−:: source/reader evidence until a later checked interface and lowerer can
12012−:: attach it to a generated request. No argument ordering is claimed here.
12013−+$ iapi-request-parameter [name=term typ=itype at=span]
12014−+$ iapi-request-parts
12015− [evidence=iapi-path-evidence path=iapi-path-typed parameters=(list iapi-request-parameter) reply-sample=itype fold=(unit itype) watchability=?(%watchable %not-watchable)]
12016−++ api-request-parameter-types
12017− |= params=(list iapi-parameter)
12018− ^- (unit (list iapi-request-parameter))
12019− ?~ params `~
12020− =/ aura=@ta aura.i.params
12021− ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
12022− =/ rest=(unit (list iapi-request-parameter)) $(params t.params)
12023− ?~ rest ~
12024− `[[name.i.params [%atom aura] at.i.params] u.rest]
12025−::
12026−:: A single diff's fold consumes the tagged diff and the previous full value.
12027−:: Multiple-diff unions need a checked union representation and remain open.
12028−++ api-request-fold-type
12029− |= p=iapi-path-typed
12030− ^- (unit (unit itype))
12031− ?~ diffs.p `~
12032− ?^ t.diffs.p ~
12033− =/ d=iapi-mark-type i.diffs.p
12034− =/ literal=lit [%term %tas name.d (crip ['%' (trip name.d)])]
12035− =/ sample=itype [%cell [%cell [%const literal] typ.d] full.p]
12036− ``[%fn sample full.p]
12037−::
12038−++ api-request-parts
12039− |= [evidence=(unit iapi-path-evidence) case-name=term]
12040− ^- (unit iapi-request-parts)
12041− ?~ evidence ~
12042− =/ found=(list iapi-path-typed)
12043− (skim paths.u.evidence |=(p=iapi-path-typed =(name.path.p case-name)))
12044− ?. ?=([* ~] found) ~
12045− =/ p=iapi-path-typed i.found
12046− =/ raw=(unit (list iapi-parameter)) (api-path-parameters segments.path.p ~)
12047− ?~ raw ~
12048− =/ params=(unit (list iapi-request-parameter)) (api-request-parameter-types u.raw)
12049− ?~ params ~
12050− =/ fold=(unit (unit itype)) (api-request-fold-type p)
12051− ?~ fold ~
12052− =/ watch=?(%watchable %not-watchable) ?~(scry.path.p %watchable %not-watchable)
12053− `[u.evidence p u.params full.p u.fold watch]
12054−::
12055−:: Check ordinary API molds and values plus every declared mark type using
12056−:: the same trusted source, prepared prelude and reader inputs as path
12057−:: evidence. Keep elaborations with those inputs for a later interface.
12058−:: This is partial analysis: an unused /- core is not independently checked,
12059−:: definitions needing derived values remain unsupported, and no complete
12060−:: API, request or constructor is exported or given runtime behavior.
12061−+$ iapi-support-evidence
12062− [paths=iapi-path-evidence values=ienv molds=imold-types marks=(list iapi-mark-type) elaborations=(list iwidth-definition)]
12063−++ api-support-analysis-source
12064− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
12065− ^- (each iapi-support-evidence @t)
12066− =/ path-result (api-path-evidence-source file src externals marks modules prepared)
12067− ?: ?=(%| -.path-result) [%| p.path-result]
12068− =/ evidence=iapi-path-evidence p.path-result
12069− =/ parsed (parse file src)
12070− ?: ?=(%| -.parsed) [%| 'API source does not parse']
12071− =/ mod=module p.parsed
12072− =/ ordinary=(list def)
12073− (skim defs.mod |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
12074− =/ prep=iprelude prepared.evidence
12075− ?. (module-scope-valid mod(defs ordinary) values.prep molds.prep) [%| 'API ordinary scope needs unsupported inference']
12076− =/ vals=(list term) (global-value-names ordinary)
12077− ?: (lien vals |=(n=term =(n %main))) [%| 'API module kind needs unsupported inference']
12078− =/ declared=(list term) (collect-mark-imports imports.mod)
12079− =/ mark-types=(unit (list iapi-mark-type)) (api-diff-types declared marks declared)
12080− ?~ mark-types [%| 'API declared marks need unsupported inference']
12081− =/ prelude=(unit ifile) `iface.prep
12082− =/ deps=jimports-result
12083− (resolve-jibb-imports imports.mod externals marks modules ~[file] values.prep molds.prep dependencies.evidence prelude)
12084− ?: ?=(%| -.deps) [%| p.deps]
12085− =/ molds=imolds (collect-simple-molds ordinary)
12086− =/ globals=(list term) (weld values.prep (weld (import-binding-names imports.mod) vals))
12087− =/ surs=(list term) (collect-sur-imports imports.mod)
12088− =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
12089− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
12090− =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~ ~ ~]
12091− =/ mts=(each imold-types @t) (module-mold-types molds state)
12092− ?: ?=(%| -.mts) [%| p.mts]
12093− =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
12094− ?. (module-values-complete ordinary env.resolution) [%| 'API ordinary definitions need unsupported inference']
12095− [%& [evidence env.resolution p.mts u.mark-types artifacts.resolution]]
12096−:: Preserve the same graph context through supporting definitions.
12097−++ api-support-analysis-graph
12098− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
12099− ^- (each iapi-support-evidence @t)
12100− =/ path-result (api-path-evidence-graph file src externals marks modules active cache prepared)
12101− ?: ?=(%| -.path-result) [%| p.path-result]
12102− =/ evidence=iapi-path-evidence p.path-result
12103− =/ parsed (parse file src)
12104− ?: ?=(%| -.parsed) [%| 'API source does not parse']
12105− =/ mod=module p.parsed
12106− =/ ordinary=(list def)
12107− (skim defs.mod |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
12108− =/ prep=iprelude prepared.evidence
12109− ?. (module-scope-valid mod(defs ordinary) values.prep molds.prep) [%| 'API ordinary scope needs unsupported inference']
12110− =/ vals=(list term) (global-value-names ordinary)
12111− ?: (lien vals |=(n=term =(n %main))) [%| 'API module kind needs unsupported inference']
12112− =/ declared=(list term) (collect-mark-imports imports.mod)
12113− =/ mark-types=(unit (list iapi-mark-type)) (api-diff-types declared marks declared)
12114− ?~ mark-types [%| 'API declared marks need unsupported inference']
12115− =/ prelude=(unit ifile) `iface.prep
12116− =/ deps=jimports-result
12117− (resolve-jibb-imports imports.mod externals marks modules active values.prep molds.prep dependencies.evidence prelude)
12118− ?: ?=(%| -.deps) [%| p.deps]
12119− =/ molds=imolds (collect-simple-molds ordinary)
12120− =/ globals=(list term) (weld values.prep (weld (import-binding-names imports.mod) vals))
12121− =/ surs=(list term) (collect-sur-imports imports.mod)
12122− =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
12123− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
12124− =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~ ~ ~]
12125− =/ mts=(each imold-types @t) (module-mold-types molds state)
12126− ?: ?=(%| -.mts) [%| p.mts]
12127− =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
12128− ?. (module-values-complete ordinary env.resolution) [%| 'API ordinary definitions need unsupported inference']
12129− [%& [evidence env.resolution p.mts u.mark-types artifacts.resolution]]
12130−::
12131−:: Type-analysis artifact for one plain request. The resolver may publish
12132−:: its interface only together with trusted source and reader evidence.
12133−:: No lowering or runtime validator exists.
12134−:: Value watchability remains unproved even for a watchable declaration.
12135−+$ ione-request-interface
12136− [support=iapi-support-evidence parts=iapi-request-parts iface=ifile]
12137−++ request-compatible-ask
12138− |= prelude=iprelude
12139− ^- (unit ischeme)
12140− =/ public=ifile iface.prelude
12141− ?. =(at.public /lib/jibb/prelude/jibb) ~
12142− =/ ask=(unit ischeme) (find-jibb-mold %ask public)
12143− ?~ ask ~
12144− ?. ?=([@ ~] vars.u.ask) ~
12145− ?. ?=(%union -.typ.u.ask) ~
12146− ?. =(origin.typ.u.ask `[/lib/jibb/internal/jibb %ask]) ~
12147− ?. (identity-union-parameters vars.u.ask args.typ.u.ask) ~
12148− =/ m=@ud i.vars.u.ask
12149− ?: (itype-var-is-atom m typ.u.ask) ~
12150− ?. (levy (itype-vars typ.u.ask) |=(n=@ud =(n m))) ~
12151− ?: (itype-has-tag typ.u.ask) ~
12152− =/ private=(list iwidth-dependency)
12153− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12154− ?. ?=([* ~] private) ~
12155− ?~ source.i.private ~
12156− =/ path=(unit ischeme) (find-jibb-mold %path public)
12157− ?~ path ~
12158− ?^ vars.u.path ~
12159− =/ path-type=itype [%collection %list ~[[%atom %ta]]]
12160− ?. =(typ.u.path path-type) ~
12161− =/ unit-template=(unit ischeme) (find-jibb-mold %unit public)
12162− ?~ unit-template ~
12163− ?. (standard-unit-template u.unit-template /lib/jibb/prelude/jibb) ~
12164− =/ state-unit=(unit itype) (template-apply u.unit-template ~[[%noun ~]])
12165− ?~ state-unit ~
12166− =/ path-unit=(unit itype) (template-apply u.unit-template ~[path-type])
12167− ?~ path-unit ~
12168− =/ output=itype [%cell [%face %state [%noun ~]] [%face %message [%var m]]]
12169− =/ agent-input=itype [%cell [%face %mark [%atom %tas]] [%cell [%face %state u.state-unit] [%face %fact [%noun ~]]]]
12170− =/ store-input=itype [%cell [%face %state u.state-unit] [%face %fact [%noun ~]]]
12171− =/ pure-case=itype [%cell [%const [%term %tas %pure '%pure']] [%face %value [%var m]]]
12172− =/ agent-case=itype
12173− [%cell [%const [%term %tas %agent '%agent']] [%cell [%face %api [%atom %t]] [%cell [%face %case [%atom %tas]] [%cell [%face %agent [%atom %tas]] [%cell [%face %path path-type] [%cell [%face %scry u.path-unit] [%face %receive [%fn agent-input output]]]]]]]]
12174− =/ store-case=itype
12175− [%cell [%const [%term %tas %store '%store']] [%cell [%face %module [%atom %t]] [%cell [%face %name [%atom %tas]] [%face %receive [%fn store-input output]]]]]
12176− ?. =(cases.typ.u.ask ~[pure-case agent-case store-case]) ~
12177− ask
12178−::
12179−:: The first supported standalone API has exactly one mark import and one
12180−:: plain path declaration, with no other definitions or imports. No partial
12181−:: success is published when source, schema, or a required mold is unknown.
12182−++ one-request-interface-source
12183− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
12184− ^- (each ione-request-interface @t)
12185− =/ out (api-support-analysis-source file src externals marks modules prepared)
12186− ?: ?=(%| -.out) [%| p.out]
12187− =/ support=iapi-support-evidence p.out
12188− =/ ev=iapi-path-evidence paths.support
12189− =/ parsed (parse file src)
12190− ?: ?=(%| -.parsed) [%| 'request source does not parse']
12191− =/ mod=module p.parsed
12192− ?. ?=(?([[%mark *] ~] [[%mark *] [%mark *] ~]) imports.mod) [%| 'request imports need unsupported inference']
12193− ?. ?=([[%mold *] ~] defs.mod) [%| 'request definitions need unsupported inference']
12194− ?. =(%paths name.i.defs.mod) [%| 'request declaration needs unsupported inference']
12195− ?. ?=([* ~] paths.ev) [%| 'request count needs unsupported inference']
12196− =/ p=iapi-path-typed i.paths.ev
12197− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
12198− ?~ parts [%| 'request components need unsupported inference']
12199− ?. ?=(?(~ [* ~]) parameters.u.parts) [%| 'request parameters need unsupported inference']
12200− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) [%| 'request parameter and fold need unsupported inference']
12201− ?^ scry.path.p [%| 'request scry needs unsupported inference']
12202− =/ valid-marks=?
12203− ?~ fold.u.parts ?=([* ~] marks.support)
12204− ?=([* [* ~]] marks.support)
12205− ?. valid-marks [%| 'request marks need unsupported inference']
12206− =/ fold-open=?
12207− ?~ fold.u.parts |
12208− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
12209− ?: fold-open [%| 'request fold needs unsupported inference']
12210− ?^ (itype-vars reply-sample.u.parts) [%| 'request payload needs unsupported inference']
12211− ?: (itype-has-tag reply-sample.u.parts) [%| 'request payload needs unsupported inference']
12212− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
12213− ?~ ask [%| 'request ask needs unsupported inference']
12214− =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
12215− ?~ result [%| 'request ask needs unsupported inference']
12216− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
12217− =/ sample=itype
12218− ?^ fold.u.parts [%cell callback u.fold.u.parts]
12219− ?~ parameters.u.parts callback
12220− [%cell typ.i.parameters.u.parts callback]
12221− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
12222− =/ exports=imold-types
12223− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
12224− =/ prelude=iprelude prepared.ev
12225− =/ public=ifile iface.prelude
12226− ?~ source.public [%| 'request prelude source needs unsupported inference']
12227− =/ private=(list iwidth-dependency)
12228− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12229− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
12230− ?~ source.i.private [%| 'request internal source needs unsupported inference']
12231− =/ req=irequest-evidence
12232− [file name.path.p p src u.source.public u.source.i.private values.prelude molds.prelude externals marks]
12233− =/ interface=ifile [~[[name.path.p scheme]] exports file ~ ~ ~ `src `[(silt `(list path)`~[file]) ~[req] modules `public values.prelude molds.prelude externals marks]]
12234− [%& [support u.parts interface]]
12235−:: Graph-aware request artifact; resolver use remains type-only.
12236−++ one-request-interface-graph
12237− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
12238− ^- (each ione-request-interface @t)
12239− =/ out (api-support-analysis-graph file src externals marks modules active cache prepared)
12240− ?: ?=(%| -.out) [%| p.out]
12241− =/ support=iapi-support-evidence p.out
12242− =/ ev=iapi-path-evidence paths.support
12243− =/ parsed (parse file src)
12244− ?: ?=(%| -.parsed) [%| 'request source does not parse']
12245− =/ mod=module p.parsed
12246− ?. ?=(?([[%mark *] ~] [[%mark *] [%mark *] ~]) imports.mod) [%| 'request imports need unsupported inference']
12247− ?. ?=([[%mold *] ~] defs.mod) [%| 'request definitions need unsupported inference']
12248− ?. =(%paths name.i.defs.mod) [%| 'request declaration needs unsupported inference']
12249− ?. ?=([* ~] paths.ev) [%| 'request count needs unsupported inference']
12250− =/ p=iapi-path-typed i.paths.ev
12251− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
12252− ?~ parts [%| 'request components need unsupported inference']
12253− ?. ?=(?(~ [* ~]) parameters.u.parts) [%| 'request parameters need unsupported inference']
12254− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) [%| 'request parameter and fold need unsupported inference']
12255− ?^ scry.path.p [%| 'request scry needs unsupported inference']
12256− =/ valid-marks=?
12257− ?~ fold.u.parts ?=([* ~] marks.support)
12258− ?=([* [* ~]] marks.support)
12259− ?. valid-marks [%| 'request marks need unsupported inference']
12260− =/ fold-open=?
12261− ?~ fold.u.parts |
12262− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
12263− ?: fold-open [%| 'request fold needs unsupported inference']
12264− ?^ (itype-vars reply-sample.u.parts) [%| 'request payload needs unsupported inference']
12265− ?: (itype-has-tag reply-sample.u.parts) [%| 'request payload needs unsupported inference']
12266− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
12267− ?~ ask [%| 'request ask needs unsupported inference']
12268− =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
12269− ?~ result [%| 'request ask needs unsupported inference']
12270− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
12271− =/ sample=itype
12272− ?^ fold.u.parts [%cell callback u.fold.u.parts]
12273− ?~ parameters.u.parts callback
12274− [%cell typ.i.parameters.u.parts callback]
12275− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
12276− =/ exports=imold-types
12277− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
12278− =/ prelude=iprelude prepared.ev
12279− =/ public=ifile iface.prelude
12280− ?~ source.public [%| 'request prelude source needs unsupported inference']
12281− =/ private=(list iwidth-dependency)
12282− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12283− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
12284− ?~ source.i.private [%| 'request internal source needs unsupported inference']
12285− =/ req=irequest-evidence
12286− [file name.path.p p src u.source.public u.source.i.private values.prelude molds.prelude externals marks]
12287− =/ interface=ifile [~[[name.path.p scheme]] exports file ~ ~ ~ `src `[(silt `(list path)`~[file]) ~[req] modules `public values.prelude molds.prelude externals marks]]
12288− [%& [support u.parts interface]]
12289−::
12290−++ api-mark-exports
12291− |= [marks=(list term) all=(list term) externals=imark-externals]
12292− ^- imold-types
12293− ?~ marks ~
12294− =/ t=(unit itype) (find-imported-mark i.marks externals all)
12295− ?~ t $(marks t.marks)
12296− [[i.marks [u.t ~]] $(marks t.marks)]
12297−::
12298−:: Experimental direct poke-only API. Unsupported API declarations fail
12299−:: as a whole; supplied mark reader results retain their existing boundary.
12300−++ api-poke-interface
12301− |= [at=path mod=module mark-externals=imark-externals prelude-values=(list term) prelude-molds=(list term) prelude=(unit ifile)]
12302− ^- (unit ifile)
12303− ?: (lien defs.mod def-has-hole) ~
12304− ?. ?=([%ui %api @ %jibb ~] at) ~
12305− ?^ (duplicate-defs defs.mod) ~
12306− ?~ prelude ~
12307− ?. =(at.u.prelude /lib/jibb/prelude/jibb) ~
12308− =/ poke=(unit ischeme) (find-jibb-mold %poke u.prelude)
12309− ?~ poke ~
12310− ?. ?=(%union -.typ.u.poke) ~
12311− ?^ vars.u.poke ~
12312− =/ compatible=?
12313− %+ lien cases.typ.u.poke
12314− |= c=itype
12315− ?=([%cell [%const [%term %tas %agent *]] [%cell [%face %agent [%atom %tas]] [%cell [%face %mark [%atom %tas]] [%face %payload [%noun ~]]]]] c)
12316− ?. compatible ~
12317− ?. (module-scope-valid mod(defs ~) prelude-values prelude-molds) ~
12318− ?. (levy imports.mod |=(i=import ?=(%mark -.i))) ~
12319− =/ marks=(list term) (collect-mark-imports imports.mod)
12320− ?. ?=([@ ~] marks) ~
12321− =/ ds=(list def) defs.mod
12322− ?. ?=([[%mold *] ~] ds) ~
12323− ?. =(%poke name.i.ds) ~
12324− =/ sh=shape shape.i.ds
12325− ?. ?=([%ref *] sh) ~
12326− ?. ?=([@ ~] names.sh) ~
12327− =/ n=term i.names.sh
12328− ?. (unique-value-name n marks) ~
12329− ?: |((lien prelude-values |=(x=term =(n x))) (lien prelude-molds |=(x=term =(n x)))) ~
12330− =/ mark=(unit itype) (find-imported-mark n mark-externals marks)
12331− ?~ mark ~
12332− =/ sc=ischeme [[%fn u.mark typ.u.poke] ~]
12333− `[~[[n sc]] (api-mark-exports marks marks mark-externals) at ~[[n i.t.t.at n]] ~ ~ ~ ~]
12334−::
12335−:: Source-proven ordinary helpers validate each selected /sur dependency.
12336−:: Unused or less direct cores remain unsupported by this first interface.
12337−++ api-sur-covered
12338− |= [surs=(list term) defs=(list def) externals=iexternals all=(list term)]
12339− ^- ?
12340− ?~ surs &
12341− =/ found=(list def)
12342− %+ skim defs
12343− |= d=def
12344− ?. ?=(%mold -.d) |
12345− ?. ?=(%ref -.shape.d) |
12346− ?. ?=([@ [@ ~]] names.shape.d) |
12347− =(i.t.names.shape.d i.surs)
12348− ?~ found |
12349− =/ selected=def i.found
12350− ?. ?=(%mold -.selected) |
12351− =/ sh=shape shape.selected
12352− ?. ?=(%ref -.sh) |
12353− ?. ?=([@ [@ ~]] names.sh) |
12354− =/ checked=(unit itype) (find-imported-mold i.surs i.names.sh externals all)
12355− ?~ checked |
12356− $(surs t.surs)
12357−::
12358−+$ imulti-request-gates [values=ienv requests=(list irequest-evidence)]
12359−++ api-request-gates
12360− |= [paths=(list iapi-path-typed) ev=iapi-path-evidence ask=ischeme file=path src=@t public=@t internal=@t externals=iexternals marks=imark-externals fuel=@ud]
12361− ^- (unit imulti-request-gates)
12362− ?~ paths `[~ ~]
12363− ?: =(0 fuel) ~
12364− =/ p=iapi-path-typed i.paths
12365− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
12366− ?~ parts ~
12367− ?. ?=(?(~ [* ~]) parameters.u.parts) ~
12368− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) ~
12369− ?^ scry.path.p ~
12370− ?^ (itype-vars reply-sample.u.parts) ~
12371− ?: (itype-has-tag reply-sample.u.parts) ~
12372− =/ open-fold=?
12373− ?~ fold.u.parts |
12374− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
12375− ?: open-fold ~
12376− =/ result=(unit itype) (template-apply ask ~[[%var 0]])
12377− ?~ result ~
12378− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
12379− =/ sample=itype
12380− ?^ fold.u.parts [%cell callback u.fold.u.parts]
12381− ?~ parameters.u.parts callback
12382− [%cell typ.i.parameters.u.parts callback]
12383− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
12384− =/ prep=iprelude prepared.ev
12385− =/ req=irequest-evidence
12386− [file name.path.p p src public internal values.prep molds.prep externals marks]
12387− =/ rest=(unit imulti-request-gates)
12388− $(paths t.paths, fuel (dec fuel))
12389− ?~ rest ~
12390− `[[[name.path.p scheme] values.u.rest] [req requests.u.rest]]
12391−::
12392−++ api-poke-from-checked
12393− |= [file=path mod=module marks=imark-externals values=(list term) molds=(list term) prelude=(unit ifile)]
12394− ^- (unit [values=ienv derived=(list iderived)])
12395− =/ pokes=(list def)
12396− (skim defs.mod |=(d=def &(?=(%mold -.d) =(%poke name.d))))
12397− ?~ pokes `[~ ~]
12398− ?. ?=([* ~] pokes) ~
12399− =/ declared=(list term) (collect-mark-imports imports.mod)
12400− =/ ns=(unit (list term)) (api-poke-mark-names pokes declared)
12401− ?~ ns ~
12402− ?. ?=([@ ~] u.ns) ~
12403− =/ matching=(list import)
12404− %+ skim imports.mod
12405− |= i=import
12406− ?. ?=(%mark -.i) |
12407− =(mark.i i.u.ns)
12408− ?. ?=([* ~] matching) ~
12409− =/ checked=(unit ifile)
12410− (api-poke-interface file mod(defs pokes, imports matching) marks values molds prelude)
12411− ?~ checked ~
12412− `[values.u.checked derived.u.checked]
12413−::
12414−:: The partial interface is published atomically: all paths, ordinary
12415−:: source definitions, declared marks and the poke must check. Unselected
12416−:: /sur bindings, runtime validation and value watchability remain unproved.
12417−++ multi-request-interface-graph
12418− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
12419− ^- (each [iface=ifile cache=jcache] @t)
12420− =/ out (api-support-analysis-graph file src externals marks modules active cache prepared)
12421− ?: ?=(%| -.out) [%| p.out]
12422− =/ support=iapi-support-evidence p.out
12423− =/ ev=iapi-path-evidence paths.support
12424− =/ parsed (parse file src)
12425− ?: ?=(%| -.parsed) [%| 'request source does not parse']
12426− =/ mod=module p.parsed
12427− ?. (levy imports.mod |=(i=import ?=(?(%mark %sur) -.i)))
12428− [%| 'request imports need unsupported inference']
12429− =/ surs=(list term) (collect-sur-imports imports.mod)
12430− ?. (api-sur-covered surs defs.mod externals surs)
12431− [%| 'API source dependency needs unsupported inference']
12432− ?~ paths.ev [%| 'request count needs unsupported inference']
12433− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
12434− ?~ ask [%| 'request ask needs unsupported inference']
12435− =/ prep=iprelude prepared.ev
12436− =/ public=ifile iface.prep
12437− ?~ source.public [%| 'request prelude source needs unsupported inference']
12438− =/ private=(list iwidth-dependency)
12439− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12440− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
12441− ?~ source.i.private [%| 'request internal source needs unsupported inference']
12442− =/ gates=(unit imulti-request-gates)
12443− (api-request-gates paths.ev ev u.ask file src u.source.public u.source.i.private externals marks 256)
12444− ?~ gates [%| 'request paths need unsupported inference']
12445− =/ poke=(unit [values=ienv derived=(list iderived)])
12446− (api-poke-from-checked file mod marks values.prep molds.prep `public)
12447− ?~ poke [%| 'API poke needs unsupported inference']
12448− =/ mark-molds=imold-types
12449− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
12450− =/ exports=imold-types (weld mark-molds molds.support)
12451− =/ names=(list term) (turn exports |=(m=[name=term template=ischeme] name.m))
12452− ?. (levy names |=(n=term (unique-value-name n names)))
12453− [%| 'API exported molds need unsupported inference']
12454− =/ env=ienv (weld values.u.gates (weld values.u.poke values.support))
12455− =/ graph=irequest-graph
12456− [(silt `(list path)`~[file]) requests.u.gates modules `public values.prep molds.prep externals marks]
12457− =/ iface=ifile
12458− [env exports file derived.u.poke elaborations.support ~ `src `graph]
12459− [%& [iface dependencies.ev]]
12460−::
12461−:: A checked program main is only the direct four-component source call.
12462−:: Grouping is transparent, but aliases, qualified wings and other module
12463−:: kinds remain outside this slice.
12464−++ program-main-def
12465− |= ds=(list def)
12466− ^- (unit def)
12467− ?~ ds ~
12468− ?: &(?=(%value -.i.ds) =(%main name.i.ds)) `i.ds
12469− $(ds t.ds)
12470−::
12471−++ program-main-wing
12472− |= e=expr
12473− ^- (unit term)
12474− ?: ?=(%group -.e) $(e inner.e)
12475− ?. ?=(%wing -.e) ~
12476− ?. ?=([@ ~] names.e) ~
12477− `i.names.e
12478−::
12479−++ program-main-args
12480− |= d=def
12481− ^- (unit (list expr))
12482− ?. ?=(%value -.d) ~
12483− |-
12484− ?: ?=(%group -.val.d) $(val.d inner.val.d)
12485− ?. ?=(%call -.val.d) ~
12486− =/ head=(unit term) (program-main-wing head.val.d)
12487− ?~ head ~
12488− ?. =(%program u.head) ~
12489− ?. ?=([* * * * ~] args.val.d) ~
12490− `args.val.d
12491−::
12492−++ program-main-parts
12493− |= d=def
12494− ^- (unit [init=term update=term view=term subs=term])
12495− ?. ?=(%value -.d) ~
12496− |-
12497− ?: ?=(%group -.val.d) $(val.d inner.val.d)
12498− ?. ?=(%call -.val.d) ~
12499− =/ head=(unit term) (program-main-wing head.val.d)
12500− ?~ head ~
12501− ?. =(%program u.head) ~
12502− ?. ?=([* * * * ~] args.val.d) ~
12503− =/ args=(list expr) args.val.d
12504− ?> ?=([* * * * ~] args)
12505− =/ init=(unit term) (program-main-wing i.args)
12506− =/ update=(unit term) (program-main-wing i.t.args)
12507− =/ view=(unit term) (program-main-wing i.t.t.args)
12508− =/ subs=(unit term) (program-main-wing i.t.t.t.args)
12509− ?~ init ~
12510− ?~ update ~
12511− ?~ view ~
12512− ?~ subs ~
12513− `[u.init u.update u.view u.subs]
12514−::
12515−++ program-empty-null
12516− |= e=expr
12517− ^- ?
12518− ?- -.e
12519− %lit =(%null form.lit.e)
12520− %cast $(e val.e)
12521− %group $(e inner.e)
12522− %body ?~(defs.e $(e final.e) |)
12523− * |
12524− ==
12525−::
12526−++ program-subs-empty
12527− |= d=def
12528− ^- ?
12529− ?. ?=(%value -.d) |
12530− ?- -.val.d
12531− %gate (program-empty-null body.val.d)
12532− %gate-wide (program-empty-null body.val.d)
12533− * |
12534− ==
12535−::
12536−++ program-transparent
12537− |= e=expr
12538− ^- expr
12539− ?- -.e
12540− %group $(e inner.e)
12541− %cast $(e val.e)
12542− %body ?~(defs.e $(e final.e) e)
12543− * e
12544− ==
12545−++ program-init-tuple-null
12546− |= d=def
12547− ^- ?
12548− ?. ?=(%value -.d) |
12549− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) |
12550− =/ body=expr
12551− ?- -.val.d
12552− %gate body.val.d
12553− %gate-wide body.val.d
12554− * !!
12555− ==
12556− =. body (program-transparent body)
12557− ?. ?=(%tuple -.body) |
12558− ?~ items.body |
12559− (program-empty-null val:(rear items.body))
12560−::
12561−:: Recover only the initializer of an already recognized direct program main.
12562−:: The derived call is evidence for an ordinary init/main retry, never an
12563−:: interface to publish on its own. Any failure returns the original resolution.
12564−++ program-init-context
12565− |= [main=def parts=[init=term update=term view=term subs=term] ds=(list def) resolution=iresolved initial=istate]
12566− ^- (unit iresolved)
12567− =/ env=ienv env.resolution
12568− ?^ (ienv-lookup %main env) ~
12569− ?^ (ienv-lookup init.parts env) ~
12570− =/ update=(unit ischeme) (ienv-lookup update.parts env)
12571− =/ view=(unit ischeme) (ienv-lookup view.parts env)
12572− =/ subs=(unit ischeme) (ienv-lookup subs.parts env)
12573− ?~ update ~
12574− ?~ view ~
12575− ?~ subs ~
12576− =/ inits=(list def)
12577− (skim ds |=(d=def &(?=(%value -.d) =(init.parts name.d))))
12578− ?. ?=([* ~] inits) ~
12579− =/ init-def=def i.inits
12580− ?> ?=(%value -.init-def)
12581− ?. (program-init-tuple-null init-def) ~
12582− =/ args=(unit (list expr)) (program-main-args main)
12583− ?~ args ~
12584− ?~ prelude.initial ~
12585− =/ program=(unit ischeme) (ienv-lookup %program values.u.prelude.initial)
12586− ?~ program ~
12587− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude.initial)
12588− ?~ heads ~
12589− =/ written=(unit def) (~(get by gates.u.heads) %program)
12590− ?~ written ~
12591− =/ written-sample=(unit sample) (direct-gate-sample u.written)
12592− ?~ written-sample ~
12593− ?. ?=(%cell -.u.written-sample) ~
12594− ?~ items.u.written-sample ~
12595− =/ checked=(map term def) (direct-checked-gates ds env)
12596− =/ templates=ienv
12597− (turn molds.u.prelude.initial |=(x=[name=term template=ischeme] [name.x template.x]))
12598− =/ scanned=(unit dgscan)
12599− (dg-all-env-ids (weld env (weld values.u.prelude.initial templates)) 32.768 ~)
12600− ?~ scanned ~
12601− =. next.initial (dg-next-id ids.u.scanned 0)
12602− =/ instance=[typ=itype state=istate] (instantiate-scheme u.program initial)
12603− ?. ?=(%fn -.typ.instance) ~
12604− ?. ?=(%cell -.sample.typ.instance) ~
12605− =/ expected-init=(unit itype)
12606− (direct-slot-body hed.sample.typ.instance (direct-sample-name i.items.u.written-sample))
12607− ?~ expected-init ~
12608− ?. ?=(%fn -.u.expected-init) ~
12609− ?. ?=(%var -.sample.u.expected-init) ~
12610− =/ data=@ud id.sample.u.expected-init
12611− =/ init-var=itype [%var next.state.instance]
12612− =/ st=istate state.instance(next +(next.state.instance))
12613− =/ up=[typ=itype state=istate] (instantiate-scheme u.update st)
12614− =/ vw=[typ=itype state=istate] (instantiate-scheme u.view state.up)
12615− =/ sb=[typ=itype state=istate] (instantiate-scheme u.subs state.vw)
12616− =. st state.sb(gate-defs checked, head-evidence heads)
12617− =/ actual=itype [%cell init-var [%cell typ.up [%cell typ.vw typ.sb]]]
12618− =/ fit=ifit
12619− (direct-positional-fit u.args items.u.written-sample actual sample.typ.instance env st sub.st next.st)
12620− ?. ?=(%ok -.fit) ~
12621− =/ actual-final=itype (itype-normalize actual sub.fit)
12622− =/ expected-final=itype (itype-normalize sample.typ.instance sub.fit)
12623− =/ open=(list @ud)
12624− (unique-type-vars (weld (itype-vars actual-final) (itype-vars expected-final)))
12625− ?. (levy open |=(n=@ud =(data n))) ~
12626− ?: |((itype-has-tag actual-final) (itype-has-tag expected-final)) ~
12627− =/ replay=ifit
12628− (direct-positional-fit u.args items.u.written-sample actual sample.typ.instance env st sub.fit next.fit)
12629− ?. ?=(%ok -.replay) ~
12630− ?. &(=(sub.fit sub.replay) =(next.fit next.replay)) ~
12631− =/ expected=itype (itype-normalize u.expected-init sub.fit)
12632− ?. ?=(%fn -.expected) ~
12633− =. st st(sub sub.fit, next next.fit)
12634− =/ init-state=istate (reserve-def-caps val.init-def st)
12635− =/ inferred=iresult (infer-fragment val.init-def env init-state)
12636− =? inferred ?=(%| -.inferred) (infer-recursive-gate init-def env init-state)
12637− ?: ?=(%| -.inferred) ~
12638− ?. ?=(%fn -.typ.p.inferred) ~
12639− =/ data-fit=ifit
12640− (itype-fit sample.typ.p.inferred sample.expected sub.state.p.inferred next.state.p.inferred)
12641− ?. ?=(%ok -.data-fit) ~
12642− =/ closed=itype (itype-normalize expected sub.data-fit)
12643− ?. ?=(%fn -.closed) ~
12644− :: Resolve the ordinary tuple cast first, then check the complete gate.
12645− :: General function fit remains unchanged; only this recovered candidate
12646− :: receives the derived result context before its whole-type cast fit.
12647− =/ product-fit=ifit
12648− (itype-fit product.typ.p.inferred product.closed sub.data-fit next.data-fit)
12649− ?. ?=(%ok -.product-fit) ~
12650− =/ product=itype
12651− (itype-merge-faces product.typ.p.inferred product.closed sub.product-fit)
12652− =/ actual-cast=itype [%fn sample.typ.p.inferred product]
12653− =/ cast=ifit
12654− (itype-fit actual-cast closed sub.product-fit next.product-fit)
12655− ?. ?=(%ok -.cast) ~
12656− =/ merged=itype (itype-merge-faces actual-cast closed sub.cast)
12657− =/ adjusted=iresult
12658− [%& merged state.p.inferred(sub sub.cast, next next.cast)]
12659− =/ added=(unit iadded-definition)
12660− (add-supported-result init-def adjusted init-state env checked artifacts.resolution)
12661− ?~ added ~
12662− =/ recovered=(unit ischeme) (ienv-lookup init.parts env.u.added)
12663− ?~ recovered ~
12664− ?. ?=(~ vars.u.recovered) ~
12665− ?. ?=(~ (itype-vars typ.u.recovered)) ~
12666− =/ completed=[env=ienv artifacts=(list iwidth-definition)]
12667− (add-supported-defs-core ~[main] ds checked.u.added heads env.u.added molds.initial globals.initial externals.initial surs.initial mark-externals.initial marks.initial jimports.initial reserved-molds.initial at.initial prelude.initial artifacts.u.added grec-index.initial)
12668− ?~ (ienv-lookup %main env.completed) ~
12669− `[env.completed grouped.resolution artifacts.completed]
12670−::
12671−++ program-subs-watch
12672− |= [d=def imports=ijimports graph=irequest-graph prelude=ifile]
12673− ^- ?
12674− ?. ?=(%value -.d) |
12675− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) |
12676− =/ body=expr
12677− ?- -.val.d
12678− %gate body.val.d
12679− %gate-wide body.val.d
12680− * val.d
12681− ==
12682− =. body (program-transparent body)
12683− ?. ?=(%list -.body) |
12684− ?. ?=([* ~] items.body) |
12685− =/ watch=expr (program-transparent i.items.body)
12686− ?. ?=(%tuple -.watch) |
12687− ?. ?=([* * ~] items.watch) |
12688− =/ tag=item i.items.watch
12689− =/ payload=item i.t.items.watch
12690− ?. &(?=(~ face.tag) ?=(~ face.payload)) |
12691− =/ tag-expr=expr (program-transparent val.tag)
12692− ?. ?=(%lit -.tag-expr) |
12693− ?. &(?=(%term form.lit.tag-expr) =(%watch val.lit.tag-expr)) |
12694− =/ request=expr (program-transparent val.payload)
12695− ?. ?=(%call -.request) |
12696− ?. ?=([* ~] args.request) |
12697− =/ head=expr (program-transparent head.request)
12698− ?. ?=(%wing -.head) |
12699− ?. ?=([@ @ ~] names.head) |
12700− =/ case=term i.names.head
12701− =/ face=term i.t.names.head
12702− =/ callback=expr (program-transparent i.args.request)
12703− ?. ?=(%ctor -.callback) |
12704− ?. ?=(%term form.tag.callback) |
12705− =/ selected=(list [face=term interface=ifile])
12706− (skim imports |=(j=[face=term interface=ifile] =(face face.j)))
12707− ?. ?=([* ~] selected) |
12708− =/ iface=ifile interface.i.selected
12709− =/ member=(unit ischeme) (ienv-lookup case values.iface)
12710− ?~ member |
12711− ?~ source.iface |
12712− =/ evidence=(list irequest-evidence)
12713− (skim requests.graph |=(r=irequest-evidence &(=(api-at.r at.iface) =(name.r case))))
12714− ?. ?=([* ~] evidence) |
12715− =/ request-evidence=irequest-evidence i.evidence
12716− ?. =(u.source.iface api-source.request-evidence) |
12717− ?. =(name.path.path.request-evidence case) |
12718− ?~ graph.iface |
12719− ?. (lien requests.u.graph.iface |=(r=irequest-evidence =(r request-evidence))) |
12720− ?. ?=(~ scry.path.path.request-evidence) |
12721− ?. &(?=(~ diffs.path.request-evidence) ?=(~ diffs.path.path.request-evidence)) |
12722− ?: (lien segments.path.path.request-evidence |=(p=pseg !?=(%knot -.p))) |
12723− ?. ?=([@ ~] vars.u.member) |
12724− =/ message=@ud i.vars.u.member
12725− ?. ?=(%fn -.typ.u.member) |
12726− ?. ?=(%fn -.sample.typ.u.member) |
12727− ?. =(sample.sample.typ.u.member full.path.request-evidence) |
12728− ?. =(product.sample.typ.u.member [%var message]) |
12729− =/ prep=iprelude [prelude prelude-values.graph prelude-molds.graph]
12730− =/ ask=(unit ischeme) (request-compatible-ask prep)
12731− ?~ ask |
12732− =/ result=(unit itype) (template-apply u.ask ~[[%var message]])
12733− ?~ result |
12734− =(product.typ.u.member u.result)
12735−::
12736−++ program-main-closed
12737− |= [parts=[init=term update=term view=term subs=term] ds=(list def) env=ienv prelude=(unit ifile) imports=ijimports graph=irequest-graph]
12738− ^- ?
12739− ?~ prelude |
12740− ?~ (ienv-lookup %program values.u.prelude) |
12741− =/ program=(unit ischeme) (find-jibb-mold %program u.prelude)
12742− ?~ program |
12743− =/ main=(unit ischeme) (ienv-lookup %main env)
12744− ?~ main |
12745− ?. ?=(~ vars.u.main) |
12746− ?. ?=(~ (itype-vars typ.u.main)) |
12747− =/ instance=[typ=itype state=istate] (instantiate-scheme u.program *istate)
12748− =/ main-fit=ifit (direct-invariant typ.u.main typ.instance ~ next.state.instance)
12749− ?. ?=(%ok -.main-fit) |
12750− =/ init=(unit ischeme) (ienv-lookup init.parts env)
12751− ?~ init |
12752− ?. ?=(~ vars.u.init) |
12753− ?. ?=(%fn -.typ.u.init) |
12754− ?. ?=(~ (itype-vars sample.typ.u.init)) |
12755− ?. ?=(~ (itype-vars product.typ.u.init)) |
12756− =/ data=igate-free (gate-free-type sample.typ.u.init 256 ~)
12757− ?. =(%yes verdict.data) |
12758− =/ model=igate-free (gate-free-type product.typ.u.init left.data ~)
12759− ?. =(%yes verdict.model) |
12760− =/ subs=(list def)
12761− (skim ds |=(d=def &(?=(%value -.d) =(subs.parts name.d))))
12762− ?. ?=([* ~] subs) |
12763− |((program-subs-empty i.subs) (program-subs-watch i.subs imports graph u.prelude))
12764−::
127657459++ infer-jibb-file
127667460 |= [at=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle active=(list path) prelude-values=(list term) prelude-molds=(list term) cache=jcache prelude=(unit ifile)]
127677461 ^- jfile-result
12768− =/ out=jfile-detailed-result
12769− (infer-jibb-file-detailed at src externals mark-externals modules active prelude-values prelude-molds cache prelude)
12770− ?: ?=(%| -.out) [%| message.p.out]
12771− [%& p.out]
12772−:: Returns structured root-source overlap evidence after the same full check.
12773−++ infer-jibb-file-detailed
12774− |= [at=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle active=(list path) prelude-values=(list term) prelude-molds=(list term) cache=jcache prelude=(unit ifile)]
12775− ^- jfile-detailed-result
7462+ ?: ?=([%ui %api *] at) [%| (crip "API module needs unsupported inference: {(spud at)}")]
127767463 =/ parsed (parse at src)
12777− ?: ?=(%| -.parsed) [%| [(crip "module source does not parse: {(spud at)}") ~]]
7464+ ?: ?=(%| -.parsed) [%| (crip "module source does not parse: {(spud at)}")]
127787465 =/ mod=module p.parsed
12779− =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
12780− ?^ duplicate [%| [(show-duplicate-fields at src u.duplicate) ~]]
12781− ?: &(?=([%ui %api *] at) ?=(^ (program-main-def defs.mod)))
12782− [%| [(crip "module kind needs unsupported inference: {(spud at)}") ~]]
12783− ?: ?=([%ui %api *] at)
12784− =/ iface=(unit ifile) (api-poke-interface at mod mark-externals prelude-values prelude-molds prelude)
12785− ?^ iface
12786− =/ checked=ifile u.iface(source `src, graph `[(silt `(list path)`~[at]) ~ modules prelude prelude-values prelude-molds externals mark-externals])
12787− [%& [checked [[at checked] cache]]]
12788− ?~ prelude [%| [(crip "API module needs unsupported inference: {(spud at)}") ~]]
12789− =/ prepared=iprelude [u.prelude prelude-values prelude-molds]
12790− =/ narrow=?
12791− ?. ?=([[%mark *] ~] imports.mod) |
12792− ?. ?=([[%mold *] ~] defs.mod) |
12793− ?. =(%paths name.i.defs.mod) |
12794− !?=(%union -.shape.i.defs.mod)
12795− ?: narrow
12796− =/ request=(each ione-request-interface @t)
12797− (one-request-interface-graph at src externals mark-externals modules active cache `prepared)
12798− ?: ?=(%| -.request) [%| [(crip "API module needs unsupported inference: {(spud at)}") ~]]
12799− =/ checked=ifile iface.p.request
12800− [%& [checked [[at checked] dependencies.paths.support.p.request]]]
12801− =/ multi=(each [iface=ifile cache=jcache] @t)
12802− (multi-request-interface-graph at src externals mark-externals modules active cache `prepared)
12803− ?: ?=(%| -.multi) [%| [(crip "API module needs unsupported inference: {(spud at)}") ~]]
12804− [%& [iface.p.multi [[at iface.p.multi] cache.p.multi]]]
12805− ?. (module-scope-valid mod prelude-values prelude-molds)
12806− ?: (pending-declared-poke at mod prelude-values prelude-molds)
12807− [%| [(crip "module kind or scope needs unsupported inference: {(spud at)}") ~]]
12808− [%| [(crip "module has conflicting names: {(spud at)}") ~]]
7466+ ?. (module-scope-valid mod prelude-values prelude-molds) [%| (crip "module has conflicting names: {(spud at)}")]
128097467 =/ vals=(list term) (global-value-names defs.mod)
12810− =/ main=(unit def) (program-main-def defs.mod)
12811− =/ main-parts=(unit [init=term update=term view=term subs=term])
12812− ?~(main ~ (program-main-parts u.main))
12813− ?. ?~(main & &(!?=([%ui %stores *] at) ?=(^ main-parts)))
12814− [%| [(crip "module kind needs unsupported inference: {(spud at)}") ~]]
12815− =/ js=jimports-detailed-result (resolve-jibb-imports-detailed imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
7468+ ?: (lien vals |=(n=term =(n %main)))
7469+ [%| (crip "module kind needs unsupported inference: {(spud at)}")]
7470+ =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
128167471 ?: ?=(%| -.js) [%| p.js]
12817− =/ collected=grec-collected
12818− ?^ imports.mod [(collect-simple-molds defs.mod) *(map term shape)]
12819− (grec-collect-molds defs.mod)
12820− =/ molds=imolds molds.collected
7472+ =/ molds=imolds (collect-simple-molds defs.mod)
128217473 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
128227474 =/ surs=(list term) (collect-sur-imports imports.mod)
128237475 =/ marks=(list term) (collect-mark-imports imports.mod)
128247476 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
128257477 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
12826− =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~ ~ ~]
12827− :: Source and scope were checked above; preserve that exact root and prelude.
12828− :: This first integration only indexes import-free library sources.
12829− =/ index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])
12830− ?^ imports.mod ~
12831− ?~ prelude ~
12832− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude)
12833− ?~ standard ~
12834− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]]) ~
12835− =/ index=(map term shape) proofs.collected
12836− ?. !=(index *(map term shape)) ~
12837− ?: (lien molds |=(m=[name=term body=shape] =(%list name.m))) ~
12838− `[at src u.prelude index]
12839− =. grec-index.state index
12840− =/ mts=(each imold-types imold-failure) (module-mold-types-detail molds state)
12841− ?: ?=(%| -.mts)
12842− ?~ overlap.p.mts [%| [(crip "{(trip message.p.mts)}: {(spud at)}") ~]]
12843− =/ witness=[name=term cases=upair] u.overlap.p.mts
12844− =/ first=@t (show-error src [at line.beg.first.cases.witness col.beg.first.cases.witness "first union case"])
12845− =/ second=@t (show-error src [at line.beg.second.cases.witness col.beg.second.cases.witness "overlapping case"])
12846− =/ msg=@t (of-wain:format ~[(crip "module mold {(trip name.witness)} has overlapping cases") first second])
12847− [%| [msg `[at src name.witness cases.witness]]]
12848− =/ resolution=iresolved
12849− ?~ index
12850− (resolve-groups defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
12851− (resolve-groups-core defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude index)
12852− =/ env=ienv env.resolution
12853− =/ recovered=(unit iresolved)
12854− ?~ main ~
12855− ?~ main-parts ~
12856− (program-init-context u.main u.main-parts defs.mod resolution state)
12857− =. env ?~(recovered env env.u.recovered)
12858− =. artifacts.resolution
12859− ?~(recovered artifacts.resolution artifacts.u.recovered)
12860− =. env
12861− ?: (module-values-complete defs.mod env) env
12862− ?: |(?=([%ui %stores *] at) ?=(^ imports.mod) ?=(^ prelude) ?=(^ prelude-values) ?=(^ prelude-molds)) env
12863− ?: (gth (met 3 src) 65.536) env
12864− ?: (gth (lent defs.mod) 64) env
12865− ?. (dg-source-candidate defs.mod 64) env
12866− =/ transaction=(unit dgcommit) (dg-root-source at src)
12867− ?~ transaction env
12868− ?: (dg-interface-safe env.u.transaction) env.u.transaction
12869− env
7478+ =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude]
7479+ =/ mts=(each imold-types @t) (module-mold-types molds state)
7480+ ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
7481+ =/ env=ienv (resolve-supported-defs defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
128707482 ?. (module-values-complete defs.mod env)
12871− [%| [(crip "module definitions need unsupported inference: {(spud at)}") ~]]
12872− =/ initial=irequest-graph [(silt `(list path)`~[at]) ~ modules prelude prelude-values prelude-molds externals mark-externals]
12873− =/ graph=(unit irequest-graph) (request-graph-merge resolved.p.js initial (add 1 (lent resolved.p.js)))
12874− ?~ graph [%| ['module request evidence needs unsupported inference' ~]]
12875− ?. ?~(main & ?~(main-parts | (program-main-closed u.main-parts defs.mod env prelude resolved.p.js u.graph)))
12876− [%| [(crip "module kind needs unsupported inference: {(spud at)}") ~]]
12877− =/ iface=ifile [env p.mts at ~ artifacts.resolution ~ `src graph]
12878− [%& [iface [[at iface] cache.p.js]]]
12879−::
12880−:: A source-bound analysis of one named mold, not a module, island,
12881−:: request, watchability or runtime check. The host owns the trusted
12882−:: prepared prelude, canonical paths and reader/source version identities.
12883−:: The 256-node cap covers only classification, not source/graph work.
12884−+$ igate-free-mold
12885− [at=path source=@t name=term prepared=iprelude externals=iexternals marks=imark-externals modules=jbundle dependencies=jcache mold=ischeme requested=@ud budget=@ud result=igate-free]
12886−++ gate-free-mold-source
12887− |= [file=path src=@t name=term externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude) fuel=@ud]
12888− ^- (each igate-free-mold @t)
12889− ?~ file [%| 'mold analysis needs a path ending in jibb']
12890− ?. =(%jibb (rear file)) [%| 'mold analysis needs a path ending in jibb']
12891− ?: |(=(file /lib/jibb/internal/jibb) =(file /lib/jibb/primitives/jibb))
12892− [%| 'the prelude internal modules are private']
12893− ?: ?=([%ui %api *] file) [%| 'API declarations need unsupported mold analysis']
12894− ?: ?=([%ui %stores *] file) [%| 'store declarations need unsupported mold analysis']
12895− =/ entries=jbundle (skim modules |=(m=jsource =(file at.m)))
12896− ?: (gth (lent entries) 1) [%| 'duplicate root module sources']
12897− =/ wrong-root=? ?~(entries | !=(source.i.entries src))
12898− ?: wrong-root [%| 'root module source does not match bundle']
12899− =/ parsed (parse file src)
12900− ?: ?=(%| -.parsed) [%| 'mold source does not parse']
12901− =/ mod=module p.parsed
12902− =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
12903− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
12904− ?~ prepared [%| 'mold analysis needs the prepared prelude']
12905− ?. (module-scope-valid mod values.u.prepared molds.u.prepared)
12906− [%| 'mold source has conflicting or unsupported scope']
12907− =/ selected=(list def)
12908− (skim defs.mod |=(d=def &(?=(%mold -.d) =(name.d name))))
12909− ?~ selected [%| 'selected mold is not declared']
12910− ?^ t.selected [%| 'selected mold is not unique']
12911− ?> ?=(%mold -.i.selected)
12912− =/ public=ifile iface.u.prepared
12913− =/ js=jimports-result
12914− (resolve-jibb-imports imports.mod externals marks modules ~[file] values.u.prepared molds.u.prepared ~ `public)
12915− ?: ?=(%| -.js) [%| p.js]
12916− =/ ms=imolds (collect-simple-molds defs.mod)
12917− =/ vals=(list term) (global-value-names defs.mod)
12918− =/ globals=(list term) (weld values.u.prepared (weld (import-binding-names imports.mod) vals))
12919− =/ surs=(list term) (collect-sur-imports imports.mod)
12920− =/ declared=(list term) (collect-mark-imports imports.mod)
12921− =/ reserved=(list term) (weld molds.u.prepared (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
12922− =/ top=(list term) (turn ms |=(m=[name=term body=shape] name.m))
12923− =/ state=istate [0 ~ ~ ~ ms globals externals surs marks declared resolved.p.js reserved ~ ~ ~ | file top `public ~ 256 ~ ~ ~ ~ ~ ~]
12924− =/ inferred=(unit [template=ischeme state=istate])
12925− (infer-mold-template shape.i.selected state(active ~[name], in-mold &))
12926− ?~ inferred [%| 'selected mold needs unsupported inference']
12927− =/ template=ischeme template.u.inferred
12928− =. typ.template (label-direct-union typ.template shape.i.selected name state)
12929− =. typ.template (itype-normalize typ.template sub.state.u.inferred)
12930− =/ cap=@ud (min fuel 256)
12931− =/ analysis=igate-free (gate-free-type typ.template cap ~)
12932− [%& [file src name u.prepared externals marks modules cache.p.js template fuel cap analysis]]
7483+ [%| (crip "module definitions need unsupported inference: {(spud at)}")]
7484+ [%& [[env p.mts at] [[at [env p.mts at]] cache.p.js]]]
129337485::
129347486:: +golden-types-with-modules fails closed for imports without prelude
129357487:: scope. +golden-types-with-prelude resolves supported library graphs;
@@ -12940,8 +7492,6 @@
129407492 ^- @t
129417493 =/ parsed (parse file src)
129427494 ?: ?=(%| -.parsed) (show-error src p.parsed)
12943− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
12944− ?^ duplicate (duplicate-fields-report file src u.duplicate)
129457495 ?: (lien imports.p.parsed |=(i=import ?=(%jibb -.i)))
129467496 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
129477497 (golden-types-with-marks file src externals mark-externals)
@@ -12956,8 +7506,6 @@
129567506 ^- @t
129577507 =/ parsed (parse file src)
129587508 ?: ?=(%| -.parsed) (show-error src p.parsed)
12959− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
12960− ?^ duplicate (duplicate-fields-report file src u.duplicate)
129617509 ?: =(0 prelude-source) 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
129627510 =/ prelude (parse /lib/jibb/prelude/jibb prelude-source)
129637511 ?: ?=(%| -.prelude) 'partial inference; module not checked\0aprelude source does not parse; module import inference unsupported'
@@ -12965,55 +7513,28 @@
129657513 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
129667514 (golden-types-with-prepared-prelude file src externals mark-externals modules prepared)
129677515::
12968−++ golden-types-with-prelude-and-internal
12969− |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prelude-source=@t internal-source=@t]
12970− ^- @t
12971− =/ prepared=(unit iprelude) (prepare-prelude-with-internal prelude-source internal-source)
12972− (golden-types-with-prepared-prelude file src externals mark-externals modules prepared)
12973−::
129747516++ golden-types-with-prepared-prelude
129757517 |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prepared=(unit iprelude)]
129767518 ^- @t
129777519 =/ parsed (parse file src)
129787520 ?: ?=(%| -.parsed) (show-error src p.parsed)
12979− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
12980− ?^ duplicate (duplicate-fields-report file src u.duplicate)
129817521 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
129827522 =/ prelude-values=(list term) values.u.prepared
129837523 =/ prelude-molds=(list term) molds.u.prepared
129847524 =/ iface=(unit ifile) `iface.u.prepared
129857525 ?. (module-scope-valid p.parsed prelude-values prelude-molds)
12986− ?: (pending-declared-poke file p.parsed prelude-values prelude-molds)
12987− 'partial inference; module not checked\0amodule kind or scope needs unsupported inference'
129887526 'partial inference; module not checked\0amodule has conflicting names'
129897527 =/ js=jimports-result
129907528 (resolve-jibb-imports imports.p.parsed externals mark-externals modules ~[file] prelude-values prelude-molds ~ iface)
129917529 ?: ?=(%| -.js) (of-wain:format ~['partial inference; module not checked' p.js])
129927530 =/ scope-values=(list term)
129937531 (weld prelude-values (weld (collect-sur-imports imports.p.parsed) (collect-mark-imports imports.p.parsed)))
12994− (golden-types-in-context-core file src externals mark-externals resolved.p.js scope-values prelude-molds iface prepared)
7532+ (golden-types-in-context file src externals mark-externals resolved.p.js scope-values prelude-molds iface)
129957533::
129967534:: +golden-types-with-marks: supply declared mark types separately from /sur
129977535:: entries, as [mark result] with the result from +read-mark:jibb-import.
129987536:: Unknown, duplicated, failed and undeclared entries never resolve a mold.
129997537::
13000−:: Callers pass unchanged structured reader results; graph validation
13001−:: remains in the existing bridge, and failures stay available lazily.
13002−++ reader-result-for-checker
13003− |= result=*
13004− ^- *
13005− ?: ?=([%ok *] result) [%& +.result]
13006− result
13007−::
13008−++ golden-types-with-reader-diagnostics
13009− |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
13010− ^- @t
13011− =/ ex=iexternals
13012− (turn externals |=(e=[module=term name=term result=*] [module.e name.e (reader-result-for-checker result.e)]))
13013− =/ mx=imark-externals
13014− (turn mark-externals |=(e=[mark=term result=*] [mark.e (reader-result-for-checker result.e)]))
13015− (golden-types-with-marks file src ex mx)
13016−::
130177538++ golden-types-with-marks
130187539 |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
130197540 ^- @t
@@ -13022,60 +7543,15 @@
130227543++ golden-types-in-context
130237544 |= [file=path src=@t externals=iexternals mark-externals=imark-externals jimports=ijimports prelude-values=(list term) reserved-molds=(list term) prelude=(unit ifile)]
130247545 ^- @t
13025− (golden-types-in-context-core file src externals mark-externals jimports prelude-values reserved-molds prelude ~)
13026−++ golden-types-in-context-core
13027− |= [file=path src=@t externals=iexternals mark-externals=imark-externals jimports=ijimports prelude-values=(list term) reserved-molds=(list term) prelude=(unit ifile) prepared=(unit iprelude)]
13028− ^- @t
130297546 =. reserved-molds (weld reserved-molds (turn jimports |=(j=[face=term interface=ifile] face.j)))
130307547 =/ parsed (parse file src)
130317548 ?: ?=(%| -.parsed) (show-error src p.parsed)
13032− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
13033− ?^ duplicate (duplicate-fields-report file src u.duplicate)
13034− ?: (module-has-reserved-proj p.parsed)
13035− 'module has reserved proj name'
130367549 =/ ds=(list def) defs.p.parsed
130377550 =/ molds=imolds (collect-simple-molds ds)
130387551 =/ globals=(list term) (weld prelude-values (weld (turn jimports |=(j=[face=term interface=ifile] face.j)) (global-value-names ds)))
130397552 =/ surs=(list term) (collect-sur-imports imports.p.parsed)
130407553 =/ marks=(list term) (collect-mark-imports imports.p.parsed)
13041− =/ resolution=iresolved (resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds file prelude)
13042− =/ cycles=(list icycle) (definite-value-cycles ds globals)
13043− =/ env=ienv env.resolution
13044− =/ recovered=(list term) ~
13045− =/ eligible=?
13046− ?& ?=(~ imports.p.parsed)
13047− ?=(~ jimports)
13048− !?=([%ui %api *] file)
13049− !?=([%ui %stores *] file)
13050− !(lien (global-value-names ds) |=(n=term =(n %main)))
13051− !(module-values-complete ds env)
13052− (lte (met 3 src) 65.536)
13053− (lte (lent ds) 64)
13054− ?| &(?=(~ prepared) ?=(~ prelude) ?=(~ prelude-values) ?=(~ reserved-molds) (module-scope-valid p.parsed ~ ~) (dg-source-candidate ds 64))
13055− ?& ?=(^ prepared)
13056− ?=(^ prelude)
13057− =(u.prelude iface.u.prepared)
13058− =(prelude-values values.u.prepared)
13059− =(reserved-molds molds.u.prepared)
13060− (module-scope-valid p.parsed values.u.prepared molds.u.prepared)
13061− (dg-prepared-candidate ds 64)
13062− ==
13063− ==
13064− ==
13065− =/ transaction=(unit dgcommit)
13066− ?. eligible ~
13067− ?~ prepared (dg-root-source file src)
13068− (dg-root-prepared file src u.prepared)
13069− =. recovered
13070− ?~ transaction ~
13071− ?. &((module-values-complete ds env.u.transaction) (dg-interface-safe env.u.transaction)) ~
13072− (turn (skim env.u.transaction |=(entry=[name=term scheme=ischeme] ?=(~ (ienv-lookup name.entry env)))) |=(entry=[name=term scheme=ischeme] name.entry))
13073− =. env
13074− ?~ transaction env
13075− ?: &((module-values-complete ds env.u.transaction) (dg-interface-safe env.u.transaction)) env.u.transaction
13076− env
13077− =/ source-defs=(map term def) (direct-checked-gates ds env)
13078− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude)
7554+ =/ env=ienv (resolve-supported-defs ds molds globals externals surs mark-externals marks jimports reserved-molds file prelude)
130797555 =/ lines=(list @t) ~
130807556 |-
130817557 ?~ ds (of-wain:format ['partial inference; module not checked' (flop lines)])
@@ -13084,42 +7560,14 @@
130847560 $(ds t.ds, lines [(show-partial-mold file src d molds) lines])
130857561 ?. (unique-value-name name.d globals)
130867562 $(ds t.ds, lines [(crip "++ {(trip name.d)}: name already in scope") lines])
13087− =/ cycle=(list icycle) (skim cycles |=(c=icycle =(name.c name.d)))
13088− ?^ cycle
13089− =/ diag=idiag ["non-gate value depends on itself through a cycle" ~[[first.i.cycle "value in cycle"] [next.i.cycle "dependency in cycle"]]]
13090− $(ds t.ds, lines [(show-inference-diagnostic file src name.d diag) lines])
13091− ?: (lien recovered |=(n=term =(n name.d)))
13092− =/ found=(unit ischeme) (ienv-lookup name.d env)
13093− ?~ found $(ds t.ds, lines [(crip "++ {(trip name.d)}: committed definition unavailable") lines])
13094− ?: (itype-has-hidden-recursive typ.u.found)
13095− $(ds t.ds, lines [(crip "++ {(trip name.d)}: recursive mold name is not available in this scope") lines])
13096− ?: (itype-has-hidden-generic typ.u.found)
13097− $(ds t.ds, lines [(crip "++ {(trip name.d)}: generic union name is not available in this scope") lines])
13098− =/ typ=itype (canonical-itype typ.u.found vars.u.found)
13099− =/ line=@t (crip "++ {(trip name.d)}: {(show-itype typ ~)}{(show-atom-constraint typ)}")
13100− $(ds t.ds, lines [line lines])
13101− ?: (lien grouped.resolution |=(n=term =(n name.d)))
13102− =/ found=(unit ischeme) (ienv-lookup name.d env)
13103− ?~ found $(ds t.ds, lines [(crip "++ {(trip name.d)}: recursive group unavailable") lines])
13104− =/ typ=itype (canonical-itype typ.u.found vars.u.found)
13105− =/ line=@t (crip "++ {(trip name.d)}: {(show-itype typ ~)}{(show-atom-constraint typ)}")
13106− $(ds t.ds, lines [line lines])
131077563 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
13108− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~ ~ ~]
13109− =. gate-defs.initial source-defs
13110− =. head-evidence.initial heads
13111− =. initial (reserve-def-caps val.d initial)
7564+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude]
131127565 =/ result=iresult
131137566 ?: |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
131147567 (infer-recursive-gate d env initial)
131157568 (infer-fragment val.d env initial)
131167569 ?: ?=(%| -.result)
131177570 $(ds t.ds, lines [(show-inference-diagnostic file src name.d p.result) lines])
13118− =. state.p.result (promote-restricted-numbers state.p.result env)
13119− =. state.p.result (default-hole-numbers holes.state.p.result holes.initial state.p.result env !(itype-has-gate (itype-normalize typ.p.result sub.state.p.result)))
13120− =/ hole=(unit idiag) (unresolved-hole holes.state.p.result holes.initial state.p.result)
13121− ?^ hole
13122− $(ds t.ds, lines [(show-inference-diagnostic file src name.d u.hole) lines])
131237571 =/ merged=(unit [first=icap second=icap])
131247572 (merged-capitals caps.state.p.result sub.state.p.result)
131257573 ?^ merged
@@ -13142,672 +7590,7 @@
131427590 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
131437591 ?: (gth (lent vars) 26)
131447592 $(ds t.ds, lines [(crip "++ {(trip name.d)}: too many variables for partial printer") lines])
13145− ?~ (width-finalize projections.state.p.result sub.state.p.result vars)
13146− $(ds t.ds, lines [(crip "++ {(trip name.d)}: record projection elaboration needs unsupported inference") lines])
131477593 =/ printable=itype (canonical-itype typ vars)
131487594 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
131497595 $(ds t.ds, lines [line lines])
13150−:: Experimental module-owned pending-constraint generalization only.
13151−:: Inputs, IDs and substitution come from one checker-owned transaction.
13152−+$ dgscan [ids=(list @ud) fuel=@ud]
13153−++ dg-scan
13154− |= [todo=(list itype) sub=isub fuel=@ud ids=(list @ud)]
13155− ^- (unit dgscan)
13156− ?~ todo `[ids fuel]
13157− ?: =(0 fuel) ~
13158− =. fuel (dec fuel)
13159− =/ t=itype i.todo
13160− ?: ?=(?(%var %avar %rvar %nvar %rnvar %tag) -.t)
13161− =/ node-id=@ud ?:(?=(%tag -.t) id.t +.t)
13162− =/ found=(unit itype) (itype-lookup node-id sub)
13163− ?~ found $(todo t.todo, ids [node-id ids])
13164− ?: &(?=(?(%rvar %rnvar) -.u.found) =(node-id +.u.found))
13165− $(todo t.todo, ids [node-id ids])
13166− $(todo [u.found t.todo])
13167− ?: ?=(%jrec -.t) $(todo t.todo)
13168− ?+ -.t ~
13169− %collection $(todo (weld args.t t.todo))
13170− %union $(todo (weld args.t (weld cases.t t.todo)))
13171− %face $(todo [body.t t.todo])
13172− %fn $(todo [sample.t product.t t.todo])
13173− %cell $(todo [hed.t tal.t t.todo])
13174− %atom $(todo t.todo)
13175− %any-atom $(todo t.todo)
13176− %flag $(todo t.todo)
13177− %noun $(todo t.todo)
13178− %empty $(todo t.todo)
13179− %const $(todo t.todo)
13180− ==
13181−::
13182−++ dg-scan-ids
13183− |= [ids=(list @ud) sub=isub fuel=@ud blocked=(list @ud)]
13184− ^- (unit dgscan)
13185− ?~ ids `[blocked fuel]
13186− =/ one=(unit dgscan) (dg-scan ~[[%var i.ids]] sub fuel blocked)
13187− ?~ one ~
13188− $(ids t.ids, fuel fuel.u.one, blocked ids.u.one)
13189−::
13190−++ dg-env
13191− |= [env=ienv sub=isub fuel=@ud blocked=(list @ud)]
13192− ^- (unit dgscan)
13193− ?~ env `[blocked fuel]
13194− =/ sc=ischeme scheme.i.env
13195− :: Quantifiers are local to the scheme: first find raw free IDs, then
13196− :: follow those IDs in the module substitution without capturing them.
13197− =/ raw=(unit dgscan) (dg-scan ~[typ.sc] ~ fuel ~)
13198− ?~ raw ~
13199− =/ free=(list @ud) (skim ids.u.raw |=(n=@ud !(lien vars.sc |=(q=@ud =(q n)))))
13200− =/ resolved=(unit dgscan) (dg-scan-ids free sub fuel.u.raw blocked)
13201− ?~ resolved ~
13202− $(env t.env, fuel fuel.u.resolved, blocked ids.u.resolved)
13203−::
13204−++ dg-obligations
13205− |= [pending=(list dgo) sub=isub fuel=@ud blocked=(list @ud)]
13206− ^- (unit dgscan)
13207− ?~ pending `[blocked fuel]
13208− =/ found=(unit dgscan) (dg-scan ~[left.i.pending right.i.pending] sub fuel blocked)
13209− ?~ found ~
13210− $(pending t.pending, fuel fuel.u.found, blocked ids.u.found)
13211−::
13212−++ dg-tags
13213− |= [tags=(list ipending) sub=isub fuel=@ud blocked=(list @ud)]
13214− ^- (unit dgscan)
13215− ?~ tags `[blocked fuel]
13216− ?: =(0 fuel) ~
13217− =/ found=(unit itype) (itype-lookup id.i.tags sub)
13218− ?~ found $(tags t.tags, fuel (dec fuel), blocked [id.i.tags blocked])
13219− :: Until this entry is explicitly discharged, retain variables reachable
13220− :: through its binding; mere existence of a substitution is not proof.
13221− =/ reached=(unit dgscan) (dg-scan ~[u.found] sub (dec fuel) blocked)
13222− ?~ reached ~
13223− $(tags t.tags, fuel fuel.u.reached, blocked ids.u.reached)
13224−::
13225−++ dg-generalize
13226− |= [typ=itype env=ienv pending=(list dgo) tags=(list ipending) captured=(list @ud) state=istate fuel=@ud]
13227− ^- (unit ischeme)
13228− :: Bound the obligation list and all graph/substitution walks. The
13229− :: substitution is assumed checker-owned and occurs-checked.
13230− ?: (gth (lent pending) 64) ~
13231− =/ capt=(unit dgscan) (dg-scan-ids captured sub.state fuel ~)
13232− ?~ capt ~
13233− =/ env-free=(unit dgscan) (dg-env env sub.state fuel.u.capt ids.u.capt)
13234− ?~ env-free ~
13235− =/ obligations=(unit dgscan) (dg-obligations pending sub.state fuel.u.env-free ids.u.env-free)
13236− ?~ obligations ~
13237− =/ tagged=(unit dgscan) (dg-tags tags sub.state fuel.u.obligations ids.u.obligations)
13238− ?~ tagged ~
13239− =/ bounded=(unit dgscan) (dg-scan ~[typ] sub.state fuel.u.tagged ~)
13240− ?~ bounded ~
13241− =/ normalized=itype (itype-normalize typ sub.state)
13242− =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
13243− =/ quantified=(list @ud) (skim vars |=(n=@ud !(lien ids.u.tagged |=(b=@ud =(b n)))))
13244− `[[normalized quantified]]
13245−::
13246−+$ dgcommit [env=ienv state=istate]
13247−:: A branch literal must not acquire a value face through replay.
13248−++ dg-literal-target-safe
13249− |= target=itype
13250− ^- ?
13251− ?: ?=(%union -.target)
13252− (levy cases.target |=(c=itype ?=(?(%const %cell) -.c)))
13253− ?=(?(%const %atom %any-atom %flag %noun) -.target)
13254−::
13255−++ dg-replay-edges
13256− |= [edges=(list dgo) state=istate fuel=@ud]
13257− ^- (unit istate)
13258− ?~ edges `state
13259− ?: =(0 fuel) ~
13260− =/ trial=ifit (itype-fit left.i.edges right.i.edges sub.state next.state)
13261− ?. ?=(%ok -.trial) ~
13262− =/ valid=?
13263− ?: ?=(%tag -.left.i.edges)
13264− ?. constructor.left.i.edges
13265− =/ closed=(unit dgscan) (dg-scan ~[right.i.edges] sub.trial 512 ~)
13266− ?~ closed |
13267− ?^ ids.u.closed |
13268− (dg-literal-target-safe (itype-normalize right.i.edges sub.trial))
13269− =((itype-walk left.i.edges sub.trial) (itype-walk right.i.edges sub.trial))
13270− =((itype-walk left.i.edges sub.trial) (itype-walk right.i.edges sub.trial))
13271− ?. valid ~
13272− $(edges t.edges, state state(sub sub.trial, next next.trial), fuel (dec fuel))
13273−::
13274−++ dg-close-env
13275− |= [env=ienv sub=isub fuel=@ud]
13276− ^- (unit ienv)
13277− ?~ env `~
13278− ?: =(0 fuel) ~
13279− =/ s=ischeme scheme.i.env
13280− :: Quantified IDs are scheme-local and cannot be rewritten on publication.
13281− ?. (levy vars.s |=(n=@ud ?=(~ (itype-lookup n sub)))) ~
13282− =/ bounded=(unit dgscan) (dg-scan ~[typ.s] sub (dec fuel) ~)
13283− ?~ bounded ~
13284− =/ normalized=itype (itype-normalize typ.s sub)
13285− ?: (itype-has-tag normalized) ~
13286− =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
13287− ?. (levy vars |=(n=@ud (lien vars.s |=(v=@ud =(v n))))) ~
13288− =/ rest=(unit ienv) (dg-close-env t.env sub fuel.u.bounded)
13289− ?~ rest ~
13290− `[[name.i.env [normalized vars.s]] u.rest]
13291−::
13292−:: A deferred boolean branch has exactly the two literal flag patterns.
13293−:: Arms are inferred in order. Equal types are retained; two direct pending
13294−:: literals may instead retain source-owned obligations for later context.
13295−++ dg-boolean-patterns
13296− |= e=expr
13297− ^- ?
13298− ?. ?=(%branch -.e) |
13299− ?~ arms.e |
13300− ?~ t.arms.e |
13301− ?^ t.t.arms.e |
13302− =/ x=arm i.arms.e
13303− =/ y=arm i.t.arms.e
13304− ?. &(?=(%lit -.pat.x) ?=(%lit -.pat.y)) |
13305− ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y)) |
13306− !=(val.lit.pat.x val.lit.pat.y)
13307−:: Only a direct source literal which created its own unbound pending tag
13308−:: may create a branch edge. The caller must retain the exact source and state.
13309−++ dg-owned-arm-literal
13310− |= [e=expr t=itype tags=(list ipending) sub=isub initial=@ud]
13311− ^- ?
13312− ?. ?=(%lit -.e) |
13313− ?. ?=(%tag -.t) |
13314− ?: constructor.t |
13315− ?. =(lit.e literal.t) |
13316− ?: (lth id.t initial) |
13317− ?^ (itype-lookup id.t sub) |
13318− (lien tags |=(x=ipending &(=(id.x id.t) =(literal.x literal.t))))
13319−++ dg-boolean-branch
13320− |= [e=expr env=ienv state=istate]
13321− ^- iresult
13322− ?. (dg-boolean-patterns e) [%| ["deferred branch patterns need unsupported inference" ~]]
13323− ?> ?=(%branch -.e)
13324− ?> ?=(^ arms.e)
13325− ?> ?=(^ t.arms.e)
13326− =/ x=arm i.arms.e
13327− =/ y=arm i.t.arms.e
13328− =/ subject=iresult (infer-fragment subject.e env state)
13329− ?: ?=(%| -.subject) subject
13330− =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
13331− ?~ su [%| ["deferred branch subject does not unify with ?" ~]]
13332− =/ left=iresult (infer-fragment val.x env state.p.subject(sub u.su))
13333− ?: ?=(%| -.left) left
13334− =/ right=iresult (infer-fragment val.y env state.p.left)
13335− ?: ?=(%| -.right) right
13336− ?. (dg-stable-fit typ.p.left typ.p.right sub.state.p.right)
13337− =/ st=istate state.p.right
13338− ?. (dg-owned-arm-literal val.x typ.p.left tags.st sub.st next.state)
13339− [%| ["deferred branch arm context needs unsupported inference" ~]]
13340− ?. (dg-owned-arm-literal val.y typ.p.right tags.st sub.st next.state)
13341− [%| ["deferred branch arm context needs unsupported inference" ~]]
13342− ?> ?=(%tag -.typ.p.left)
13343− ?> ?=(%tag -.typ.p.right)
13344− ?: =(id.typ.p.left id.typ.p.right)
13345− [%| ["deferred branch arm context needs unsupported inference" ~]]
13346− ?: (gth (lent obligations.st) 62)
13347− [%| ["deferred branch arm context needs unsupported inference" ~]]
13348− =/ result=itype [%var next.st]
13349− =/ ex=dgo [typ.p.left result (span-of val.x) (span-of e)]
13350− =/ ey=dgo [typ.p.right result (span-of val.y) (span-of e)]
13351− [%& result st(next +(next.st), obligations [ex ey obligations.st])]
13352− [%& typ.p.left state.p.right]
13353−::
13354−:: A direct tuple literal may wait for a later exact result context.
13355−:: Each pending literal retains its source tag and its own fit obligation.
13356−++ dg-infer-tuple-items
13357− |= [items=(list item) env=ienv state=istate]
13358− ^- iresult
13359− ?~ items [%| ["empty cell is not supported by partial inference" ~]]
13360− =/ head=iresult (infer-fragment val.i.items env state)
13361− ?: ?=(%| -.head) head
13362− =/ typ=itype typ.p.head
13363− =/ st=istate state.p.head
13364− =/ adjusted=(unit [typ=itype state=istate])
13365− ?. (dg-owned-arm-literal val.i.items typ tags.st sub.st next.state) `[typ st]
13366− ?: (gth (lent obligations.st) 63) ~
13367− =/ pending=itype [%var next.st]
13368− =/ edge=dgo [typ pending (span-of val.i.items) at.i.items]
13369− `[pending st(next +(next.st), obligations [edge obligations.st])]
13370− ?~ adjusted [%| ["deferred tuple context needs unsupported inference" ~]]
13371− =. typ typ.u.adjusted
13372− =. st state.u.adjusted
13373− =. typ ?~(face.i.items typ [%face u.face.i.items typ])
13374− ?~ t.items [%& typ st]
13375− =/ tail=iresult $(items t.items, state st)
13376− ?: ?=(%| -.tail) tail
13377− [%& [%cell typ typ.p.tail] state.p.tail]
13378−::
13379−:: Deferred inference uses only source forms whose successful fit sites are
13380−:: guarded below; a shared source-node budget bounds this screen.
13381−++ dg-safe-expressions
13382− |= [todo=(list expr) fuel=@ud]
13383− ^- (unit @ud)
13384− ?~ todo `fuel
13385− =/ first=(unit @ud) (dg-safe-expression i.todo fuel)
13386− ?~ first ~
13387− $(todo t.todo, fuel u.first)
13388−++ dg-safe-items
13389− |= [items=(list item) fuel=@ud]
13390− ^- (unit @ud)
13391− ?~ items `fuel
13392− =/ first=(unit @ud) (dg-safe-expression val.i.items fuel)
13393− ?~ first ~
13394− $(items t.items, fuel u.first)
13395−++ dg-safe-expression
13396− |= [e=expr fuel=@ud]
13397− ^- (unit @ud)
13398− ?: =(0 fuel) ~
13399− =. fuel (dec fuel)
13400− ?+ -.e ~
13401− ?(%lit %ctor) `fuel
13402− %wing ?:(?=([@ ~] names.e) `fuel ~)
13403− %str
13404− ?. (levy pieces.e |=(p=piece ?=(%text -.p))) ~
13405− `fuel
13406− %group $(e inner.e, fuel fuel)
13407− %body
13408− ?^ defs.e ~
13409− $(e final.e, fuel fuel)
13410− %gate $(e body.e, fuel fuel)
13411− %gate-wide $(e body.e, fuel fuel)
13412− %tuple (dg-safe-items items.e fuel)
13413− %branch
13414− ?. (dg-boolean-patterns e) ~
13415− ?> ?=(^ arms.e)
13416− ?> ?=(^ t.arms.e)
13417− =/ subject=(unit @ud) $(e subject.e, fuel fuel)
13418− ?~ subject ~
13419− (dg-safe-expressions ~[val.i.arms.e val.i.t.arms.e] u.subject)
13420− %cast $(e val.e, fuel fuel)
13421− %call
13422− =/ head=(unit @ud) $(e head.e, fuel fuel)
13423− ?~ head ~
13424− (dg-safe-expressions args.e u.head)
13425− ==
13426−:: Exact normalized equality is preserved by all later substitutions.
13427−:: The bounded scan declines opaque types and oversized inputs.
13428−++ dg-stable-fit
13429− |= [actual=itype expected=itype sub=isub]
13430− ^- ?
13431− ?~ (dg-scan ~[actual expected] sub 512 ~) |
13432− =((itype-normalize actual sub) (itype-normalize expected sub))
13433−::
13434−:: A positional call peels sample-slot faces during its separate face check.
13435−:: Require its argument, sample and result closed so that check stays valid.
13436−++ dg-stable-call-fit
13437− |= [actual=itype expected=itype product=itype sub=isub positional=?]
13438− ^- ?
13439− =/ checked=(unit dgscan) (dg-scan ~[actual expected product] sub 512 ~)
13440− ?~ checked |
13441− ?: &(positional ?=(^ ids.u.checked)) |
13442− =((itype-normalize actual sub) (itype-normalize expected sub))
13443−::
13444−:: One definition attempt retains state only when inference succeeds.
13445−+$ dg-step [env=ienv state=istate pending=(list dgo)]
13446−++ dg-stage-one
13447− |= [d=def env=ienv state=istate]
13448− ^- (unit dg-step)
13449− ?> ?=(%value -.d)
13450− ?~ (dg-safe-expression val.d 512) ~
13451− =/ local=istate (reserve-def-caps val.d state)
13452− :: This first slice declines all written capitals and holes/projections.
13453− ?^ caps.local ~
13454− =/ ordinary=iresult (infer-fragment val.d env local)
13455− ?: ?=(%| -.ordinary) ~
13456− =/ typ=itype typ.p.ordinary
13457− =/ after=istate state.p.ordinary
13458− =/ edges=(list dgo) obligations.after
13459− ?. =(binders.after binders.state) ~
13460− ?. =(molds.after molds.state) ~
13461− ?. =(globals.after globals.state) ~
13462− ?. =(externals.after externals.state) ~
13463− ?. =(surs.after surs.state) ~
13464− ?. =(mark-externals.after mark-externals.state) ~
13465− ?. =(marks.after marks.state) ~
13466− ?. =(jimports.after jimports.state) ~
13467− ?. =(reserved-molds.after reserved-molds.state) ~
13468− ?. =(params.after params.state) ~
13469− ?. =(active.after active.state) ~
13470− ?. =(in-mold.after in-mold.state) ~
13471− ?. =(at.after at.state) ~
13472− ?. =(top-molds.after top-molds.state) ~
13473− ?. =(prelude.after prelude.state) ~
13474− ?. =(gate-defs.after gate-defs.state) ~
13475− ?. =(head-evidence.after head-evidence.state) ~
13476− ?. =(grec-index.after grec-index.state) ~
13477− ?. =(defer.after defer.state) ~
13478− ?. =(holes.after holes.state) ~
13479− ?. =(caps.after caps.state) ~
13480− ?. =(projections.after projections.state) ~
13481− ?: (unsupported-atom-vars (itype-normalize typ sub.after) caps.after binders.after sub.after) ~
13482− ?: (itype-has-nvar (itype-normalize typ sub.after)) ~
13483− =/ scheme=(unit ischeme) (dg-generalize typ env edges tags.after ~ after 32.768)
13484− ?~ scheme ~
13485− `[[[name.d u.scheme] env] after edges]
13486−:: Retry only definitions that did not infer. Successful definitions are
13487−:: committed into the local transaction, never published until all close.
13488−++ dg-stage
13489− |= [ds=(list def) base=ienv env=ienv state=istate pending=(list dgo) fuel=@ud]
13490− ^- (unit dgcommit)
13491− ?: (gth fuel 64) ~
13492− ?: (gth (lent ds) fuel) ~
13493− =/ remaining=(list def) ds
13494− =/ waiting=(list def) ~
13495− =/ progress=? |
13496− =/ attempts=@ud (mul fuel fuel)
13497− |-
13498− ?~ remaining
13499− ?^ waiting
13500− ?. progress ~
13501− $(remaining (flop waiting), waiting ~, progress |)
13502− =/ replayed=(unit istate) (dg-replay-edges pending state 64)
13503− ?~ replayed ~
13504− ?: (pending-tags tags.u.replayed sub.u.replayed) ~
13505− =/ closed-edges=(unit dgscan) (dg-obligations pending sub.u.replayed 32.768 ~)
13506− ?~ closed-edges ~
13507− ?^ ids.u.closed-edges ~
13508− =/ rechecked=(unit istate) (dg-replay-edges pending u.replayed 64)
13509− ?~ rechecked ~
13510− ?. =(sub.u.rechecked sub.u.replayed) ~
13511− ?. =(next.u.rechecked next.u.replayed) ~
13512− =/ closed=(unit ienv) (dg-close-env env sub.u.replayed 32.768)
13513− ?~ closed ~
13514− `[[u.closed u.replayed(defer ~, obligations ~)]]
13515− ?: =(0 attempts) ~
13516− =. attempts (dec attempts)
13517− =/ d=def i.remaining
13518− ?: ?=(%mold -.d) $(remaining t.remaining)
13519− ?^ (ienv-lookup name.d base) $(remaining t.remaining)
13520− ?^ (ienv-lookup name.d env) ~
13521− =/ done=(unit dg-step) (dg-stage-one d env state)
13522− ?~ done $(remaining t.remaining, waiting [d waiting])
13523− $(remaining t.remaining, env env.u.done, state state.u.done, pending pending.u.done, progress &)
13524−::
13525−:: Cheap bounded eligibility check on the already parsed source. This
13526−:: deliberately covers only direct constructor calls beneath transparent
13527−:: groups, gates, casts and definition-free bodies. Other shapes decline
13528−:: this fallback without a second parse or resolution pass.
13529−++ dg-direct-source
13530− |= [e=expr fuel=@ud]
13531− ^- ?
13532− ?: =(0 fuel) |
13533− ?+ -.e |
13534− %group $(e inner.e, fuel (dec fuel))
13535− %gate $(e body.e, fuel (dec fuel))
13536− %gate-wide $(e body.e, fuel (dec fuel))
13537− %cast $(e val.e, fuel (dec fuel))
13538− %body ?~(defs.e $(e final.e, fuel (dec fuel)) |)
13539− %call
13540− ?. ?=([* ~] args.e) |
13541− ?=(%ctor -.i.args.e)
13542− ==
13543−++ dg-source-candidate
13544− |= [ds=(list def) fuel=@ud]
13545− ^- ?
13546− ?~ ds |
13547− ?: =(0 fuel) |
13548− ?. ?=(%value -.i.ds) $(ds t.ds, fuel (dec fuel))
13549− ?: (dg-direct-source val.i.ds 64) &
13550− $(ds t.ds, fuel (dec fuel))
13551−::
13552−++ dg-prepared-source
13553− |= [e=expr fuel=@ud]
13554− ^- ?
13555− ?: (dg-direct-source e fuel) &
13556− ?: =(0 fuel) |
13557− ?+ -.e |
13558− %group $(e inner.e, fuel (dec fuel))
13559− %gate $(e body.e, fuel (dec fuel))
13560− %gate-wide $(e body.e, fuel (dec fuel))
13561− %cast $(e val.e, fuel (dec fuel))
13562− %body ?~(defs.e $(e final.e, fuel (dec fuel)) |)
13563− %tuple &
13564− ==
13565−++ dg-prepared-candidate
13566− |= [ds=(list def) fuel=@ud]
13567− ^- ?
13568− ?~ ds |
13569− ?: =(0 fuel) |
13570− ?. ?=(%value -.i.ds) $(ds t.ds, fuel (dec fuel))
13571− ?: (dg-prepared-source val.i.ds 64) &
13572− $(ds t.ds, fuel (dec fuel))
13573−::
13574−++ dg-interface-safe
13575− |= [env=ienv]
13576− ^- ?
13577− ?~ env &
13578− =/ sc=ischeme scheme.i.env
13579− ?: |((itype-has-hidden-recursive typ.sc) (itype-has-hidden-generic typ.sc)) |
13580− ?: (gth (lent vars.sc) 26) |
13581− $(env t.env)
13582−:: Parse status and the transaction result come from the same source parse.
13583−+$ dgparse [parsed=? result=(unit dgcommit)]
13584−++ dg-root-source
13585− |= [at=path src=@t]
13586− ^- (unit dgcommit)
13587− result:(dg-root-detail at src)
13588−++ dg-root-detail
13589− |= [at=path src=@t]
13590− ^- dgparse
13591− =/ parsed (parse at src)
13592− ?: ?=(%| -.parsed) [| ~]
13593− =/ transact
13594− |.
13595− ?^ imports.p.parsed ~
13596− ?. (module-scope-valid p.parsed ~ ~) ~
13597− ?^ (duplicate-defs defs.p.parsed) ~
13598− =/ defs=(list def) defs.p.parsed
13599− ?: (gth (lent defs) 64) ~
13600− =/ molds=imolds (collect-simple-molds defs)
13601− =/ globals=(list term) (global-value-names defs)
13602− =/ resolution=iresolved (resolve-groups defs molds globals ~ ~ ~ ~ ~ ~ at ~)
13603− ?^ grouped.resolution ~
13604− ?^ artifacts.resolution ~
13605− =/ base=ienv env.resolution
13606− =/ free=(unit dgscan) (dg-env base ~ 32.768 ~)
13607− ?~ free ~
13608− ?^ ids.u.free ~
13609− =/ all=(unit dgscan) (dg-all-env-ids base 32.768 ~)
13610− ?~ all ~
13611− =/ fresh=@ud (dg-next-id ids.u.all 0)
13612− =/ st=istate *istate
13613− =. st st(next fresh, defer `~, molds molds, globals globals, at at, top-molds (turn molds |=(m=[name=term body=shape] name.m)), in-mold |, jrec-fuel 256)
13614− =/ checked-molds=(each imold-types @t) (module-mold-types molds st)
13615− ?: ?=(%| -.checked-molds) ~
13616− (dg-stage defs base base st ~ 64)
13617− ::
13618− [& (transact)]
13619−:: The caller supplies the trusted prepared prelude. This transaction is
13620−:: only report evidence; the ordinary module resolver does not publish it.
13621−++ dg-root-prepared
13622− |= [at=path src=@t prepared=iprelude]
13623− ^- (unit dgcommit)
13624− ?: ?=([%ui %api *] at) ~
13625− ?: ?=([%ui %stores *] at) ~
13626− ?: (gth (met 3 src) 65.536) ~
13627− =/ parsed (parse at src)
13628− ?: ?=(%| -.parsed) ~
13629− ?^ imports.p.parsed ~
13630− ?. (module-scope-valid p.parsed values.prepared molds.prepared) ~
13631− ?^ (duplicate-defs defs.p.parsed) ~
13632− =/ defs=(list def) defs.p.parsed
13633− ?: (gth (lent defs) 64) ~
13634− ?: (lien (global-value-names defs) |=(n=term =(n %main))) ~
13635− ?. (dg-prepared-candidate defs 64) ~
13636− =/ local-molds=imolds (collect-simple-molds defs)
13637− =/ globals=(list term) (weld values.prepared (global-value-names defs))
13638− =/ iface=ifile iface.prepared
13639− =/ prelude=(unit ifile) `iface
13640− =/ resolution=iresolved
13641− (resolve-groups defs local-molds globals ~ ~ ~ ~ ~ molds.prepared at prelude)
13642− ?^ grouped.resolution ~
13643− ?^ artifacts.resolution ~
13644− =/ base=ienv env.resolution
13645− =/ templates=ienv
13646− (turn molds.iface |=(x=[name=term template=ischeme] [name.x template.x]))
13647− =/ all-env=ienv (weld base (weld values.iface templates))
13648− =/ free=(unit dgscan) (dg-env all-env ~ 32.768 ~)
13649− ?~ free ~
13650− ?^ ids.u.free ~
13651− =/ all=(unit dgscan) (dg-all-env-ids all-env 32.768 ~)
13652− ?~ all ~
13653− =/ fresh=@ud (dg-next-id ids.u.all 0)
13654− =/ st=istate *istate
13655− =. st st(next fresh, defer `~, molds local-molds, globals globals, at at, reserved-molds molds.prepared, prelude prelude, top-molds (turn local-molds |=(m=[name=term body=shape] name.m)), in-mold |, jrec-fuel 256)
13656− =/ checked-molds=(each imold-types @t) (module-mold-types local-molds st)
13657− ?: ?=(%| -.checked-molds) ~
13658− (dg-stage defs base base st ~ 64)
13659−::
13660−++ dg-all-env-ids
13661− |= [env=ienv fuel=@ud ids=(list @ud)]
13662− ^- (unit dgscan)
13663− ?~ env `[ids fuel]
13664− ?: =(0 fuel) ~
13665− =/ sc=ischeme scheme.i.env
13666− ?: (itype-has-tag typ.sc) ~
13667− =/ raw=(unit dgscan) (dg-scan ~[typ.sc] ~ (dec fuel) ids)
13668− ?~ raw ~
13669− =/ quant=(unit dgscan) (dg-scan-ids vars.sc ~ fuel.u.raw ids.u.raw)
13670− ?~ quant ~
13671− $(env t.env, fuel fuel.u.quant, ids ids.u.quant)
13672−::
13673−++ dg-next-id
13674− |= [ids=(list @ud) largest=@ud]
13675− ^- @ud
13676− ?~ ids +(largest)
13677− $(ids t.ids, largest (max largest i.ids))
13678−::
13679−++ dg-eligible-ctor
13680− |= [e=expr head=itype actual=itype expected=itype state=istate]
13681− ^- (unit dgo)
13682− ?. ?=(%call -.e) ~
13683− ?. ?=([* ~] args.e) ~
13684− ?. ?=(%ctor -.i.args.e) ~
13685− ?. ?=(%fn -.head) ~
13686− ?. ?=(%fn -.expected) ~
13687− ?. ?=(%tag -.actual) ~
13688− ?. constructor.actual ~
13689− ?. ?=(%var -.product.expected) ~
13690− ?^ (itype-lookup id.product.expected sub.state) ~
13691− =/ bounded=(unit dgscan) (dg-scan ~[sample.expected] sub.state 256 ~)
13692− ?~ bounded ~
13693− ?^ ids.u.bounded ~
13694− `[[actual expected (span-of i.args.e) (span-of head.e)]]
13695−::
13696−:: Experimental per-module, source-derived recursive tree index.
13697−:: The two tags and the exact children/list/self layout are fixed-shape
13698−:: checks, so ordinary definitions incur no type-tree or source scans.
13699−++ grec-tagged-fields
13700− |= sh=shape
13701− ^- (unit [tag=@ fields=(list field)])
13702− ?. ?=(%cell -.sh) ~
13703− ?~ fields.sh ~
13704− =/ head=field i.fields.sh
13705− ?. ?=(%bare -.head) ~
13706− ?. ?=(%const -.shape.head) ~
13707− ?. &(?=(%term form.lit.shape.head) =(%tas aura.lit.shape.head)) ~
13708− `[val.lit.shape.head t.fields.sh]
13709−++ grec-tree-children
13710− |= [fs=(list field) param=@t]
13711− ^- (unit field)
13712− ?~ fs ~
13713− ?~ t.fs `i.fs
13714− ?^ t.t.fs ~
13715− =/ event=field i.fs
13716− =/ kids=field i.t.fs
13717− ?. &(?=(%face -.event) ?=(%face -.kids)) ~
13718− ?. !=(name.event name.kids) ~
13719− ?. ?=(%fn -.shape.event) ~
13720− ?. ?=(%aura -.sample.shape.event) ~
13721− ?. =(%t aura.sample.shape.event) ~
13722− ?. ?=(%tvar -.product.shape.event) ~
13723− ?. =(param name.product.shape.event) ~
13724− `kids
13725−::
13726−++ grec-tree-proof
13727− |= [name=term sh=shape]
13728− ^- ?
13729− ?. ?=(%generic -.sh) |
13730− ?. ?=([@ ~] vars.sh) |
13731− =/ param=@t i.vars.sh
13732− ?. ?=(%union -.body.sh) |
13733− ?. ?=([* [* ~]] cases.body.sh) |
13734− =/ a=(unit [tag=@ fields=(list field)]) (grec-tagged-fields i.cases.body.sh)
13735− =/ b=(unit [tag=@ fields=(list field)]) (grec-tagged-fields i.t.cases.body.sh)
13736− ?~ a |
13737− ?~ b |
13738− ?. !=(tag.u.a tag.u.b) |
13739− ?. ?=([* ~] fields.u.a) |
13740− =/ value=field i.fields.u.a
13741− ?. ?=(%face -.value) |
13742− ?. ?=(%aura -.shape.value) |
13743− ?. =(%t aura.shape.value) |
13744− =/ selected=(unit field) (grec-tree-children fields.u.b param)
13745− ?~ selected |
13746− =/ kids=field u.selected
13747− ?. ?=(%face -.kids) |
13748− ?. ?=(%apply -.shape.kids) |
13749− ?. =(ref.shape.kids ~[%list]) |
13750− ?. ?=([* ~] args.shape.kids) |
13751− =/ self=shape i.args.shape.kids
13752− ?. ?=(%apply -.self) |
13753− ?. =(ref.self ~[name]) |
13754− ?. ?=([* ~] args.self) |
13755− ?. ?=(%tvar -.i.args.self) |
13756− =(name.i.args.self param)
13757−+$ grec-collected [molds=imolds proofs=(map term shape)]
13758−:: Experimental one-layer analysis view, never an exported mold identity.
13759−++ grec-unfold-view
13760− |= [typ=itype fuel=@ud]
13761− ^- (unit [view=itype left=@ud])
13762− ?. ?=(%grec -.typ) ~
13763− ?: =(fuel 0) ~
13764− ?. ?=([* ~] args.typ) ~
13765− =/ sh=shape proof.typ
13766− ?. (grec-tree-proof name.typ sh) ~
13767− ?> ?=(%generic -.sh)
13768− ?> ?=([@ ~] vars.sh)
13769− ?> ?=(%union -.body.sh)
13770− ?> ?=([* [* ~]] cases.body.sh)
13771− =/ ca=shape i.cases.body.sh
13772− =/ cb=shape i.t.cases.body.sh
13773− ?> ?=(%cell -.ca)
13774− ?> ?=(%cell -.cb)
13775− ?> ?=([* [* ~]] fields.ca)
13776− ?> ?=([* *] fields.cb)
13777− =/ tag-a=field i.fields.ca
13778− =/ tag-b=field i.fields.cb
13779− ?> ?=(%bare -.tag-a)
13780− ?> ?=(%bare -.tag-b)
13781− ?> ?=(%const -.shape.tag-a)
13782− ?> ?=(%const -.shape.tag-b)
13783− =/ text-field=field i.t.fields.ca
13784− ?> ?=(%face -.text-field)
13785− =/ branch=(list field) t.fields.cb
13786− =/ kids=(unit field) (grec-tree-children branch i.vars.sh)
13787− ?~ kids ~
13788− ?> ?=(%face -.u.kids)
13789− =/ children=itype [%face name.u.kids [%collection %list ~[typ]]]
13790− ?> ?=(^ branch)
13791− =/ payload=itype
13792− ?~ t.branch children
13793− =/ event=field i.branch
13794− ?> ?=(%face -.event)
13795− [%cell [%face name.event [%fn [%atom %t] i.args.typ]] children]
13796− =/ leaf=itype [%cell [%const lit.shape.tag-a] [%face name.text-field [%atom %t]]]
13797− =/ node=itype [%cell [%const lit.shape.tag-b] payload]
13798− `[[%union ~[leaf node] ~ ~ ~] (dec fuel)]
13799−::
13800−++ grec-collect-molds
13801− |= ds=(list def)
13802− ^- grec-collected
13803− ?~ ds [~ *(map term shape)]
13804− =/ rest=grec-collected $(ds t.ds)
13805− ?. ?=(%mold -.i.ds) rest
13806− =/ name=term name.i.ds
13807− =/ body=shape shape.i.ds
13808− =/ proofs=(map term shape) proofs.rest
13809− =? proofs (grec-tree-proof name body) (~(put by proofs) name body)
13810− [[[name body] molds.rest] proofs]
13811−::
13812−
138137596--