@@ -874,7 +874,7 @@
874874 %'~[' %'|=(' %'$-(' :: openers
875875 %'%/' %'/' :: paths
876876 %'+' %'`' %'=' :: pair, unit, face
877− %'*' %'?' :: noun, loobean mold
877+ %'*' %'?' %'_' :: noun, loobean, type hole
878878 %'++' %'+$' %'|=' %'|$' :: runes
879879 %'^-' %'~&' %'?-' %'!!' :: runes
880880 %'/-' %'/%' %'/=' :: imports
@@ -1016,6 +1016,7 @@
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 ~] :: _
10191020 [%path at=span segs=(list pseg)] :: / /todos /todo/[id=@ud]
10201021 [%apply at=span ref=(list term) args=(list shape)] :: (list @t)
10211022 [%cell at=span fields=(list field)] :: [text=@t done=?]
@@ -1024,9 +1025,9 @@
10241025 [%generic at=span vars=(list @t) body=shape] :: +$ name |$ [M] …
10251026 ==
10261027::
1027−:: +pseg: a path mold's segment, a knot or [name=aura]
1028+:: +pseg: a path mold's segment, a knot, [name=aura], or [name=_]
10281029::
1029−+$ pseg $%([%knot p=@ta] [%typed at=span name=term aura=@ta])
1030++$ pseg $%([%knot p=@ta] [%typed at=span name=term aura=@ta] [%inferred at=span name=term hole-at=span])
10301031::
10311032+| %api
10321033::
@@ -1295,6 +1296,7 @@
12951296 (emit 1 %'=')
12961297 ?: =('`' a) (emit 1 %'`')
12971298 ?: =('*' a) (emit 1 %'*')
1299+ ?: =('_' a) (emit 1 %'_')
12981300 ?: =('~' a)
12991301 ?: =('[' b) (emit 2 %'~[')
13001302 ?: =('&' b) (emit 2 %'~&')
@@ -1670,14 +1672,14 @@
16701672:: What may begin each place the parser reads (section 3, Errors):
16711673:: an expression a-z 0-9 " ( [ ~ % / ` | ^ ? !
16721674:: an operand a-z 0-9 " ( [ ~ % / ` | !
1673−:: a mold a-z A-Z @ * ! ? ~ % / ( [ $
1675+:: a mold a-z A-Z @ * ! ? ~ % / ( [ $ _
16741676:: a pattern a-z 0-9 " ~ % * [
16751677:: and what may go tight after an operand: . ( + = after a name, a
16761678:: closer ) ] }, or the : of a comment
16771679::
16781680++ expr-mask 0x57ff.ffff.4800.0000.83ff.8126.0000.0000
16791681++ operand-mask 0x57ff.ffff.0800.0000.03ff.8126.0000.0000
1680−++ mold-mask 0x47ff.fffe.0fff.ffff.8000.8532.0000.0000
1682+++ mold-mask 0x47ff.fffe.8fff.ffff.8000.8532.0000.0000
16811683++ bar-mask 0x1000.0000.0000.0000.0000.0000.0000.0000
16821684++ pattern-mask 0x47ff.fffe.0800.0000.03ff.0424.0000.0000
16831685++ after-mask 0x2000.0000.2000.0000.2400.4b00.0000.0000
@@ -2107,6 +2109,7 @@
21072109 ?- -.s
21082110 %knot (weld "/" (trip p.s))
21092111 %typed "/[{(trip name.s)}=@{(trip aura.s)}]"
2112+ %inferred "/[{(trip name.s)}=_]"
21102113 ==
21112114::
21122115++ show-tvars
@@ -2318,6 +2321,7 @@
23182321 %const (nod "const" at.s (show-lit lit.s) ~)
23192322 %ref (nod "ref" at.s (show-names names.s) ~)
23202323 %tvar (nod "tvar" at.s (trip name.s) ~)
2324+ %hole (nod "hole" at.s "" ~)
23212325 %path (nod "path" at.s (show-psegs segs.s) ~)
23222326 %apply (nod "apply" at.s (show-names ref.s) (turn args.s sexp-shape))
23232327 %cell (nod "cell" at.s "" (turn fields.s sexp-field))
@@ -3842,6 +3846,7 @@
38423846 %'*' [%& [%noun at.t ~] t.ts]
38433847 %'!!' [%& [%void at.t ~] t.ts]
38443848 %'?' [%& [%flag at.t ~] t.ts]
3849+ %'_' [%& [%hole at.t ~] t.ts]
38453850 [%name *] [%& [%ref at.t ~[p.lex.t]] t.ts]
38463851 [%wing *] [%& [%ref at.t p.lex.t] t.ts]
38473852 [%tvar *] [%& [%tvar at.t p.lex.t] t.ts]
@@ -4058,7 +4063,7 @@
40584063 ?: &(?=(^ nex) tight.i.nex) (bad nex "a path segment")
40594064 (bad-space i.after nex "a path segment")
40604065 ::
4061− :: +read-pseg: a path mold's segment, a knot or [name=aura] with no
4066+ :: +read-pseg: a path mold's knot, [name=aura], or [name=_] with no
40624067 :: spaces, and where it ends
40634068 ::
40644069 ++ read-pseg
@@ -4075,13 +4080,16 @@
40754080 ?: |(?=(~ r2) !tight.i.r2) (bad-space i.r1 r2 "`=`")
40764081 ?. ?=([[* * %'='] *] r2) (bad-in r2 "`=`" tis-mask)
40774082 =/ r3=(list token) t.r2
4078− ?: |(?=(~ r3) !tight.i.r3) (bad-space i.r2 r3 "an aura")
4079− ?. ?=([[* * [%aura *]] *] r3) (bad-in r3 "an aura" pat-mask)
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)))
40804085 =/ r4=(list token) t.r3
40814086 ?: |(?=(~ r4) !tight.i.r4) (bad-space i.r3 r4 "`]`")
40824087 ?. ?=([[* * %']'] *] r4) (bad-in r4 "`]`" ser-mask)
40834088 =/ at=span [beg.at.op end.at.i.r4]
4084− [%& [[%typed at p.lex.i.r1 p.lex.i.r3] end.at.i.r4] t.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]
40854093 --
40864094::
40874095+| %span-check
@@ -4465,6 +4473,7 @@
44654473 %const [%const at.s ~[%lit] %one ~]
44664474 %ref [%ref at.s ~[%name %wing] %one ~]
44674475 %tvar [%tvar at.s ~[%tvar] %one ~]
4476+ %hole [%hole at.s ~[%'_'] %one ~]
44684477 %apply [%apply at.s ~[%'('] %shut (turn args.s outline-shape)]
44694478 %cell [%cell at.s ~[%'['] %shut (turn fields.s outline-sample)]
44704479 ::
@@ -4473,8 +4482,11 @@
44734482 %+ murn segs.s
44744483 |= g=pseg
44754484 ^- (unit outline)
4476− ?. ?=(%typed -.g) ~
4477− `[%typed at.g ~[%'['] %shut ~]
4485+ ?- -.g
4486+ %knot ~
4487+ %typed `[%typed at.g ~[%'['] %shut ~]
4488+ %inferred `[%typed at.g ~[%'['] %shut ~[[%hole hole-at.g ~[%'_'] %one ~]]]
4489+ ==
44784490 [%path at.s ~[%'/'] %run ks]
44794491 ::
44804492 %union
@@ -4534,6 +4546,8 @@
45344546 [%path [1 9] [1 9] [1 21]]
45354547 [%face [1 7] [1 7] [1 21]]
45364548 ==
4549+ :: an inferred path aura's hole spanning its = as well
4550+ ['+$ x /a/[id=_]' ~[[%hole [1 13] [1 12] [1 14]]]]
45374551 :: an import's path cut short
45384552 ['/= c /ui/c' ~[[%jibb [1 1] [1 1] [1 11]]]]
45394553 :: brackets that close with the deeper lines, cut at their line's
@@ -4593,6 +4607,8 @@
45934607:: Atom constraints tied to an explicit capital or an inferred sample
45944608:: are generalized and printed. Other aura variables remain unsupported until
45954609:: 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.
45964612:: Bare @ is a separate unrestricted atom type. A directional fit check
45974613:: permits concrete atoms to widen to it, never the reverse. A fit that
45984614:: needs a not-yet-implemented constraint remains unsupported. Named unions
@@ -4600,11 +4616,53 @@
46004616:: from their display name. Generic cases must be disjoint for all arguments.
46014617:: Unnamed union printing is informational; it is not Jibb syntax.
46024618::
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+::
46034659+$ itype
46044660 $~ [%var 0]
46054661 $% [%var id=@ud]
46064662 [%avar id=@ud]
4663+ [%rvar id=@ud]
46074664 [%nvar id=@ud]
4665+ [%rnvar id=@ud]
46084666 [%atom aura=@ta]
46094667 [%any-atom ~]
46104668 [%flag ~]
@@ -4613,6 +4671,8 @@
46134671 [%const literal=lit]
46144672 [%collection name=term args=(list itype)]
46154673 [%recursive module=term name=term label=(unit @t)]
4674+ [%jrec at=path name=term label=(unit @t) head=term aura=@ta tail=term]
4675+ [%grec at=path name=term label=(unit @t) proof=shape args=(list itype)]
46164676 [%union cases=(list itype) origin=(unit [at=path name=term]) label=(unit @t) args=(list itype)]
46174677 [%face name=term body=itype]
46184678 [%fn sample=itype product=itype]
@@ -4636,18 +4696,32 @@
46364696 %var
46374697 =/ found=(unit itype) (itype-lookup id.t sub)
46384698 ?~ found t
4699+ ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
46394700 $(t u.found)
46404701 %avar
46414702 =/ found=(unit itype) (itype-lookup id.t sub)
46424703 ?~ found t
4704+ ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4705+ $(t u.found)
4706+ %rvar
4707+ =/ found=(unit itype) (itype-lookup id.t sub)
4708+ ?~ found t
4709+ ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
46434710 $(t u.found)
46444711 %nvar
46454712 =/ found=(unit itype) (itype-lookup id.t sub)
46464713 ?~ found t
4714+ ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4715+ $(t u.found)
4716+ %rnvar
4717+ =/ found=(unit itype) (itype-lookup id.t sub)
4718+ ?~ found t
4719+ ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
46474720 $(t u.found)
46484721 %tag
46494722 =/ found=(unit itype) (itype-lookup id.t sub)
46504723 ?~ found t
4724+ ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
46514725 $(t u.found)
46524726 ==
46534727::
@@ -4658,7 +4732,9 @@
46584732 ?- -.t
46594733 %var =(n id.t)
46604734 %avar =(n id.t)
4735+ %rvar =(n id.t)
46614736 %nvar =(n id.t)
4737+ %rnvar =(n id.t)
46624738 %atom |
46634739 %any-atom |
46644740 %flag |
@@ -4667,6 +4743,8 @@
46674743 %const |
46684744 %union |((lien cases.t |=(c=itype (itype-occurs n c sub))) (lien args.t |=(c=itype (itype-occurs n c sub))))
46694745 %recursive |
4746+ %jrec |
4747+ %grec (lien args.t |=(c=itype (itype-occurs n c sub)))
46704748 %collection (lien args.t |=(c=itype (itype-occurs n c sub)))
46714749 %face $(t body.t)
46724750 %fn |($(t sample.t) $(t product.t))
@@ -4685,6 +4763,11 @@
46854763 =. a (itype-walk a sub)
46864764 =. b (itype-walk b sub)
46874765 ?: =(a b) `sub
4766+ ?: &(?=(%grec -.a) ?=(%grec -.b))
4767+ ?. &(=(at.a at.b) =(name.a name.b)) ~
4768+ (itype-unify-args args.a args.b sub)
4769+ ?: &(?=(%jrec -.a) ?=(%jrec -.b))
4770+ ?:(&(=(at.a at.b) =(name.a name.b) =(head.a head.b) =(aura.a aura.b) =(tail.a tail.b)) `sub ~)
46884771 ?: &(?=(%recursive -.a) ?=(%recursive -.b))
46894772 ?:(&(=(module.a module.b) =(name.a name.b)) `sub ~)
46904773 ?: &(?=(%union -.a) ?=(%union -.b))
@@ -4701,6 +4784,32 @@
47014784 ?: ?=(%var -.b)
47024785 ?: (itype-occurs id.b a sub) ~
47034786 `[[id.b a] sub]
4787+ :: Arithmetic's aura variable excludes loobeans; decimal literals
4788+ :: remain defaultable until a later constraint makes them concrete.
4789+ ?: &(?=(%nvar -.a) ?=(%rvar -.b))
4790+ `[[id.b [%rnvar id.a]] [id.a [%rnvar id.a]] sub]
4791+ ?: &(?=(%rvar -.a) ?=(%nvar -.b))
4792+ `[[id.a [%rnvar id.b]] [id.b [%rnvar id.b]] sub]
4793+ ?: &(?=(%rnvar -.a) ?=(%rvar -.b)) `[[id.b a] sub]
4794+ ?: &(?=(%rvar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4795+ ?: &(?=(%rnvar -.a) ?=(%nvar -.b)) `[[id.b a] sub]
4796+ ?: &(?=(%nvar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4797+ ?: &(?=(%rnvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4798+ ?: &(?=(%avar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4799+ ?: ?=(%rnvar -.a)
4800+ ?. |(?=(%rnvar -.b) ?=(%atom -.b)) ~
4801+ `[[id.a b] sub]
4802+ ?: ?=(%rnvar -.b)
4803+ ?. ?=(%atom -.a) ~
4804+ `[[id.b a] sub]
4805+ ?: &(?=(%avar -.a) ?=(%rvar -.b)) `[[id.a b] sub]
4806+ ?: &(?=(%rvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4807+ ?: ?=(%rvar -.a)
4808+ ?. |(?=(%rvar -.b) ?=(%atom -.b)) ~
4809+ `[[id.a b] sub]
4810+ ?: ?=(%rvar -.b)
4811+ ?. ?=(%atom -.a) ~
4812+ `[[id.b a] sub]
47044813 :: The narrower decimal constraint survives a match with an atom
47054814 :: variable; decimal syntax alone does not make it a loobean.
47064815 ?: &(?=(%nvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
@@ -4755,7 +4864,9 @@
47554864 ?- -.t
47564865 %var |
47574866 %avar |
4867+ %rvar |
47584868 %nvar |
4869+ %rnvar |
47594870 %atom |
47604871 %any-atom &
47614872 %flag |
@@ -4764,6 +4875,8 @@
47644875 %const |
47654876 %union |((lien cases.t |=(c=itype (itype-has-any-atom c sub))) (lien args.t |=(c=itype (itype-has-any-atom c sub))))
47664877 %recursive |
4878+ %jrec |
4879+ %grec (lien args.t |=(c=itype (itype-has-any-atom c sub)))
47674880 %collection (lien args.t |=(c=itype (itype-has-any-atom c sub)))
47684881 %face $(t body.t)
47694882 %fn |($(t sample.t) $(t product.t))
@@ -4826,7 +4939,9 @@
48264939 ?- -.typ
48274940 %var |
48284941 %avar |
4942+ %rvar |
48294943 %nvar |
4944+ %rnvar |
48304945 %atom &
48314946 %any-atom &
48324947 %flag &
@@ -4835,6 +4950,8 @@
48354950 %const &
48364951 %union |((lien cases.typ |=(c=itype (itype-has-fixed-atom c))) (lien args.typ |=(c=itype (itype-has-fixed-atom c))))
48374952 %recursive |
4953+ %jrec |
4954+ %grec (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
48384955 %collection (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
48394956 %face $(typ body.typ)
48404957 %fn |($(typ sample.typ) $(typ product.typ))
@@ -4863,6 +4980,7 @@
48634980 ^- ?
48644981 =. t (itype-walk t sub)
48654982 ?- -.t
4983+ %grec (lien args.t |=(c=itype (itype-has-face c sub)))
48664984 %collection (lien args.t |=(c=itype (itype-has-face c sub)))
48674985 %face &
48684986 %cell |($(t hed.t) $(t tal.t))
@@ -4870,6 +4988,42 @@
48704988 * |
48714989 ==
48724990::
4991+:: Closed function samples may omit a slot face, but a known name must
4992+:: match another known name. Keep nested value faces and require exact
4993+:: invariant compatibility; a faced tail against a cell is ambiguous.
4994+++ itype-closed-slot-match
4995+ |= [a=itype b=itype]
4996+ ^- ?
4997+ ?: &(?=(%face -.a) ?=(%face -.b))
4998+ ?. =(name.a name.b) |
4999+ ?=(^ (itype-unify body.a body.b ~))
5000+ ?: ?=(%face -.a) ?=(^ (itype-unify body.a b ~))
5001+ ?: ?=(%face -.b) ?=(^ (itype-unify a body.b ~))
5002+ ?=(^ (itype-unify a b ~))
5003+++ itype-closed-sample-match
5004+ |= [a=itype b=itype fuel=@ud]
5005+ ^- ?
5006+ ?: =(0 fuel) |
5007+ ?. &(?=(%cell -.a) ?=(%cell -.b)) |
5008+ ?. (itype-closed-slot-match hed.a hed.b) |
5009+ =/ x=itype tal.a
5010+ =/ y=itype tal.b
5011+ ?: &(?=(%cell -.x) ?=(%cell -.y))
5012+ ?=(^ (itype-unify x y ~))
5013+ ?: |(&(?=(%face -.x) ?=(%cell -.y)) &(?=(%cell -.x) ?=(%face -.y))) |
5014+ (itype-closed-slot-match x y)
5015+++ itype-closed-gates-match
5016+ |= [a=itype b=itype]
5017+ ^- ?
5018+ ?. &(?=(%fn -.a) ?=(%fn -.b)) |
5019+ ?. &(?=(%cell -.sample.a) ?=(%cell -.sample.b)) |
5020+ ?. =(product.a product.b) |
5021+ ?^ (itype-vars a) |
5022+ ?^ (itype-vars b) |
5023+ ?: |((itype-has-tag a) (itype-has-tag b)) |
5024+ ?. (itype-closed-sample-match sample.a sample.b 1.024) |
5025+ ?=(^ (itype-unify product.a product.b ~))
5026+::
48735027++ itype-face-asym-collection-args
48745028 |= [as=(list itype) bs=(list itype) sub=isub]
48755029 ^- ?
@@ -4883,12 +5037,15 @@
48835037 ^- ?
48845038 =. a (itype-walk a sub)
48855039 =. b (itype-walk b sub)
5040+ ?: &(?=(%grec -.a) ?=(%grec -.b))
5041+ ?. &(=(at.a at.b) =(name.a name.b)) |
5042+ (itype-face-asym-collection-args args.a args.b sub)
48865043 ?: &(?=(%collection -.a) ?=(%collection -.b))
48875044 ?. =(name.a name.b) |
48885045 (itype-face-asym-collection-args args.a args.b sub)
48895046 ?: &(?=(%face -.a) ?=(%face -.b)) $(a body.a, b body.b)
4890− ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%nvar -.b))
4891− ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%nvar -.a))
5047+ ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%rvar -.b) |(?=(%nvar -.b) ?=(%rnvar -.b)))
5048+ ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%rvar -.a) |(?=(%nvar -.a) ?=(%rnvar -.a)))
48925049 ?: &(?=(%cell -.a) ?=(%cell -.b)) |($(a hed.a, b hed.b) $(a tal.a, b tal.b))
48935050 ?: &(?=(%fn -.a) ?=(%fn -.b)) |($(a sample.a, b sample.b) $(a product.a, b product.b))
48945051 |
@@ -4911,6 +5068,30 @@
49115068 [%cell $(actual hed.actual, expected hed.expected) $(actual tal.actual, expected tal.expected)]
49125069 expected
49135070::
5071+:: Positional call arguments do not write the sample's enclosing field
5072+:: labels. Ignore one raw sample-slot face per written argument while
5073+:: checking value faces as usual. An unknown or variable-bound cell spine
5074+:: cannot justify this distinction, so keep the existing conservative guard.
5075+++ itype-positional-slot-face-asym
5076+ |= [actual=itype expected=itype sub=isub]
5077+ ^- ?
5078+ ?: &(?=(%fn -.actual) ?=(%fn -.expected) (itype-closed-gates-match actual expected)) |
5079+ (itype-face-asym actual expected sub)
5080+::
5081+++ itype-positional-face-asym
5082+ |= [args=(list expr) actual=itype expected=itype sub=isub]
5083+ ^- ?
5084+ ?~ args &
5085+ ?~ t.args
5086+ =/ slot=itype expected
5087+ =? slot ?=(%face -.slot) body.slot
5088+ (itype-positional-slot-face-asym actual slot sub)
5089+ ?. &(?=(%cell -.actual) ?=(%cell -.expected)) &
5090+ =/ slot=itype hed.expected
5091+ =? slot ?=(%face -.slot) body.slot
5092+ ?: (itype-positional-slot-face-asym hed.actual slot sub) &
5093+ $(args t.args, actual tal.actual, expected tal.expected)
5094+::
49145095++ itype-output-may-be-cell
49155096 |= [t=itype sub=isub]
49165097 ^- ?
@@ -4920,6 +5101,8 @@
49205101 %cell &
49215102 %union &
49225103 %recursive &
5104+ %jrec &
5105+ %grec &
49235106 %noun &
49245107 %collection &
49255108 %face $(t body.t)
@@ -4949,6 +5132,7 @@
49495132 ^- ?
49505133 ?- -.t
49515134 %tag &
5135+ %grec (lien args.t |=(c=itype (itype-has-tag c)))
49525136 %collection (lien args.t |=(c=itype (itype-has-tag c)))
49535137 %face $(t body.t)
49545138 %fn |($(t sample.t) $(t product.t))
@@ -4962,6 +5146,7 @@
49625146 ^- ?
49635147 ?- -.t
49645148 %union &
5149+ %grec (lien args.t |=(c=itype (itype-has-union c)))
49655150 %collection (lien args.t |=(c=itype (itype-has-union c)))
49665151 %face $(t body.t)
49675152 %fn |($(t sample.t) $(t product.t))
@@ -4980,6 +5165,7 @@
49805165 %union
49815166 ?: &(?=(~ label.t) ?=(^ args.t)) &
49825167 (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-generic c)))
5168+ %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-generic c))))
49835169 %collection (lien args.t |=(c=itype (itype-has-hidden-generic c)))
49845170 %face $(t body.t)
49855171 %fn |($(t sample.t) $(t product.t))
@@ -4992,6 +5178,8 @@
49925178 ^- ?
49935179 ?- -.t
49945180 %recursive &
5181+ %jrec &
5182+ %grec &
49955183 %collection (lien args.t |=(c=itype (itype-has-recursive c)))
49965184 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-recursive c)))
49975185 %face $(t body.t)
@@ -5005,6 +5193,8 @@
50055193 ^- ?
50065194 ?- -.t
50075195 %recursive ?=(~ label.t)
5196+ %jrec ?=(~ label.t)
5197+ %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-recursive c))))
50085198 %collection (lien args.t |=(c=itype (itype-has-hidden-recursive c)))
50095199 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-recursive c)))
50105200 %face $(t body.t)
@@ -5032,34 +5222,77 @@
50325222 $(cases t.cases, good `trial)
50335223 ==
50345224::
5035−:: A constructor needs a case with its tag at the head and a payload
5036−:: compatible with the expected gate sample. Other case forms do not
5037−:: identify a constructor.
5225+:: A constructor needs a case whose head has the same literal noun as its
5226+:: tag. An unresolved or opaque case may reveal one later, so it cannot
5227+:: prove a mismatch or a unique match. A broad atom mold is not a case.
50385228::
50395229++ itype-fit-ctor-cases
50405230 |= [tag=lit sample=itype cases=(list itype) sub=isub next=@ud]
50415231 ^- ifit
50425232 =/ found=(unit ifit) ~
5233+ =/ pending=? |
50435234 |-
5044− ?~ cases ?~(found [%bad ~] u.found)
5045− =/ c=itype (itype-walk i.cases sub)
5235+ ?~ cases
5236+ ?: pending [%unknown ~]
5237+ ?~ found [%bad ~]
5238+ u.found
5239+ =/ raw=itype i.cases
5240+ ?: ?=(%var -.raw)
5241+ $(cases t.cases, pending &)
5242+ =/ c=itype (itype-walk raw sub)
5243+ ?: ?=(?(%var %tag %recursive %jrec %grec %union %face) -.c)
5244+ $(cases t.cases, pending &)
50465245 ?. ?=(%cell -.c) $(cases t.cases)
5047− =/ head=itype (itype-walk hed.c sub)
5246+ =/ raw-head=itype hed.c
5247+ ?: ?=(%var -.raw-head)
5248+ $(cases t.cases, pending &)
5249+ =/ head=itype (itype-walk raw-head sub)
5250+ :: A single faced, explicitly atom-only head cannot be the tag case.
5251+ :: Do not follow variables or peel nested faces for this negative proof.
5252+ ?: ?=(%face -.head)
5253+ ?: ?=(?(%atom %any-atom %flag %avar %rvar %nvar %rnvar) -.body.head)
5254+ $(cases t.cases)
5255+ $(cases t.cases, pending &)
5256+ ?: ?=(?(%var %tag %recursive %jrec %grec %union) -.head)
5257+ $(cases t.cases, pending &)
50485258 ?. ?=(%const -.head) $(cases t.cases)
5049− ?. =(%term form.literal.head) $(cases t.cases)
50505259 ?. =(val.literal.head val.tag) $(cases t.cases)
5051− ?^ found [%unknown ~]
5260+ :: Equal heads can have disjoint payloads. Test each from the original
5261+ :: substitution; a unique success is usable only with no unknown rival.
50525262 =/ trial=ifit (itype-fit sample tal.c sub next)
5053− $(cases t.cases, found `trial)
5263+ ?- -.trial
5264+ %bad $(cases t.cases)
5265+ %unknown $(cases t.cases, pending &)
5266+ %ok
5267+ ?^ found [%unknown ~]
5268+ $(cases t.cases, found `trial)
5269+ ==
50545270::
50555271++ itype-fit
50565272 |= [actual=itype expected=itype sub=isub next=@ud]
50575273 ^- ifit
5274+ (itype-fit-inner actual expected sub next | |)
5275+++ itype-fit-inner
5276+ |= [actual=itype expected=itype sub=isub next=@ud skip-width=? spine-proof=?]
5277+ ^- ifit
5278+ ?: &(!skip-width ?=(%cell -.actual) ?=(%cell -.expected) |((width-spine-exhausted actual 1.024) (width-spine-exhausted expected 1.024)))
5279+ [%unknown ~]
5280+ =/ known=(unit [source=iwfields target=iwfields])
5281+ ?: skip-width ~
5282+ (width-known-shape actual expected sub)
5283+ =/ too-wide=? ?~(known | (gth (lent order.source.u.known) (lent order.target.u.known)))
5284+ ?: too-wide [%unknown ~]
5285+ =/ spine-checked=? |(spine-proof ?=(^ known))
50585286 =/ uncertain=?
5059− |(?=(%var -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%var -.expected) ?=(%avar -.expected) ?=(%nvar -.expected))
5287+ |(?=(%var -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)) ?=(%var -.expected) ?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected)))
5288+ =/ actual-open=?
5289+ |(?=(%var -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))
50605290 =. actual (itype-walk actual sub)
50615291 =. expected (itype-walk expected sub)
50625292 ?: =(actual expected) [%ok sub next]
5293+ :: The relation of the source loobean mold to explicit @f is not yet
5294+ :: established. Keep it unsupported rather than asserting a mismatch.
5295+ ?: &(?=(%flag -.actual) ?=(%atom -.expected) =(%f aura.expected)) [%unknown ~]
50635296 :: Any value can be used where a noun is expected. An unresolved
50645297 :: bare tag is fixed as a constant; a constructor still needs a gate.
50655298 ?: ?=(%noun -.expected)
@@ -5069,6 +5302,19 @@
50695302 [%ok sub next]
50705303 :: An arbitrary noun is not known to fit a narrower type.
50715304 ?: &(?=(%noun -.actual) !?=(%var -.expected)) [%unknown ~]
5305+ ?: &(!uncertain ?=(%grec -.actual) ?=(%face -.expected)) $(expected body.expected)
5306+ ?: &(!uncertain ?=(%face -.actual) ?=(%grec -.expected)) $(actual body.actual)
5307+ ?: &(?=(%grec -.actual) ?=(%grec -.expected))
5308+ ?. &(=(at.actual at.expected) =(name.actual name.expected)) [%unknown ~]
5309+ =/ matched=(unit isub) (itype-unify-args args.actual args.expected sub)
5310+ ?~ matched [%unknown ~]
5311+ [%ok u.matched next]
5312+ ?: &(|(?=(%grec -.actual) ?=(%grec -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
5313+ ?: &(!uncertain ?=(%jrec -.actual) ?=(%face -.expected)) $(expected body.expected)
5314+ ?: &(!uncertain ?=(%face -.actual) ?=(%jrec -.expected)) $(actual body.actual)
5315+ ?: &(?=(%jrec -.actual) ?=(%jrec -.expected))
5316+ ?:(&(=(at.actual at.expected) =(name.actual name.expected) =(head.actual head.expected) =(aura.actual aura.expected) =(tail.actual tail.expected)) [%ok sub next] [%bad ~])
5317+ ?: &(|(?=(%jrec -.actual) ?=(%jrec -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
50725318 ?: &(?=(%recursive -.actual) ?=(%recursive -.expected))
50735319 ?:(&(=(module.actual module.expected) =(name.actual name.expected)) [%ok sub next] [%bad ~])
50745320 ?: &(|(?=(%recursive -.actual) ?=(%recursive -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
@@ -5080,12 +5326,21 @@
50805326 =/ unified=(unit isub) (itype-unify-args args.actual args.expected sub)
50815327 ?^ unified [%ok u.unified next]
50825328 [%unknown ~]
5329+ :: A known union can instantiate an unconstrained sample directly;
5330+ :: preserve unknown results for variable-bound union origins.
5331+ ?: &(!actual-open ?=(%union -.actual) ?=(%var -.expected))
5332+ ?~ origin.actual [%unknown ~]
5333+ =/ normalized=itype (itype-normalize actual sub)
5334+ ?: |((itype-has-tag normalized) (itype-has-recursive normalized) (itype-has-any-atom actual sub)) [%unknown ~]
5335+ =/ unified=(unit isub) (itype-unify actual expected sub)
5336+ ?~ unified [%unknown ~]
5337+ [%ok u.unified next]
50835338 :: A concrete union value in a tuple may acquire the expected field's
50845339 :: face. A variable-bound union still needs face propagation support.
50855340 ?: &(!uncertain ?=(%union -.actual) ?=(%face -.expected))
50865341 $(expected body.expected)
50875342 ?: ?=(%union -.actual) [%unknown ~]
5088− ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%nvar -.actual))) [%unknown ~]
5343+ ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))) [%unknown ~]
50895344 ?: &(?=(%union -.expected) !?=(%var -.actual))
50905345 (itype-fit-cases actual cases.expected sub next)
50915346 ?: ?=(%tag -.actual)
@@ -5093,7 +5348,7 @@
50935348 =/ u=(unit isub) (itype-unify actual expected sub)
50945349 ?~ u [%bad ~]
50955350 [%ok u.u next]
5096− ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5351+ ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
50975352 ?: ?=(%face -.expected) $(expected body.expected)
50985353 ?: constructor.actual
50995354 ?. ?=(%fn -.expected) [%bad ~]
@@ -5121,13 +5376,17 @@
51215376 =/ u=(unit isub) (itype-unify actual expected sub)
51225377 ?~ u [%bad ~]
51235378 [%ok u.u next]
5124− ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5379+ ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
51255380 ?: ?=(%face -.expected) $(expected body.expected)
51265381 ?: &(?=(%collection -.expected) =(%list name.expected) =(0 val.literal.actual))
51275382 [%unknown ~]
51285383 ?: ?=(%const -.expected)
51295384 ?:(=(val.literal.actual val.literal.expected) [%ok sub next] [%bad ~])
51305385 ?: ?=(%atom -.expected)
5386+ :: A loobean singleton must not silently widen into another aura.
5387+ ?: =(%loobean form.literal.actual)
5388+ ?: =(%f aura.expected) [%unknown ~]
5389+ [%bad ~]
51315390 ?: |(=(%tas aura.expected) =(%ta aura.expected)) [%ok sub next]
51325391 [%bad ~]
51335392 ?: ?=(%flag -.expected)
@@ -5135,8 +5394,14 @@
51355394 ?: ?=(%any-atom -.expected) [%ok sub next]
51365395 [%bad ~]
51375396 ?: &(uncertain (itype-face-asym actual expected sub)) [%unknown ~]
5397+ :: A known face labels the same noun. Peel it before applying the
5398+ :: directional unrestricted-atom rule, preserving raw-variable guards.
5399+ ?: &(!uncertain ?=(%any-atom -.actual) ?=(%face -.expected))
5400+ $(expected body.expected, skip-width |, spine-proof |)
5401+ ?: &(!uncertain ?=(%any-atom -.expected) ?=(%face -.actual))
5402+ $(actual body.actual, skip-width |, spine-proof |)
51385403 ?: ?=(%any-atom -.expected)
5139− ?: |(?=(%atom -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%flag -.actual)) [%ok sub next]
5404+ ?: |(?=(%atom -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)) ?=(%flag -.actual)) [%ok sub next]
51405405 ?: ?=(%var -.actual)
51415406 =/ unified=(unit isub) (itype-unify actual [%avar next] sub)
51425407 ?~ unified [%bad ~]
@@ -5147,16 +5412,16 @@
51475412 =/ unified=(unit isub) (itype-unify actual expected sub)
51485413 ?~ unified [%bad ~]
51495414 [%ok u.unified next]
5150− ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5415+ ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
51515416 [%bad ~]
51525417 ?: &(?=(%atom -.actual) ?=(%atom -.expected))
51535418 ?: (aura-prefix aura.expected aura.actual) [%ok sub next]
51545419 ?: &((aura-prefix aura.actual aura.expected) uncertain) [%unknown ~]
51555420 [%bad ~]
51565421 ?: &(?=(%cell -.actual) ?=(%cell -.expected))
5157− =/ first=ifit $(actual hed.actual, expected hed.expected)
5422+ =/ first=ifit $(actual hed.actual, expected hed.expected, skip-width |, spine-proof |)
51585423 ?. ?=(%ok -.first) first
5159− $(actual tal.actual, expected tal.expected, sub sub.first, next next.first)
5424+ $(actual tal.actual, expected tal.expected, sub sub.first, next next.first, skip-width spine-checked, spine-proof spine-checked)
51605425 :: A field may add a face to an occurrence of the very same type
51615426 :: variable. Binding that variable to a face around itself would fail
51625427 :: the occurs check, but its underlying type has already matched.
@@ -5178,9 +5443,10 @@
51785443 [%ok u.unified next]
51795444 ?: &(?=(%face -.actual) ?=(%face -.expected))
51805445 ?. =(name.actual name.expected) [%bad ~]
5181− $(actual body.actual, expected body.expected)
5182− ?: ?=(%face -.actual) $(actual body.actual)
5183− ?: ?=(%face -.expected) $(expected body.expected)
5446+ $(actual body.actual, expected body.expected, skip-width |, spine-proof |)
5447+ ?: ?=(%face -.actual) $(actual body.actual, skip-width |, spine-proof |)
5448+ ?: ?=(%face -.expected) $(expected body.expected, skip-width |, spine-proof |)
5449+ ?: &(!uncertain (itype-closed-gates-match actual expected)) [%ok sub next]
51845450 ?: (itype-face-asym actual expected sub) [%unknown ~]
51855451 ?: |((itype-has-any-atom actual sub) (itype-has-any-atom expected sub))
51865452 [%unknown ~]
@@ -5257,7 +5523,17 @@
52575523+$ ienv (list [name=term scheme=ischeme])
52585524+$ imold-types (list [name=term template=ischeme])
52595525+$ iderived [name=term agent=term mark=term]
5260−+$ ifile [values=ienv molds=imold-types at=path derived=(list iderived)]
5526++$ iwidth-definition [name=term original=expr typ=itype sub=isub projections=(list iwprojection)]
5527++$ iwidth-dependency [at=path source=(unit @t) definitions=(list iwidth-definition)]
5528+:: Nonrecursive request evidence is compiler-owned metadata, not a property
5529+:: of an arbitrary ask value. Reader graphs and source inputs are trusted.
5530++$ irequest-evidence
5531+ [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]
5532+:: A unit distinguishes a verified empty closure from a detached legacy file.
5533+:: The opaque prelude is an exact trusted input, not a recursive interface mold.
5534++$ irequest-graph
5535+ [paths=(set path) requests=(list irequest-evidence) bundle-input=* prelude-input=* prelude-values=(list term) prelude-molds=(list term) externals=iexternals marks=imark-externals]
5536++$ 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)]
52615537+$ ijimports (list [face=term interface=ifile])
52625538+$ icap [name=@t id=@ud at=span]
52635539+$ icaps (list icap)
@@ -5267,7 +5543,167 @@
52675543:: This core has no Ford dependencies; unrecognized payloads fail closed.
52685544+$ iexternals (list [module=term name=term result=*])
52695545+$ imark-externals (list [mark=term result=*])
5270−+$ 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)]
5546+:: Hole obligations survive discarded expressions until their owning
5547+:: definition has inferred; their source spans support unresolved reports.
5548++$ ihole [id=@ud at=span]
5549+:: Recursive-mold unfolding spends fuel in the threaded inference state.
5550+:: Retries can restart from an earlier state, so this bounds an attempt,
5551+:: not all parsing or module-checking work.
5552+:: Experimental: only closed, uniquely faced records have known axes.
5553++$ iwfield [name=term axis=@ud typ=itype]
5554++$ iwfields [order=(list iwfield) index=(map term iwfield)]
5555++$ iwstep [name=term axis=@ud]
5556++$ iwidth-result [steps=(list iwstep) sub=isub next=@ud]
5557++$ iwprojection [at=span original=expr source=itype target=itype steps=(list iwstep)]
5558+++ width-scan
5559+ |= [typ=itype sub=isub axis=@ud fuel=@ud]
5560+ ^- (unit iwfields)
5561+ =/ order=(list iwfield) ~
5562+ =/ index=(map term iwfield) *(map term iwfield)
5563+ |-
5564+ ?: =(0 fuel) ~
5565+ ?: |(?=(%var -.typ) ?=(%avar -.typ) ?=(%rvar -.typ) ?=(%nvar -.typ) ?=(%rnvar -.typ)) ~
5566+ ?: ?=(%face -.typ)
5567+ =/ entry=iwfield [name.typ axis body.typ]
5568+ ?: ?=(^ (~(get by index) name.entry)) ~
5569+ `[(flop [entry order]) (~(put by index) name.entry entry)]
5570+ ?. ?=(%cell -.typ) ~
5571+ =/ head=itype hed.typ
5572+ ?: |(?=(%var -.head) ?=(%avar -.head) ?=(%rvar -.head) ?=(%nvar -.head) ?=(%rnvar -.head)) ~
5573+ ?. ?=(%face -.head) ~
5574+ =/ entry=iwfield [name.head (mul 2 axis) body.head]
5575+ ?: ?=(^ (~(get by index) name.entry)) ~
5576+ $(typ tal.typ, axis +((mul 2 axis)), fuel (dec fuel), order [entry order], index (~(put by index) name.entry entry))
5577+++ width-in-order
5578+ |= [source=(list iwfield) target=(list iwfield)]
5579+ ^- ?
5580+ ?~ target &
5581+ ?~ source |
5582+ ?: =(name.i.source name.i.target) $(source t.source, target t.target)
5583+ $(source t.source)
5584+++ width-fit-fields
5585+ |= [source=(map term iwfield) target=(list iwfield) sub=isub next=@ud]
5586+ ^- (unit iwidth-result)
5587+ ?~ target `[~ sub next]
5588+ =/ found=(unit iwfield) (~(get by source) name.i.target)
5589+ ?~ found ~
5590+ =/ fit=ifit (itype-fit typ.u.found typ.i.target sub next)
5591+ ?. ?=(%ok -.fit) ~
5592+ =/ rest=(unit iwidth-result) $(target t.target, sub sub.fit, next next.fit)
5593+ ?~ rest ~
5594+ `[[[name.i.target axis.u.found] steps.u.rest] sub.u.rest next.u.rest]
5595+++ width-spine-exhausted
5596+ |= [t=itype fuel=@ud]
5597+ ^- ?
5598+ ?: =(0 fuel) &
5599+ ?. ?=(%cell -.t) |
5600+ ?. ?=(%face -.hed.t) |
5601+ $(t tal.t, fuel (dec fuel))
5602+++ width-known-shape
5603+ |= [actual=itype expected=itype sub=isub]
5604+ ^- (unit [source=iwfields target=iwfields])
5605+ ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
5606+ =/ source=(unit iwfields) (width-scan actual sub 1 1.024)
5607+ =/ target=(unit iwfields) (width-scan expected sub 1 1.024)
5608+ ?~ source ~
5609+ ?~ target ~
5610+ `[u.source u.target]
5611+::
5612+++ width-shape
5613+ |= [actual=itype expected=itype sub=isub]
5614+ ^- (unit [source=iwfields target=iwfields])
5615+ ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
5616+ =/ source=(unit iwfields) (width-scan actual sub 1 4.096)
5617+ =/ target=(unit iwfields) (width-scan expected sub 1 4.096)
5618+ ?~ source ~
5619+ ?~ target ~
5620+ ?. (gth (lent order.u.source) (lent order.u.target)) ~
5621+ `[u.source u.target]
5622+++ width-proj-shape
5623+ |= [actual=itype expected=itype sub=isub]
5624+ ^- (unit [source=iwfields target=iwfields])
5625+ ?. &(|(?=(%cell -.actual) ?=(%face -.actual)) |(?=(%cell -.expected) ?=(%face -.expected))) ~
5626+ =/ source=(unit iwfields) (width-scan actual sub 1 4.096)
5627+ =/ target=(unit iwfields) (width-scan expected sub 1 4.096)
5628+ ?~ source ~
5629+ ?~ target ~
5630+ ?: (lth (lent order.u.source) (lent order.u.target)) ~
5631+ `[u.source u.target]
5632+::
5633+++ width-project
5634+ |= [shape=[source=iwfields target=iwfields] sub=isub next=@ud]
5635+ ^- (unit iwidth-result)
5636+ ?. (width-in-order order.source.shape order.target.shape) ~
5637+ (width-fit-fields index.source.shape order.target.shape sub next)
5638+::
5639+:: Provisional, globally budgeted gate-free proof. %no includes a
5640+:: gate-bearing witness; an uninhabited sibling could invalidate it.
5641+:: Input types must be resolved and normalized under valid substitutions,
5642+:: from trusted source-backed interfaces and reader results. Collection
5643+:: list/unit names rely on their existing identity invariant; this arm
5644+:: does not validate fabricated internal types.
5645++$ igf-segment
5646+ $% [%field name=term]
5647+ [%head ~]
5648+ [%tail ~]
5649+ [%item ~]
5650+ [%case index=@ud]
5651+ ==
5652++$ igate-free [verdict=?(%yes %no %unknown) inhabited=? left=@ud path=(unit (list igf-segment))]
5653+++ gate-free-types
5654+ |= [types=(list itype) fuel=@ud path=(list igf-segment) index=@ud]
5655+ ^- igate-free
5656+ ?~ types [%yes | fuel ~]
5657+ ?: =(0 fuel) [%unknown | 0 ~]
5658+ =/ first=igate-free (gate-free-type i.types fuel [[%case index] path])
5659+ ?: =(%no verdict.first) first
5660+ =/ rest=igate-free $(types t.types, fuel left.first, index +(index))
5661+ ?: =(%no verdict.rest) rest
5662+ =/ inhabited=? |(inhabited.first inhabited.rest)
5663+ ?: |(=(%unknown verdict.first) =(%unknown verdict.rest)) [%unknown inhabited left.rest ~]
5664+ [%yes inhabited left.rest ~]
5665+++ gate-free-type
5666+ |= [typ=itype fuel=@ud path=(list igf-segment)]
5667+ ^- igate-free
5668+ ?: =(0 fuel) [%unknown | 0 ~]
5669+ =. fuel (dec fuel)
5670+ ?- -.typ
5671+ %fn [%no & fuel `(flop path)]
5672+ %atom [%yes & fuel ~]
5673+ %any-atom [%yes & fuel ~]
5674+ %flag [%yes & fuel ~]
5675+ %const [%yes & fuel ~]
5676+ %face $(typ body.typ, path [[%field name.typ] path])
5677+ %cell
5678+ =/ head=igate-free $(typ hed.typ, path [[%head ~] path])
5679+ =/ tail=igate-free $(typ tal.typ, fuel left.head, path [[%tail ~] path])
5680+ =/ inhabited=? &(inhabited.head inhabited.tail)
5681+ ?: &(=(%no verdict.head) inhabited.tail) head(left left.tail)
5682+ ?: &(=(%no verdict.tail) inhabited.head) tail
5683+ ?: |(!=(%yes verdict.head) !=(%yes verdict.tail)) [%unknown inhabited left.tail ~]
5684+ [%yes inhabited left.tail ~]
5685+ %collection
5686+ ?. |(=(%list name.typ) =(%unit name.typ)) [%unknown | fuel ~]
5687+ ?. ?=([* ~] args.typ) [%unknown | fuel ~]
5688+ =/ item=igate-free $(typ i.args.typ, path [[%item ~] path])
5689+ item(inhabited &)
5690+ %union
5691+ ?~ cases.typ [%unknown | fuel ~]
5692+ (gate-free-types cases.typ fuel path 0)
5693+ %noun [%unknown & fuel ~]
5694+ %var [%unknown | fuel ~]
5695+ %avar [%yes & fuel ~]
5696+ %rvar [%yes & fuel ~]
5697+ %nvar [%yes & fuel ~]
5698+ %rnvar [%yes & fuel ~]
5699+ %tag [%unknown | fuel ~]
5700+ %recursive [%unknown | fuel ~]
5701+ %jrec [%yes & fuel ~]
5702+ %grec [%unknown | fuel ~]
5703+ ==
5704+::
5705++$ igate-prelude-evidence [iface=ifile gates=(map term def)]
5706++$ 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)])]
52715707+$ idiag [msg=tape sites=(list [at=span note=tape])]
52725708+$ iresult (each [typ=itype state=istate] idiag)
52735709+$ isample-result (each [typ=itype env=ienv state=istate] tape)
@@ -5287,6 +5723,7 @@
52875723 |= [t=itype sub=isub]
52885724 ^- itype
52895725 =. t (itype-walk t sub)
5726+ ?: ?=(%grec -.t) t(args (turn args.t |=(c=itype (itype-normalize c sub))))
52905727 ?: ?=(%collection -.t) [%collection name.t (turn args.t |=(c=itype (itype-normalize c sub)))]
52915728 ?: ?=(%union -.t)
52925729 [%union (turn cases.t |=(c=itype (itype-normalize c sub))) origin.t label.t (turn args.t |=(c=itype (itype-normalize c sub)))]
@@ -5312,6 +5749,8 @@
53125749 %fn &
53135750 %cell |($(t hed.t) $(t tal.t))
53145751 %recursive |
5752+ %jrec |
5753+ %grec &
53155754 %collection (lien args.t |=(c=itype (itype-has-gate c)))
53165755 %face $(t body.t)
53175756 %union (lien cases.t |=(c=itype (itype-has-gate c)))
@@ -5319,7 +5758,9 @@
53195758 %const |
53205759 %var |
53215760 %avar |
5761+ %rvar |
53225762 %nvar |
5763+ %rnvar |
53235764 %atom |
53245765 %any-atom |
53255766 %flag |
@@ -5332,19 +5773,125 @@
53325773 ?: (itype-has-gate t) t
53335774 ?- -.t
53345775 %nvar [%atom %ud]
5776+ %rnvar [%atom %ud]
5777+ %grec t(args (turn args.t |=(c=itype (default-decimals c))))
53355778 %collection [%collection name.t (turn args.t |=(c=itype (default-decimals c)))]
53365779 %face [%face name.t $(t body.t)]
53375780 %cell [%cell $(t hed.t) $(t tal.t)]
53385781 * t
53395782 ==
53405783::
5784+:: A hole is solved only by a fully determined type or a written
5785+:: in-scope type variable. Ordinary fresh variables are not evidence.
5786+:: Compare representatives after substitution, since unification can
5787+:: orient a written capital toward the hole rather than the reverse.
5788+++ hole-variable-id
5789+ |= t=itype
5790+ ^- (unit @ud)
5791+ ?- -.t
5792+ %var `id.t
5793+ %avar `id.t
5794+ %rvar `id.t
5795+ %nvar `id.t
5796+ %rnvar `id.t
5797+ %tag `id.t
5798+ * ~
5799+ ==
5800+++ hole-same-variable
5801+ |= [a=itype b=itype]
5802+ ^- ?
5803+ =/ x=(unit @ud) (hole-variable-id a)
5804+ ?~ x |
5805+ =/ y=(unit @ud) (hole-variable-id b)
5806+ ?~ y |
5807+ =(u.x u.y)
5808+++ hole-known
5809+ |= [t=itype state=istate]
5810+ ^- ?
5811+ =. t (itype-walk t sub.state)
5812+ ?- -.t
5813+ ?(%var %avar %rvar %nvar %rnvar)
5814+ ?: (lien caps.state |=(c=icap (hole-same-variable t (itype-walk [%var id.c] sub.state)))) &
5815+ (lien params.state |=(p=[name=@t typ=itype] (hole-same-variable t (itype-walk typ.p sub.state))))
5816+ %tag |
5817+ %any-atom &
5818+ %union &((levy cases.t |=(c=itype (hole-known c state))) (levy args.t |=(c=itype (hole-known c state))))
5819+ %grec (levy args.t |=(c=itype (hole-known c state)))
5820+ %collection (levy args.t |=(c=itype (hole-known c state)))
5821+ %face $(t body.t)
5822+ %fn &($(t sample.t) $(t product.t))
5823+ %cell &($(t hed.t) $(t tal.t))
5824+ * &
5825+ ==
5826+++ promote-restricted-numbers
5827+ |= [state=istate env=ienv]
5828+ ^- istate
5829+ :: With no written capitals, there is nothing to promote.
5830+ ?~ caps.state state
5831+ =/ ids=(list @ud) (turn caps.state |=(c=icap id.c))
5832+ =/ free=(list @ud) (free-env-vars env sub.state)
5833+ |-
5834+ ?~ ids state
5835+ =/ t=itype (itype-walk [%var i.ids] sub.state)
5836+ ?: &(?=(%rnvar -.t) !(lien free |=(n=@ud =(n +.t))))
5837+ $(ids t.ids, state state(sub [[+.t [%rvar +.t]] sub.state]))
5838+ $(ids t.ids)
5839+::
5840+++ default-hole-numbers
5841+ |= [all=(list ihole) prior=(list ihole) state=istate env=ienv permit=?]
5842+ ^- istate
5843+ :: Do not default a named capital or a variable captured from env.
5844+ ?. permit state
5845+ ?: =(all prior) state
5846+ ?~ all state
5847+ =/ t=itype (itype-walk [%var id.i.all] sub.state)
5848+ =/ free=(list @ud) (free-env-vars env sub.state)
5849+ =? state &(?=(?(%nvar %rnvar) -.t) !(hole-known t state) !(lien free |=(id=@ud =(id id.t))))
5850+ state(sub [[id.t [%atom %ud]] sub.state])
5851+ $(all t.all)
5852+::
5853+:: Only obligations created inside this definition belong to it.
5854+++ holes-created
5855+ |= [all=(list ihole) prior=(list ihole)]
5856+ ^- (list ihole)
5857+ ?: =(all prior) ~
5858+ ?~ all ~
5859+ [i.all $(all t.all)]
5860+++ hole-uncertain
5861+ |= [t=itype state=istate]
5862+ ^- ?
5863+ =. t (itype-walk t sub.state)
5864+ ?- -.t
5865+ ?(%tag %nvar %rnvar %avar %rvar) !(hole-known t state)
5866+ %union |((lien cases.t |=(c=itype (hole-uncertain c state))) (lien args.t |=(c=itype (hole-uncertain c state))))
5867+ %grec (lien args.t |=(c=itype (hole-uncertain c state)))
5868+ %collection (lien args.t |=(c=itype (hole-uncertain c state)))
5869+ %face $(t body.t)
5870+ %fn |($(t sample.t) $(t product.t))
5871+ %cell |($(t hed.t) $(t tal.t))
5872+ * |
5873+ ==
5874+::
5875+++ unresolved-hole
5876+ |= [all=(list ihole) prior=(list ihole) state=istate]
5877+ ^- (unit idiag)
5878+ =/ work=(list ihole) (flop (holes-created all prior))
5879+ |-
5880+ ?~ work ~
5881+ ?: (hole-known [%var id.i.work] state) $(work t.work)
5882+ ?: (hole-uncertain [%var id.i.work] state)
5883+ `["type hole needs unsupported inference" ~[[at.i.work "type hole"]]]
5884+ `["type hole needs a determined type" ~[[at.i.work "unresolved type hole"]]]
5885+::
53415886++ itype-vars
53425887 |= t=itype
53435888 ^- (list @ud)
53445889 ?- -.t
53455890 %var ~[id.t]
53465891 %avar ~[id.t]
5892+ %rvar ~[id.t]
53475893 %nvar ~[id.t]
5894+ %rnvar ~[id.t]
53485895 %atom ~
53495896 %any-atom ~
53505897 %flag ~
@@ -5353,6 +5900,8 @@
53535900 %const ~
53545901 %union (zing (turn (weld args.t cases.t) |=(c=itype (itype-vars c))))
53555902 %recursive ~
5903+ %jrec ~
5904+ %grec (zing (turn args.t |=(c=itype (itype-vars c))))
53565905 %collection (zing (turn args.t |=(c=itype (itype-vars c))))
53575906 %face $(t body.t)
53585907 %fn (weld $(t sample.t) $(t product.t))
@@ -5380,10 +5929,18 @@
53805929 =/ found=(unit itype) (itype-lookup id.t ren)
53815930 ?~ found t
53825931 u.found
5932+ %rvar
5933+ =/ found=(unit itype) (itype-lookup id.t ren)
5934+ ?~ found t
5935+ u.found
53835936 %nvar
53845937 =/ found=(unit itype) (itype-lookup id.t ren)
53855938 ?~ found t
53865939 u.found
5940+ %rnvar
5941+ =/ found=(unit itype) (itype-lookup id.t ren)
5942+ ?~ found t
5943+ u.found
53875944 %atom t
53885945 %any-atom t
53895946 %flag t
@@ -5392,6 +5949,8 @@
53925949 %const t
53935950 %union [%union (turn cases.t |=(c=itype (itype-rename c ren))) origin.t label.t (turn args.t |=(c=itype (itype-rename c ren)))]
53945951 %recursive t
5952+ %jrec t
5953+ %grec t(args (turn args.t |=(c=itype (itype-rename c ren))))
53955954 %collection [%collection name.t (turn args.t |=(c=itype (itype-rename c ren)))]
53965955 %face [%face name.t $(t body.t)]
53975956 %fn [%fn $(t sample.t) $(t product.t)]
@@ -5407,7 +5966,9 @@
54075966 ?- -.t
54085967 %var |
54095968 %avar =(n id.t)
5969+ %rvar =(n id.t)
54105970 %nvar =(n id.t)
5971+ %rnvar =(n id.t)
54115972 %atom |
54125973 %any-atom |
54135974 %flag |
@@ -5416,11 +5977,37 @@
54165977 %const |
54175978 %union |((lien cases.t |=(c=itype (itype-var-is-atom n c))) (lien args.t |=(c=itype (itype-var-is-atom n c))))
54185979 %recursive |
5980+ %jrec |
5981+ %grec (lien args.t |=(c=itype (itype-var-is-atom n c)))
54195982 %collection (lien args.t |=(c=itype (itype-var-is-atom n c)))
54205983 %face $(t body.t)
54215984 %fn |($(t sample.t) $(t product.t))
54225985 %cell |($(t hed.t) $(t tal.t))
54235986 ==
5987+++ itype-var-is-restricted
5988+ |= [n=@ud t=itype]
5989+ ^- ?
5990+ ?- -.t
5991+ %var |
5992+ %avar |
5993+ %rvar =(n id.t)
5994+ %nvar |
5995+ %rnvar |
5996+ %atom |
5997+ %any-atom |
5998+ %flag |
5999+ %noun |
6000+ %tag |
6001+ %const |
6002+ %union |((lien cases.t |=(c=itype (itype-var-is-restricted n c))) (lien args.t |=(c=itype (itype-var-is-restricted n c))))
6003+ %recursive |
6004+ %jrec |
6005+ %grec (lien args.t |=(c=itype (itype-var-is-restricted n c)))
6006+ %collection (lien args.t |=(c=itype (itype-var-is-restricted n c)))
6007+ %face $(t body.t)
6008+ %fn |($(t sample.t) $(t product.t))
6009+ %cell |($(t hed.t) $(t tal.t))
6010+ ==
54246011::
54256012:: Canonical numbering makes printed variables independent of the order
54266013:: the unifier happened to allocate intermediates.
@@ -5432,7 +6019,7 @@
54326019 =/ n=@ud 0
54336020 |-
54346021 ?~ vars (itype-rename t ren)
5435− =/ replacement=itype ?:((itype-var-is-atom i.vars t) [%avar n] [%var n])
6022+ =/ replacement=itype ?:((itype-var-is-restricted i.vars t) [%rvar n] ?:((itype-var-is-atom i.vars t) [%avar n] [%var n]))
54366023 $(vars t.vars, ren [[i.vars replacement] ren], n +(n))
54376024::
54386025++ instantiate-scheme
@@ -5443,11 +6030,11 @@
54436030 |-
54446031 ?~ vars [(itype-rename typ.scheme ren) state]
54456032 =/ replacement=itype
5446− ?:((itype-var-is-atom i.vars typ.scheme) [%avar next.state] [%var next.state])
6033+ ?:((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]))
54476034 :: A generalized atom variable is a valid origin for re-generalizing
54486035 :: an alias, just as a sample binder is.
54496036 =/ st=istate state(next +(next.state))
5450− =? binders.st ?=(%avar -.replacement) [next.state binders.state]
6037+ =? binders.st |(?=(%avar -.replacement) ?=(%rvar -.replacement)) [next.state binders.state]
54516038 $(vars t.vars, ren [[i.vars replacement] ren], state st)
54526039::
54536040++ icap-lookup
@@ -5518,6 +6105,11 @@
55186105 ?. ?=([%ref @ @] node) ~
55196106 ?. &(=(module +<.node) =(name +>.node)) ~
55206107 `[[%unknown ~] &]
6108+ %apply
6109+ ?. ?=([%apply %list [* ~]] node) ~
6110+ =/ item $(node -.+>.node)
6111+ ?~ item ~
6112+ `[[%or ~[[%atom `0] [%cell pat.u.item [%unknown ~]]]] has.u.item]
55216113 %face
55226114 ?. ?=([%face @ *] node) ~
55236115 ?. (jibb-face-name +<.node) ~
@@ -5572,6 +6164,10 @@
55726164 %cell ?:(?=([%cell * *] node) (imported-record-faces-valid node ~) |)
55736165 %fork (imported-faces-valid-list +.node)
55746166 %apply ?:(?=([%apply @ *] node) (imported-faces-valid-list +>.node) |)
6167+ %named
6168+ ?. ?=([%named @ @ *] node) |
6169+ =/ n=[%named module=@ name=@ body=*] ;;([%named module=@ name=@ body=*] node)
6170+ (imported-faces-valid body.n)
55756171 ==
55766172::
55776173++ imported-faces-valid-list
@@ -5625,6 +6221,15 @@
56256221 =/ aura=@ta (@ta +<.node)
56266222 ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
56276223 `[%atom aura]
6224+ %named
6225+ ?. ?=([%named @ @ *] node) ~
6226+ =/ n=[%named module=@ name=@ body=*] ;;([%named module=@ name=@ body=*] node)
6227+ ?. &((jibb-face-name module.n) (jibb-face-name name.n)) ~
6228+ ?. ?=([%fork *] body.n) ~
6229+ =/ proof=(unit irec-pattern) (rec-pattern body.n (@tas module.n) (@tas name.n))
6230+ ?~ proof ~
6231+ ?. has.u.proof ~
6232+ `[%recursive (@tas module.n) (@tas name.n) `(crip "{(trip name.n)}.{(trip module.n)}")]
56286233 %apply
56296234 ?. ?=([%apply @ *] node) ~
56306235 =/ name=term (@tas +<.node)
@@ -5790,21 +6395,54 @@
57906395 ?:(=(`origin origin.typ.template) `name.i.molds $(molds t.molds))
57916396 $(molds t.molds)
57926397::
5793−:: A public non-generic alias names exactly its origin and arguments.
5794−:: Reusing only an origin could print a different generic instantiation.
6398+:: A prelude union alias is a display name, not a new union identity. An
6399+:: identity-generic alias can carry the origin's arguments only when the
6400+:: origin, arity and ordered parameters match. Swapped, repeated, fixed
6401+:: or phantom parameters cannot be printed that way and remain unsupported
6402+:: when their only available name is private. A nongeneric alias of a
6403+:: generic instantiation cannot be printed with the origin's arguments.
6404+++ identity-union-parameters
6405+ |= [vars=(list @ud) args=(list itype)]
6406+ ^- ?
6407+ ?~ vars ?=(~ args)
6408+ ?~ args |
6409+ ?. =([%var i.vars] i.args) |
6410+ $(vars t.vars, args t.args)
57956411++ prelude-union-alias
57966412 |= [origin=[at=path name=term] args=(list itype) molds=imold-types]
57976413 ^- (unit term)
5798− ?^ args ~
57996414 ?~ molds ~
58006415 =/ template=ischeme template.i.molds
5801− ?: &(?=(~ vars.template) ?=(%union -.typ.template))
5802− ?:(&(=(`origin origin.typ.template) =(args args.typ.template)) `name.i.molds $(molds t.molds))
6416+ ?. ?=(%union -.typ.template) $(molds t.molds)
6417+ ?. =(`origin origin.typ.template) $(molds t.molds)
6418+ ?~ vars.template
6419+ ?^ args $(molds t.molds)
6420+ ?:(=(args args.typ.template) `name.i.molds $(molds t.molds))
6421+ ?: &((identity-union-parameters vars.template args.typ.template) =((lent vars.template) (lent args)))
6422+ `name.i.molds
58036423 $(molds t.molds)
58046424::
58056425:: Names exported by the directly imported module are visible through its
58066426:: face; a matching prelude alias is also visible without a qualifier.
58076427::
6428+++ jrec-alias
6429+ |= [origin=path name=term molds=imold-types]
6430+ ^- (unit term)
6431+ ?~ molds ~
6432+ =/ template=ischeme template.i.molds
6433+ ?: &(?=(~ vars.template) ?=(%jrec -.typ.template) =(at.typ.template origin) =(name.typ.template name)) `name.i.molds
6434+ $(molds t.molds)
6435+::
6436+++ grec-visible-alias
6437+ |= [origin=path name=term proof=shape args=(list itype) molds=imold-types]
6438+ ^- (unit term)
6439+ ?~ molds ~
6440+ =/ template=ischeme template.i.molds
6441+ ?. ?=(%grec -.typ.template) $(molds t.molds)
6442+ ?. &(=(at.typ.template origin) =(name.typ.template name) =(proof.typ.template proof)) $(molds t.molds)
6443+ ?. &((identity-union-parameters vars.template args.typ.template) =((lent vars.template) (lent args))) $(molds t.molds)
6444+ `name.i.molds
6445+::
58086446++ itype-in-import
58096447 |= [t=itype iface=ifile face=term prelude=(unit ifile)]
58106448 ^- itype
@@ -5824,6 +6462,17 @@
58246462 `(crip "{(trip u.alias)}.{(trip face)}")
58256463 [%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)))]
58266464 %recursive [%recursive module.t name.t ~]
6465+ %grec
6466+ =/ public=(unit term) ?~(prelude ~ (grec-visible-alias at.t name.t proof.t args.t molds.u.prelude))
6467+ =/ alias=(unit term) ?~(public (grec-visible-alias at.t name.t proof.t args.t molds.iface) public)
6468+ =/ label=(unit @t) ?~(alias ~ ?~(public `(crip "{(trip u.alias)}.{(trip face)}") `u.alias))
6469+ t(label label, args (turn args.t |=(c=itype (itype-in-import c iface face prelude))))
6470+ %jrec
6471+ =/ public=(unit term) ?~(prelude ~ (jrec-alias at.t name.t molds.u.prelude))
6472+ ?^ public t(label `u.public)
6473+ =/ alias=(unit term) (jrec-alias at.t name.t molds.iface)
6474+ ?~ alias t(label ~)
6475+ t(label `(crip "{(trip u.alias)}.{(trip face)}"))
58276476 %collection [%collection name.t (turn args.t |=(c=itype (itype-in-import c iface face prelude)))]
58286477 %face [%face name.t $(t body.t)]
58296478 %fn [%fn $(t sample.t) $(t product.t)]
@@ -5897,9 +6546,66 @@
58976546 =/ rest=[params=iparams vars=(list @ud) next=@ud] $(names t.names, next +(next))
58986547 [[[i.names [%var next]] params.rest] [next vars.rest] next.rest]
58996548::
6549+:: Recognize a unique top-level source mold with exactly a null case and a
6550+:: faced atom-headed cell whose faced tail names that same mold. Its Jibb
6551+:: path and name provide nominal identity. Other recursive shapes fail closed;
6552+:: construction and matching expose the proven shape one layer at a time.
6553+++ simple-source-recursive
6554+ |= [name=term sh=shape state=istate]
6555+ ^- (unit itype)
6556+ ?. (lien top-molds.state |=(n=term =(n name))) ~
6557+ =/ original=(unit shape) (find-simple-mold name molds.state)
6558+ ?~ original ~
6559+ ?. =(u.original sh) ~
6560+ ?. ?=(%union -.sh) ~
6561+ =/ cs=(list shape) cases.sh
6562+ ?~ cs ~
6563+ ?~ t.cs ~
6564+ ?^ t.t.cs ~
6565+ ?. ?=(%const -.i.cs) ~
6566+ ?. =(%null form.lit.i.cs) ~
6567+ ?. ?=(%cell -.i.t.cs) ~
6568+ =/ fs=(list field) fields.i.t.cs
6569+ ?~ fs ~
6570+ ?~ t.fs ~
6571+ ?^ t.t.fs ~
6572+ ?. ?=(%face -.i.fs) ~
6573+ ?. ?=(%aura -.shape.i.fs) ~
6574+ ?. !=(0 aura.shape.i.fs) ~
6575+ ?. ?=(%face -.i.t.fs) ~
6576+ ?. !=(name.i.fs name.i.t.fs) ~
6577+ =/ tail=shape shape.i.t.fs
6578+ ?. ?=(%ref -.tail) ~
6579+ ?. =(names.tail ~[name]) ~
6580+ `[%jrec at.state name `name name.i.fs aura.shape.i.fs name.i.t.fs]
6581+::
6582+++ simple-source-generic-recursive
6583+ |= [name=term sh=shape args=(list itype) state=istate]
6584+ ^- (unit itype)
6585+ ?. ?=(%generic -.sh) ~
6586+ ?. ?=([@ ~] vars.sh) ~
6587+ ?. ?=([* ~] args) ~
6588+ ?~ grec-index.state ~
6589+ ?. =(at.u.grec-index.state at.state) ~
6590+ ?~ prelude.state ~
6591+ ?. =(prelude.u.grec-index.state u.prelude.state) ~
6592+ =/ proof=(unit shape) (~(get by shapes.u.grec-index.state) name)
6593+ ?~ proof ~
6594+ ?. =(u.proof sh) ~
6595+ `[%grec at.state name `name sh args]
6596+::
6597+
59006598++ infer-mold-template
59016599 |= [sh=shape state=istate]
59026600 ^- (unit [template=ischeme state=istate])
6601+ =/ generic=(unit itype)
6602+ ?. ?=([@ ~] active.state) ~
6603+ (simple-source-generic-recursive i.active.state sh ~[[%var next.state]] state)
6604+ ?^ generic `[[u.generic ~[next.state]] state(next +(next.state))]
6605+ =/ direct=(unit itype)
6606+ ?. ?=([@ ~] active.state) ~
6607+ (simple-source-recursive i.active.state sh state)
6608+ ?^ direct `[[u.direct ~] state]
59036609 ?: ?=(%generic -.sh)
59046610 ?~ vars.sh ~
59056611 ?. (distinct-params vars.sh) ~
@@ -5907,17 +6613,19 @@
59076613 =/ out=(unit [typ=itype state=istate])
59086614 (infer-simple-shape body.sh state(next next.fresh, params params.fresh, in-mold &))
59096615 ?~ out ~
6616+ ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
59106617 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.sh) ?=(~ origin.typ.u.out)) ~
59116618 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.sh))
59126619 typ.u.out(args (turn vars.fresh |=(n=@ud `itype`[%var n])))
59136620 =/ used=(list @ud) (itype-vars typ.u.out)
59146621 ?. (levy used |=(n=@ud (lien vars.fresh |=(p=@ud =(p n))))) ~
5915− `[[typ.u.out vars.fresh] state.u.out(params params.state, in-mold in-mold.state)]
6622+ `[[typ.u.out vars.fresh] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
59166623 =/ out=(unit [typ=itype state=istate])
59176624 (infer-simple-shape sh state(params ~, in-mold &))
59186625 ?~ out ~
6626+ ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
59196627 ?: ?=(^ (itype-vars typ.u.out)) ~
5920− `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state)]
6628+ `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
59216629::
59226630:: A direct imported reference may carry definite reader evidence. Only
59236631:: uniquely supplied, declared inputs are used; unsupported data stay generic.
@@ -5951,7 +6659,7 @@
59516659 ?~ found ~
59526660 ?^ t.found ~
59536661 result.i.found
5954− ?. ?=([%invalid ?(%aura %core) @] raw) ~
6662+ ?. ?=([%invalid ?(%aura %core %overlap) @] raw) ~
59556663 `["{(trip +>.raw)}" ~[[at.sh "invalid imported mold"]]]
59566664::
59576665:: Replay only the shape branches whose evaluation order we can prove.
@@ -6020,13 +6728,15 @@
60206728 |= [sh=shape state=istate]
60216729 ^- (unit [typ=itype state=istate])
60226730 ?- -.sh
6731+ %hole `[[%var next.state] state(next +(next.state), holes [[next.state at.sh] holes.state])]
60236732 %aura
60246733 ?: =(0 aura.sh) `[[%any-atom ~] state]
60256734 `[[%atom aura.sh] state]
60266735 %flag `[[%flag ~] state]
60276736 %noun `[[%noun ~] state]
60286737 %const
6029− ?. |(=(%term form.lit.sh) =(%null form.lit.sh)) ~
6738+ ?. |(=(%term form.lit.sh) =(%null form.lit.sh) =(%loobean form.lit.sh)) ~
6739+ ?: &(=(%loobean form.lit.sh) !|(=(0 val.lit.sh) =(1 val.lit.sh))) ~
60306740 `[[%const lit.sh] state]
60316741 %union
60326742 =/ pairs=(list upair) (union-pairs cases.sh molds.state)
@@ -6070,10 +6780,13 @@
60706780 ?~ prelude-entry ~
60716781 ?^ vars.u.prelude-entry ~
60726782 `[typ.u.prelude-entry state]
6783+ =/ direct=(unit itype) (simple-source-recursive n u.found state)
6784+ ?^ direct `[u.direct state]
60736785 =/ out=(unit [typ=itype state=istate])
60746786 $(sh u.found, state state(active [n active.state], in-mold &, params ~))
60756787 ?~ out ~
6076− `[(label-direct-union typ.u.out u.found n state) state.u.out(active active.state, in-mold in-mold.state, params params.state)]
6788+ ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
6789+ `[(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)]
60776790 %apply
60786791 ?~ ref.sh ~
60796792 =/ args=(unit [types=(list itype) state=istate]) (infer-shape-args args.sh state)
@@ -6101,17 +6814,20 @@
61016814 ?~ applied ~
61026815 `[u.applied state.u.args]
61036816 ?. ?=(%generic -.u.found) ~
6817+ =/ grec=(unit itype) (simple-source-generic-recursive n u.found types.u.args state.u.args)
6818+ ?^ grec `[u.grec state.u.args]
61046819 ?. (distinct-params vars.u.found) ~
61056820 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
61066821 ?~ params ~
61076822 =/ out=(unit [typ=itype state=istate])
61086823 $(sh body.u.found, state state.u.args(active [n active.state.u.args], in-mold &, params u.params))
61096824 ?~ out ~
6825+ ?^ (unresolved-hole holes.state.u.out holes.state.u.args state.u.out) ~
61106826 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.u.found) ?=(~ origin.typ.u.out)) ~
61116827 ?: &(?=(%union -.typ.u.out) ?=(%union -.body.u.found) !(lien top-molds.state.u.args |=(x=term =(x n)))) ~
61126828 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.u.found))
61136829 (label-direct-union typ.u.out(args types.u.args) u.found n state.u.args)
6114− `[typ.u.out state.u.out(active active.state.u.args, in-mold in-mold.state.u.args, params params.state.u.args)]
6830+ `[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)]
61156831 %tvar
61166832 =/ param=(unit itype) (iparam-lookup name.sh params.state)
61176833 ?^ param `[u.param state]
@@ -6151,12 +6867,12 @@
61516867 ^- isample-result
61526868 ?- -.s
61536869 %bind
6154− ?: |(?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
6870+ ?: |(=(name.s %proj) ?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
61556871 [%| "sample shadows a name"]
61566872 =/ t=itype [%var next.state]
61576873 [%& t [[name.s [t ~]] env] state(next +(next.state), binders [next.state binders.state])]
61586874 %face
6159− ?: |(?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
6875+ ?: |(=(name.s %proj) ?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
61606876 [%| "sample shadows a name"]
61616877 =/ t=(unit [typ=itype state=istate]) (infer-simple-shape shape.s state)
61626878 ?~ t [%| "sample mold is not supported by partial inference"]
@@ -6224,6 +6940,7 @@
62246940 |-
62256941 ?~ ds &
62266942 ?: ?=(%mold -.i.ds) $(ds t.ds)
6943+ ?: =(name.i.ds %proj) |
62276944 ?. (unique-value-name name.i.ds names) |
62286945 ?: ?=(^ (ienv-lookup name.i.ds env)) |
62296946 ?: (lien globals.state |=(n=term =(n name.i.ds))) |
@@ -6247,6 +6964,7 @@
62476964 |-
62486965 ?~ locals &
62496966 =/ n=term name.i.locals
6967+ ?: =(n %proj) |
62506968 ?. (unique-value-name n names) |
62516969 ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) |
62526970 ?: (lien marks.state |=(m=term =(n m))) |
@@ -6426,6 +7144,10 @@
64267144 =/ retried=? ?=(%| -.inferred)
64277145 =? inferred retried (infer-recursive-gate d env local-state)
64287146 ?: ?=(%| -.inferred) $(ds t.ds, remaining [d remaining])
7147+ =. state.p.inferred (promote-restricted-numbers state.p.inferred env)
7148+ =. 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)))
7149+ =/ hole=(unit idiag) (unresolved-hole holes.state.p.inferred holes.state state.p.inferred)
7150+ ?^ hole [%| u.hole]
64297151 =/ merged=(unit [first=icap second=icap])
64307152 (merged-capitals caps.state.p.inferred sub.state.p.inferred)
64317153 ?^ merged
@@ -6441,7 +7163,7 @@
64417163 (weld (free-env-vars env sub.state.p.inferred) (free-cap-vars caps.state sub.state.p.inferred))
64427164 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
64437165 =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
6444− $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred(caps caps.state), progressed &)
7166+ $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred(caps caps.state, holes holes.state), progressed &)
64457167::
64467168:: Try complete cyclic local groups after individual definitions stall.
64477169:: Components with non-gates or unresolved constraints stay unavailable.
@@ -6562,6 +7284,7 @@
65627284 ?: ?=(%unknown -.fit)
65637285 ?: &(?=(%collection -.expected) =(%list name.expected))
65647286 [%| ["branch list constraint is not supported by partial inference" ~]]
7287+ ?: ?=(%flag -.expected) [%| ["branch loobean constraint is not supported by partial inference" ~]]
65657288 [%| ["branch union constraint is not supported by partial inference" ~]]
65667289 ?: ?=(%bad -.fit)
65677290 =/ missing=(unit idiag) (missing-union-tag e expected sub.state.p.value context)
@@ -6570,6 +7293,8 @@
65707293 ?^ nested [%| u.nested]
65717294 ?: &(?=(%collection -.expected) =(%list name.expected))
65727295 [%| ["branch arm does not fit its expected list" ~[[context "expected list"] [(span-of e) "branch arm"]]]]
7296+ ?: ?=(%flag -.expected)
7297+ [%| ["branch arm does not fit its expected loobean" ~[[context "expected loobean"] [(span-of e) "branch arm"]]]]
65737298 [%| ["branch arm does not fit its expected union" ~[[context "expected union"] [(span-of e) "branch arm"]]]]
65747299 [%& expected state.p.value(sub sub.fit, next next.fit)]
65757300::
@@ -6757,7 +7482,7 @@
67577482 [%| ["list branch pattern is not supported by partial inference" ~]]
67587483 =/ binder=(unit [head=term tail=term]) ?:(first-empty second-name first-name)
67597484 ?~ binder [%| ["list branch pattern is not supported by partial inference" ~]]
6760− ?: |(=(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)))))
7485+ ?: |(=(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)))))
67617486 [%| ["pattern binder shadows a name" ~]]
67627487 =/ extended=ienv [[head.u.binder [i.args.typ ~]] [tail.u.binder [typ ~]] env]
67637488 =/ left=iresult
@@ -6794,7 +7519,7 @@
67947519 [%| ["unit branch pattern is not supported by partial inference" ~]]
67957520 =/ binder=(unit term) ?:(first-empty second-name first-name)
67967521 ?~ binder [%| ["unit branch pattern is not supported by partial inference" ~]]
6797− ?: |(?=(^ (ienv-lookup u.binder env)) (lien globals.state |=(n=term =(n u.binder))))
7522+ ?: |(=(u.binder %proj) ?=(^ (ienv-lookup u.binder env)) (lien globals.state |=(n=term =(n u.binder))))
67987523 [%| ["pattern binder shadows a name" ~]]
67997524 =/ payload=(unit itype) (unit-union-payload typ)
68007525 ?~ payload [%| ["unit branch subject is not supported by partial inference" ~]]
@@ -6826,12 +7551,14 @@
68267551 =/ t=itype (itype-normalize typ.p.item sub.state.p.item)
68277552 ?: |(?=(%atom -.t) ?=(%any-atom -.t))
68287553 $(ps t.ps, state state.p.item)
6829− ?: &(?=(%nvar -.t) ?=(%lit -.p.i.ps) =(%number form.lit.p.i.ps))
7554+ ?: &(|(?=(%nvar -.t) ?=(%rnvar -.t)) ?=(%lit -.p.i.ps) =(%number form.lit.p.i.ps))
68307555 $(ps t.ps, state state.p.item)
68317556 ?: &(?=(%collection -.t) =(%list name.t) =(~[[%atom 'tD']] args.t))
68327557 $(ps t.ps, state state.p.item)
68337558 ?: &(?=(%avar -.t) (atom-var-from-cap id.t caps.state.p.item sub.state.p.item))
68347559 [%| ["a generic atom in interpolation needs an aura" ~[[(span-of p.i.ps) "atom with a generic aura"]]]]
7560+ ?: &(?=(%rvar -.t) (atom-var-from-cap id.t caps.state.p.item sub.state.p.item))
7561+ [%| ["a generic atom in interpolation needs an aura" ~[[(span-of p.i.ps) "atom with a generic aura"]]]]
68357562 ?: ?=(%cell -.t)
68367563 [%| ["a cell in interpolation needs a printer" ~[[(span-of p.i.ps) "cell without a printer"]]]]
68377564 [%| ["interpolation type needs unsupported inference" ~]]
@@ -6894,7 +7621,7 @@
68947621 ^- (unit ienv)
68957622 =. t ?:(?=(%face -.t) body.t t)
68967623 ?: ?=(%bind -.p)
6897− ?: |(?=(^ (ienv-lookup name.p env)) (lien globals |=(n=term =(n name.p)))) ~
7624+ ?: |(=(name.p %proj) ?=(^ (ienv-lookup name.p env)) (lien globals |=(n=term =(n name.p)))) ~
68987625 `[[name.p [t ~]] env]
68997626 ?: ?=(%cell -.p) (union-pattern-bind-items items.p t env globals)
69007627 `env
@@ -6942,10 +7669,9 @@
69427669 $(xs t.xs, out (weld out rows), origin +(origin))
69437670::
69447671++ infer-known-union-whole
6945− |= [e=expr env=ienv state=istate]
7672+ |= [e=expr env=ienv subject=iresult]
69467673 ^- (unit iresult)
69477674 ?> ?=(%branch -.e)
6948− =/ subject=iresult (infer-fragment subject.e env state)
69497675 ?: ?=(%| -.subject) `subject
69507676 =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
69517677 ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
@@ -6980,10 +7706,9 @@
69807706 $(arms t.arms, remaining (skim remaining |=(c=itype !=(%full (union-pattern pat.a c)))), st state.p.body, answer `result)
69817707::
69827708++ infer-known-union-context-whole
6983− |= [e=expr expected=itype env=ienv state=istate context=span]
7709+ |= [e=expr expected=itype env=ienv subject=iresult context=span]
69847710 ^- (unit iresult)
69857711 ?> ?=(%branch -.e)
6986− =/ subject=iresult (infer-fragment subject.e env state)
69877712 ?: ?=(%| -.subject) `subject
69887713 =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
69897714 ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
@@ -7025,10 +7750,9 @@
70257750 $(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)
70267751::
70277752++ infer-known-union-finite
7028− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
7753+ |= [e=expr env=ienv subject=iresult expected=(unit [typ=itype context=span])]
70297754 ^- iresult
70307755 ?> ?=(%branch -.e)
7031− =/ subject=iresult (infer-fragment subject.e env state)
70327756 ?: ?=(%| -.subject) subject
70337757 =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
70347758 ?. ?=(%union -.typ) [%| ["branch is not supported by partial inference" ~]]
@@ -7079,29 +7803,201 @@
70797803 ?: mismatch [%| ["union branch result matching needs unsupported inference" ~]]
70807804 $(arms t.arms, remaining (skim remaining |=(c=ifinite !=(%full (union-pattern pat.a part.c)))), st state.p.body, answer `result)
70817805::
7082−++ infer-known-union-branch
7806+:: Prove a one-arm record pattern covers a known, non-union subject.
7807+:: Variable or partial matches stay unsupported; binding uses the same
7808+:: scope and original payload types as the existing union matcher.
7809+++ single-structured-pattern
7810+ |= e=expr
7811+ ^- ?
7812+ ?. ?=(%branch -.e) |
7813+ ?~ arms.e |
7814+ ?^ t.arms.e |
7815+ =/ p=pattern pat.i.arms.e
7816+ ?. ?=(%cell -.p) |
7817+ !(levy items.p |=(x=pattern ?=(%bind -.x)))
7818+::
7819+++ infer-single-case-branch
7820+ |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
7821+ ^- iresult
7822+ ?> (single-structured-pattern e)
7823+ ?> ?=(%branch -.e)
7824+ ?> ?=(^ arms.e)
7825+ =/ a=arm i.arms.e
7826+ =/ subject=iresult (infer-fragment subject.e env state)
7827+ ?: ?=(%| -.subject) subject
7828+ =/ st=istate state.p.subject
7829+ =/ typ=itype (itype-normalize typ.p.subject sub.st)
7830+ ?: ?=(%union -.typ) [%| ["single-case pattern needs unsupported inference" ~]]
7831+ ?. =(%full (union-pattern pat.a typ))
7832+ [%| ["single-case pattern needs unsupported inference" ~]]
7833+ =/ bound=(unit ienv) (union-pattern-bind pat.a typ env globals.st)
7834+ ?~ bound [%| ["pattern binder shadows a name" ~]]
7835+ ?~ expected (infer-fragment val.a u.bound st)
7836+ =/ body=iresult (infer-call-context-arg val.a typ.u.expected u.bound st context.u.expected)
7837+ ?: ?=(%| -.body) body
7838+ =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
7839+ ?: ?=(%unknown -.fit) [%| ["single-case branch result constraint is not supported by partial inference" ~]]
7840+ ?: ?=(%bad -.fit)
7841+ =/ missing=(unit idiag) (missing-union-tag val.a typ.u.expected sub.state.p.body context.u.expected)
7842+ ?^ missing [%| u.missing]
7843+ =/ 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)
7844+ ?^ nested [%| u.nested]
7845+ [%| ["single-case branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.a) "branch arm"]]]]
7846+ ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
7847+ [%| ["single-case branch result needs context in partial inference" ~]]
7848+ [%& typ.u.expected state.p.body(sub sub.fit, next next.fit)]
7849+::
7850+:: This view is used only by pattern analysis, never exported or bound as
7851+:: the subject. Only null plus a two-binder/wildcard cell is supported; its
7852+:: tail keeps the original recursive type. Other patterns fail closed.
7853+++ jrec-match-view
7854+ |= [e=expr subject=iresult]
7855+ ^- iresult
7856+ ?: ?=(%| -.subject) subject
7857+ ?. ?=(%branch -.e) subject
7858+ =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7859+ ?. ?=(%jrec -.typ) subject
7860+ ?~ arms.e subject
7861+ ?~ t.arms.e subject
7862+ ?^ t.t.arms.e subject
7863+ =/ x=pattern pat.i.arms.e
7864+ =/ y=pattern pat.i.t.arms.e
7865+ =/ empty=? &(?=(%lit -.x) =(%null form.lit.x))
7866+ =/ full=pattern ?:(empty y x)
7867+ ?. |(empty &(?=(%lit -.y) =(%null form.lit.y))) subject
7868+ ?. ?=(%cell -.full) subject
7869+ ?~ items.full subject
7870+ ?~ t.items.full subject
7871+ ?^ t.t.items.full subject
7872+ ?. |(?=(%bind -.i.items.full) ?=(%any -.i.items.full)) subject
7873+ ?. |(?=(%bind -.i.t.items.full) ?=(%any -.i.t.items.full)) subject
7874+ ?: =(0 jrec-fuel.state.p.subject)
7875+ [%| ["recursive mold unfolding needs unsupported inference" ~]]
7876+ =/ nil=itype [%const [%null %n 0 '~']]
7877+ =/ cell=itype [%cell [%face head.typ [%atom aura.typ]] [%face tail.typ typ]]
7878+ [%& [%union ~[nil cell] ~ ~ ~] state.p.subject(jrec-fuel (dec jrec-fuel.state.p.subject))]
7879+::
7880+:: Experimental bounded, source-proven tree match. Only two explicit
7881+:: flat tag/binder patterns may consume the view: a whole-case binder
7882+:: must not leak the temporary structural representation.
7883+++ grec-simple-pattern
7884+ |= [pat=pattern view=itype]
7885+ ^- ?
7886+ ?. ?=(%cell -.pat) |
7887+ ?~ items.pat |
7888+ =/ first=pattern i.items.pat
7889+ ?. ?=(%lit -.first) |
7890+ ?. =(%term form.lit.first) |
7891+ =/ chosen=(unit itype) (contextual-tagged-case view val.lit.first ~)
7892+ ?~ chosen |
7893+ ?> ?=(%cell -.u.chosen)
7894+ =/ rest=(list pattern) t.items.pat
7895+ ?. (levy rest |=(p=pattern |(?=(%bind -.p) ?=(%any -.p)))) |
7896+ ?: ?=(%cell -.tal.u.chosen) ?=([* [* ~]] rest)
7897+ ?=([* ~] rest)
7898+++ grec-match-view
7899+ |= [e=expr subject=iresult]
7900+ ^- iresult
7901+ ?: ?=(%| -.subject) subject
7902+ ?. ?=(%branch -.e) subject
7903+ ?. (grec-direct-context typ.p.subject sub.state.p.subject) subject
7904+ =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7905+ ?. ?=(%grec -.typ) subject
7906+ ?~ arms.e subject
7907+ ?. |(?=(~ t.arms.e) ?=([* ~] t.arms.e)) subject
7908+ =/ view=(unit [view=itype left=@ud]) (grec-unfold-view typ jrec-fuel.state.p.subject)
7909+ ?~ view [%| ["recursive mold unfolding needs unsupported inference" ~]]
7910+ ?. (grec-simple-pattern pat.i.arms.e view.u.view) subject
7911+ =/ rest-ok=? ?~(t.arms.e & (grec-simple-pattern pat.i.t.arms.e view.u.view))
7912+ ?. rest-ok subject
7913+ [%& view.u.view state.p.subject(jrec-fuel left.u.view)]
7914+::
7915+:: A single-arm diagnostic only probes a direct, source-typed in-scope wing;
7916+:: other subjects retain the prior single-pattern inference path.
7917+++ grec-single-wing-subject
70837918 |= [e=expr env=ienv state=istate]
7919+ ^- (unit iresult)
7920+ ?. ?=(%wing -.e) ~
7921+ ?. ?=([@ ~] names.e) ~
7922+ =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
7923+ ?~ scheme ~
7924+ ?. (grec-direct-context typ.u.scheme sub.state) ~
7925+ `(infer-fragment e env state)
7926+::
7927+++ infer-known-union-branch-subject
7928+ |= [e=expr env=ienv subject=iresult]
70847929 ^- iresult
7085− =/ whole=(unit iresult) (infer-known-union-whole e env state)
7086− ?~ whole (infer-known-union-finite e env state ~)
7930+ =. subject (grec-match-view e subject)
7931+ =. subject (jrec-match-view e subject)
7932+ =/ whole=(unit iresult) (infer-known-union-whole e env subject)
7933+ ?~ whole (infer-known-union-finite e env subject ~)
70877934 u.whole
70887935::
7089−++ infer-known-union-context
7090− |= [e=expr expected=itype env=ienv state=istate context=span]
7936+++ infer-known-union-branch
7937+ |= [e=expr env=ienv state=istate]
7938+ ^- iresult
7939+ ?> ?=(%branch -.e)
7940+ (infer-known-union-branch-subject e env (infer-fragment subject.e env state))
7941+::
7942+++ infer-known-union-context-subject
7943+ |= [e=expr expected=itype env=ienv subject=iresult context=span]
70917944 ^- iresult
7092− =/ whole=(unit iresult) (infer-known-union-context-whole e expected env state context)
7093− ?~ whole (infer-known-union-finite e env state `[expected context])
7945+ =. subject (grec-match-view e subject)
7946+ =. subject (jrec-match-view e subject)
7947+ =/ whole=(unit iresult) (infer-known-union-context-whole e expected env subject context)
7948+ ?~ whole (infer-known-union-finite e env subject `[expected context])
70947949 u.whole
70957950::
7951+:: Limit speculative subject inference to wings and shallow calls;
7952+:: grouping is peeled linearly and cannot introduce a nested branch.
7953+++ simple-union-subject-arg
7954+ |= e=expr
7955+ ^- ?
7956+ ?- -.e
7957+ %wing &
7958+ %lit &
7959+ %str !(lien pieces.e |=(p=piece ?=(%expr -.p)))
7960+ * |
7961+ ==
7962+::
7963+++ safe-union-subject
7964+ |= e=expr
7965+ ^- ?
7966+ ?: ?=(%group -.e) $(e inner.e)
7967+ ?: ?=(%wing -.e) &
7968+ ?. ?=(%call -.e) |
7969+ ?. ?=(%wing -.head.e) |
7970+ (levy args.e simple-union-subject-arg)
7971+::
7972+++ duplicate-loobean-arms
7973+ |= e=expr
7974+ ^- ?
7975+ ?. ?=(%branch -.e) |
7976+ ?~ arms.e |
7977+ ?~ t.arms.e |
7978+ ?^ t.t.arms.e |
7979+ =/ x=pattern pat.i.arms.e
7980+ =/ y=pattern pat.i.t.arms.e
7981+ ?. &(?=(%lit -.x) ?=(%lit -.y)) |
7982+ ?. &(=(%loobean form.lit.x) =(%loobean form.lit.y)) |
7983+ =(val.lit.x val.lit.y)
7984+::
7985+++ union-subject-call
7986+ |= e=expr
7987+ ^- ?
7988+ ?: ?=(%group -.e) $(e inner.e)
7989+ ?=(%call -.e)
7990+::
70967991++ known-union-subject
70977992 |= [e=expr env=ienv state=istate]
7098− ^- (unit itype)
7099− ?. ?=(%wing -.e) ~
7993+ ^- (unit iresult)
7994+ ?. (safe-union-subject e) ~
71007995 =/ subject=iresult (infer-fragment e env state)
7101− ?: ?=(%| -.subject) ~
7996+ ?: ?=(%| -.subject) ?:((union-subject-call e) `subject ~)
71027997 =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7103− ?. ?=(%union -.typ) ~
7104− `typ
7998+ ?. |(?=(%union -.typ) ?=(%jrec -.typ) &(?=(%grec -.typ) (grec-direct-context typ.p.subject sub.state.p.subject))) ~
7999+ `subject
8000+::
71058001::
71068002:: Infer changes only against a fully known record spine. Retain the
71078003:: target type; unknown spines and repeated edits remain unsupported.
@@ -7208,7 +8104,7 @@
72088104 |= [e=expr actual=itype expected=itype sub=isub next=@ud context=span]
72098105 ^- (unit idiag)
72108106 =/ original=[left=itype right=itype] [actual expected]
7211− ?: |(?=(%var -.left.original) ?=(%avar -.left.original) ?=(%nvar -.left.original) ?=(%var -.right.original) ?=(%avar -.right.original) ?=(%nvar -.right.original)) ~
8107+ ?: |(?=(%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))) ~
72128108 =/ fit=ifit (itype-fit actual expected sub next)
72138109 ?. ?=(%bad -.fit) ~
72148110 =. actual (itype-walk actual sub)
@@ -7229,7 +8125,7 @@
72298125 ?~ items ~
72308126 ?~ t.items (nested-missing-tag val.i.items actual expected sub next context)
72318127 =/ original=[left=itype right=itype] [actual expected]
7232− ?: |(?=(%var -.left.original) ?=(%avar -.left.original) ?=(%nvar -.left.original) ?=(%var -.right.original) ?=(%avar -.right.original) ?=(%nvar -.right.original)) ~
8128+ ?: |(?=(%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))) ~
72338129 =. actual (itype-walk actual sub)
72348130 =. expected (itype-walk expected sub)
72358131 ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
@@ -7249,6 +8145,15 @@
72498145 =/ head=expr [%lit at.e [%term %tas tag.e (crip ['%' (trip tag.e)])]]
72508146 [%tuple at.e ~[[at.e ~ head] [(span-of val.e) ~ val.e]]]
72518147::
8148+:: A segment costs one shared step; dynamic segments are not handled yet.
8149+++ qath-static-fuel
8150+ |= [segs=(list qseg) fuel=@ud]
8151+ ^- (unit @ud)
8152+ ?~ segs `fuel
8153+ ?: =(0 fuel) ~
8154+ ?. ?=(%knot -.i.segs) ~
8155+ $(segs t.segs, fuel (dec fuel))
8156+::
72528157++ infer-fragment
72538158 |= [e=expr env=ienv state=istate]
72548159 ^- iresult
@@ -7291,6 +8196,21 @@
72918196 ?: ?=(%| -.result) result
72928197 [%& [%collection %list ~[element]] state.p.result]
72938198 %str (infer-string-pieces pieces.e env state)
8199+ %qath
8200+ ?~ prelude.state [%| ["application path needs the standard prelude in partial inference" ~]]
8201+ ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
8202+ [%| ["application path needs the standard prelude in partial inference" ~]]
8203+ =/ standard=(unit ischeme) (find-jibb-mold %qath u.prelude.state)
8204+ ?~ standard [%| ["application path needs the standard prelude in partial inference" ~]]
8205+ ?. ?=(~ vars.u.standard) [%| ["application path mold needs unsupported inference" ~]]
8206+ =/ typ=itype typ.u.standard
8207+ ?. ?=(%jrec -.typ) [%| ["application path mold needs unsupported inference" ~]]
8208+ ?. &(=(at.typ /lib/jibb/internal/jibb) =(%qath name.typ) =(%i head.typ) =(%ta aura.typ) =(%t tail.typ))
8209+ [%| ["application path mold needs unsupported inference" ~]]
8210+ ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
8211+ =/ remain=(unit @ud) (qath-static-fuel segs.e (dec jrec-fuel.state))
8212+ ?~ remain [%| ["application path segments need unsupported inference" ~]]
8213+ [%& typ state(jrec-fuel u.remain)]
72948214 %wing
72958215 ?~ names.e [%| ["empty wing" ~]]
72968216 ?^ t.names.e
@@ -7333,6 +8253,9 @@
73338253 [%| ["local molds shadow a name" ~]]
73348254 =/ local-state=istate
73358255 state(globals (weld local-names globals.state), molds (weld local-molds molds.state))
8256+ =/ mold-hole=(unit span) (simple-local-mold-hole defs.e)
8257+ ?^ mold-hole
8258+ [%| ["type hole needs a determined type" ~[[u.mold-hole "unresolved type hole"]]]]
73368259 ?. (local-molds-supported local-molds local-state)
73378260 [%| ["local molds need unsupported inference" ~]]
73388261 =/ values=(list def) (local-value-defs defs.e)
@@ -7343,11 +8266,16 @@
73438266 [%& typ.p.result state.p.result(globals globals.state, molds molds.state)]
73448267 %branch
73458268 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
7346− ?~ t.arms.e (infer-cell-branch e env state)
8269+ ?~ t.arms.e
8270+ =/ single=(unit iresult) (grec-single-wing-subject subject.e env state)
8271+ ?^ single (infer-known-union-branch-subject e env u.single)
8272+ ?: (single-structured-pattern e) (infer-single-case-branch e env state ~)
8273+ (infer-cell-branch e env state ~)
73478274 ?^ t.t.arms.e (infer-known-union-branch e env state)
7348− =/ known=(unit itype) (known-union-subject subject.e env state)
7349− ?: &(?=(^ known) ?=(~ (unit-union-payload u.known)))
7350− (infer-known-union-branch e env state)
8275+ =/ known=(unit iresult) (known-union-subject subject.e env state)
8276+ ?: &(?=(^ known) ?=(%| -.u.known) !(duplicate-loobean-arms e)) u.known
8277+ ?: &(?=(^ known) ?=(%& -.u.known) ?=(~ (unit-union-payload (itype-normalize typ.p.u.known sub.state.p.u.known))))
8278+ (infer-known-union-branch-subject e env u.known)
73518279 =/ x=arm i.arms.e
73528280 =/ y=arm i.t.arms.e
73538281 ?: |((unit-empty-pattern pat.x) (unit-empty-pattern pat.y))
@@ -7356,7 +8284,7 @@
73568284 ?. ?=(%lit -.pat.y) (infer-known-union-branch e env state)
73578285 ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y))
73588286 (infer-known-union-branch e env state)
7359− ?^ known (infer-known-union-branch e env state)
8287+ ?: &(?=(^ known) ?=(%& -.u.known)) (infer-known-union-branch-subject e env u.known)
73608288 ?: =(val.lit.pat.x val.lit.pat.y)
73618289 [%| ["branch does not cover both loobeans" ~]]
73628290 =/ subject=iresult $(e subject.e)
@@ -7397,6 +8325,9 @@
73978325 =/ value=iresult
73988326 (infer-call-context-arg val.e typ.u.target env state.u.target at.shape.e)
73998327 ?: ?=(%| -.value) value
8328+ =/ shape=(unit [source=iwfields target=iwfields])
8329+ (width-shape typ.p.value typ.u.target sub.state.p.value)
8330+ ?^ shape [%| ["record width constraint needs unsupported inference" ~]]
74008331 =/ fit=ifit (itype-fit typ.p.value typ.u.target sub.state.p.value next.state.p.value)
74018332 ?: ?=(%unknown -.fit) [%| ["cast constraint is not supported by partial inference" ~]]
74028333 ?: ?=(%bad -.fit)
@@ -7428,45 +8359,9 @@
74288359 [%& [%fn typ.p.sam typ.p.body] state.p.body]
74298360 %call
74308361 ?~ args.e [%| ["call has no argument" ~]]
7431− =/ head=iresult $(e head.e)
7432− ?: ?=(%| -.head) head
7433− =/ head-type=itype (itype-walk typ.p.head sub.state.p.head)
7434− =/ arg=iresult
7435− ?^ t.args.e
7436− ?: ?=(%fn -.head-type)
7437− (infer-call-context-args args.e sample.head-type env state.p.head (span-of head.e))
7438− (infer-simple-items (turn args.e |=(a=expr [(span-of a) ~ a])) env state.p.head)
7439− ?: ?=(%fn -.head-type)
7440− (infer-call-context-arg i.args.e sample.head-type env state.p.head (span-of head.e))
7441− $(e i.args.e, state state.p.head)
7442− ?: ?=(%| -.arg) arg
7443− =/ st=istate state.p.arg
7444− =/ ht=itype (itype-walk typ.p.head sub.st)
7445− ?: ?=(%fn -.ht)
7446− =/ fit=ifit (itype-fit typ.p.arg sample.ht sub.st next.st)
7447− ?: ?=(%unknown -.fit) [%| ["call constraint is not supported by partial inference" ~]]
7448− ?: ?=(%bad -.fit)
7449− ?~ t.args.e
7450− =/ missing=(unit idiag) (missing-union-tag i.args.e sample.ht sub.st (span-of head.e))
7451− ?^ missing [%| u.missing]
7452− =/ nested=(unit idiag) (nested-missing-tag i.args.e typ.p.arg sample.ht sub.st next.st (span-of head.e))
7453− ?^ nested [%| u.nested]
7454− [%| ["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)]]]]
7455− =/ bad=(unit [at=span typ=itype])
7456− (call-error-site args.e typ.p.arg sample.ht sub.st next.st)
7457− =/ whole-args=span
7458− [beg:(span-of i.args.e) end:(span-of (rear args.e))]
7459− =/ arg-at=span ?~(bad whole-args at.u.bad)
7460− =/ arg-type=itype ?~(bad typ.p.arg typ.u.bad)
7461− [%| ["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)]]]]
7462− ?: &((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))
7463− [%| ["call result face propagation is not supported by partial inference" ~]]
7464− [%& product.ht st(sub sub.fit, next next.fit)]
7465− =/ result=itype [%var next.st]
7466− =/ uni=(unit isub) (itype-unify ht [%fn typ.p.arg result] sub.st)
7467− ?~ uni
7468− [%| ["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)]]]]
7469− [%& result st(next +(next.st), sub u.uni)]
8362+ ?: (explicit-proj-call e env state)
8363+ [%| ["proj needs an expected record type" ~]]
8364+ (infer-call-with-head e env state (infer-fragment head.e env state))
74708365 * [%| ["expression is not supported by partial inference" ~]]
74718366 ==
74728367::
@@ -7474,12 +8369,314 @@
74748369:: failed. If an intermediate fit is uncertain, retain the whole argument
74758370:: span rather than assigning blame to a particular argument.
74768371::
8372+:: Check a call using the head already inferred in this state. Keeping
8373+:: this shared avoids evaluating or instantiating a contextual head twice.
8374+++ width-has-projections
8375+ |= ps=(list iwprojection)
8376+ ^- ?
8377+ ?~ ps |
8378+ &
8379+::
8380++$ iwidth-elaboration [original=expr typ=itype sub=isub projections=(list iwprojection)]
8381+++ infer-width-elaboration
8382+ |= [e=expr env=ienv state=istate]
8383+ ^- (each iwidth-elaboration idiag)
8384+ =/ out=iresult (infer-fragment e env state)
8385+ ?: ?=(%| -.out) [%| p.out]
8386+ [%& [e typ.p.out sub.state.p.out (flop projections.state.p.out)]]
8387+::
8388+:: Source-bound gate-layout evidence, confined to checked root gate
8389+:: definitions and direct unshadowed prelude calls. The prepared prelude
8390+:: interface and its retained source are trusted as a matching artifact.
8391+:: Layouts identify sample binder faces; they do not change call arity or
8392+:: authorize stripping nested value faces. Unknown origins use ordinary fit.
8393+++ direct-written-gates
8394+ |= [ds=(list def) out=ivisited]
8395+ ^- ivisited
8396+ ?~ ds out
8397+ ?: ?=(%mold -.i.ds) $(ds t.ds)
8398+ ?. |(?=(%gate -.val.i.ds) ?=(%gate-wide -.val.i.ds)) $(ds t.ds)
8399+ $(ds t.ds, out (~(put by out) name.i.ds &))
8400+++ direct-may-use-prelude
8401+ |= [ds=(list def) root=ivisited heads=ivisited]
8402+ ^- ?
8403+ ?~ ds |
8404+ ?: ?=(%mold -.i.ds) $(ds t.ds)
8405+ =/ refs=(list term) (dependency-expr val.i.ds)
8406+ =/ has-root=? (lien refs |=(n=term ?=(^ (~(get by root) n))))
8407+ =/ has-head=? (lien refs |=(n=term ?=(^ (~(get by heads) n))))
8408+ ?: &(has-root has-head) &
8409+ $(ds t.ds)
8410+++ direct-unique-names
8411+ |= [names=(list term) seen=ivisited]
8412+ ^- ?
8413+ ?~ names &
8414+ ?: ?=(^ (~(get by seen) i.names)) |
8415+ $(names t.names, seen (~(put by seen) i.names &))
8416+++ direct-prelude-evidence
8417+ |= [ds=(list def) prelude=(unit ifile)]
8418+ ^- (unit igate-prelude-evidence)
8419+ ?~ prelude ~
8420+ ?~ source.u.prelude ~
8421+ =/ root=ivisited (direct-written-gates ds ~)
8422+ =/ names=(list term) (turn values.u.prelude |=(e=[name=term scheme=ischeme] name.e))
8423+ =/ heads=ivisited (graph-nameset names ~)
8424+ ?. (direct-may-use-prelude ds root heads) ~
8425+ =/ parsed (parse at.u.prelude u.source.u.prelude)
8426+ ?: ?=(%| -.parsed) ~
8427+ ?^ (duplicate-defs defs.p.parsed) ~
8428+ ?. (direct-unique-names (global-value-names defs.p.parsed) ~) ~
8429+ =/ gates=(map term def) (direct-checked-gates defs.p.parsed values.u.prelude)
8430+ `[u.prelude gates]
8431+++ direct-checked-gates
8432+ |= [ds=(list def) env=ienv]
8433+ ^- (map term def)
8434+ =/ names=(list term) (turn env |=(e=[name=term scheme=ischeme] name.e))
8435+ =/ known=ivisited (graph-nameset names ~)
8436+ =/ out=(map term def) ~
8437+ |-
8438+ ?~ ds out
8439+ =/ d=def i.ds
8440+ ?: ?=(%mold -.d) $(ds t.ds)
8441+ ?. ?=(^ (~(get by known) name.d)) $(ds t.ds)
8442+ ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) $(ds t.ds)
8443+ $(ds t.ds, out (~(put by out) name.d d))
8444+++ direct-find-gate
8445+ |= [n=term ds=(list def)]
8446+ ^- (unit def)
8447+ ?~ ds ~
8448+ ?: &(?=(%value -.i.ds) =(n name.i.ds)) `i.ds
8449+ $(ds t.ds)
8450+++ direct-gate-sample
8451+ |= d=def
8452+ ^- (unit sample)
8453+ ?. ?=(%value -.d) ~
8454+ ?- -.val.d
8455+ %gate `sample.val.d
8456+ %gate-wide `sample.val.d
8457+ * ~
8458+ ==
8459+++ direct-sample-name
8460+ |= sam=sample
8461+ ^- (unit term)
8462+ ?- -.sam
8463+ %bind `name.sam
8464+ %face `name.sam
8465+ %pun `name.sam
8466+ * ~
8467+ ==
8468+++ direct-field-name
8469+ |= f=field
8470+ ^- (unit term)
8471+ ?- -.f
8472+ %face `name.f
8473+ %pun `name.f
8474+ * ~
8475+ ==
8476+++ direct-slot-body
8477+ |= [typ=itype name=(unit term)]
8478+ ^- (unit itype)
8479+ ?~ name `typ
8480+ ?. ?=(%face -.typ) ~
8481+ ?. =(name.typ u.name) ~
8482+ `body.typ
8483+++ direct-invariant
8484+ |= [a=itype b=itype sub=isub next=@ud]
8485+ ^- ifit
8486+ ?: (itype-face-asym a b sub) [%unknown ~]
8487+ =/ forward=ifit (itype-fit a b sub next)
8488+ ?. ?=(%ok -.forward) [%unknown ~]
8489+ ?: (itype-face-asym a b sub.forward) [%unknown ~]
8490+ =/ reverse=ifit (itype-fit b a sub.forward next.forward)
8491+ ?. ?=(%ok -.reverse) [%unknown ~]
8492+ reverse
8493+++ direct-function-fit
8494+ |= [a=itype b=itype sam=sample sh=shape sub=isub next=@ud]
8495+ ^- ifit
8496+ ?. &(?=(%fn -.a) ?=(%fn -.b) ?=(%cell -.sam) ?=(%fn -.sh)) [%unknown ~]
8497+ ?. ?=(%cell -.sample.sh) [%unknown ~]
8498+ =/ as=(list sample) items.sam
8499+ =/ bs=(list field) fields.sample.sh
8500+ ?~ as [%unknown ~]
8501+ ?~ t.as [%unknown ~]
8502+ ?^ t.t.as [%unknown ~]
8503+ ?~ bs [%unknown ~]
8504+ ?~ t.bs [%unknown ~]
8505+ ?^ t.t.bs [%unknown ~]
8506+ ?. &(?=(%cell -.sample.a) ?=(%cell -.sample.b)) [%unknown ~]
8507+ =/ an=(unit term) (direct-sample-name i.as)
8508+ =/ bn=(unit term) (direct-field-name i.bs)
8509+ ?: &(?=(^ an) ?=(^ bn) !=(u.an u.bn)) [%unknown ~]
8510+ =/ x=(unit itype) (direct-slot-body hed.sample.a an)
8511+ =/ y=(unit itype) (direct-slot-body hed.sample.b bn)
8512+ ?~ x [%unknown ~]
8513+ ?~ y [%unknown ~]
8514+ =/ first=ifit (direct-invariant u.x u.y sub next)
8515+ ?. ?=(%ok -.first) [%unknown ~]
8516+ =. an (direct-sample-name i.t.as)
8517+ =. bn (direct-field-name i.t.bs)
8518+ ?: &(?=(^ an) ?=(^ bn) !=(u.an u.bn)) [%unknown ~]
8519+ =/ x2=(unit itype) (direct-slot-body tal.sample.a an)
8520+ =/ y2=(unit itype) (direct-slot-body tal.sample.b bn)
8521+ ?~ x2 [%unknown ~]
8522+ ?~ y2 [%unknown ~]
8523+ =/ second=ifit (direct-invariant u.x2 u.y2 sub.first next.first)
8524+ ?. ?=(%ok -.second) [%unknown ~]
8525+ (direct-invariant product.a product.b sub.second next.second)
8526+:: This is a tentative proof: its caller must require closed call samples
8527+:: and repeat every positional check under the stable final substitution.
8528+++ direct-positional-fit
8529+ |= [args=(list expr) slots=(list sample) actual=itype expected=itype env=ienv state=istate sub=isub next=@ud]
8530+ ^- ifit
8531+ ?~ args [%unknown ~]
8532+ ?~ slots [%unknown ~]
8533+ =/ last=? ?=(~ t.args)
8534+ ?: !=(last ?=(~ t.slots)) [%unknown ~]
8535+ =/ split=(unit [left=itype right=itype])
8536+ ?: last `[actual expected]
8537+ ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8538+ `[hed.actual hed.expected]
8539+ ?~ split [%unknown ~]
8540+ =/ x=itype left.u.split
8541+ =/ y=itype right.u.split
8542+ =/ expected-name=(unit term) (direct-sample-name i.slots)
8543+ =/ expected-body=(unit itype) (direct-slot-body y expected-name)
8544+ ?~ expected-body [%unknown ~]
8545+ =. y u.expected-body
8546+ =/ fit=ifit (itype-fit x y sub next)
8547+ =/ accepted=? &(?=(%ok -.fit) !(itype-positional-slot-face-asym x y sub.fit))
8548+ =/ result=(unit ifit)
8549+ ?: accepted `fit
8550+ ?. &(?=(%face -.i.slots) ?=(%fn -.shape.i.slots)) ~
8551+ ?. ?=(%wing -.i.args) ~
8552+ ?. ?=([@ ~] names.i.args) ~
8553+ ?. (unique-value-name i.names.i.args globals.state) ~
8554+ =/ source=(unit def) (~(get by gate-defs.state) i.names.i.args)
8555+ ?~ source ~
8556+ =/ sample=(unit sample) (direct-gate-sample u.source)
8557+ ?~ sample ~
8558+ =/ trial=ifit (direct-function-fit x y u.sample shape.i.slots sub next)
8559+ ?. ?=(%ok -.trial) ~
8560+ `trial
8561+ ?~ result [%unknown ~]
8562+ =. fit u.result
8563+ ?: last fit
8564+ ?. &(?=(%cell -.actual) ?=(%cell -.expected)) [%unknown ~]
8565+ ?. ?=(%ok -.fit) [%unknown ~]
8566+ $(args t.args, slots t.slots, actual tal.actual, expected tal.expected, sub sub.fit, next next.fit)
8567+++ direct-any-gate-arg
8568+ |= [args=(list expr) defs=(map term def)]
8569+ ^- ?
8570+ ?~ args |
8571+ =/ found=?
8572+ ?. ?=(%wing -.i.args) |
8573+ ?. ?=([@ ~] names.i.args) |
8574+ ?=(^ (~(get by defs) i.names.i.args))
8575+ ?: found &
8576+ $(args t.args)
8577+++ direct-gate-call-fit
8578+ |= [e=expr actual=itype expected=itype env=ienv state=istate]
8579+ ^- (unit ifit)
8580+ ?. ?=(%call -.e) ~
8581+ ?~ args.e ~
8582+ ?~ t.args.e ~
8583+ ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8584+ ?. ?=(%wing -.head.e) ~
8585+ ?. ?=([@ ~] names.head.e) ~
8586+ ?. ?=(~ (ienv-lookup i.names.head.e env)) ~
8587+ ?. (unique-value-name i.names.head.e globals.state) ~
8588+ ?. (direct-any-gate-arg args.e gate-defs.state) ~
8589+ ?~ prelude.state ~
8590+ ?~ source.u.prelude.state ~
8591+ ?~ head-evidence.state ~
8592+ ?. =(u.prelude.state iface.u.head-evidence.state) ~
8593+ ?. ?=(^ (ienv-lookup i.names.head.e values.u.prelude.state)) ~
8594+ =/ head=(unit def) (~(get by gates.u.head-evidence.state) i.names.head.e)
8595+ ?~ head ~
8596+ =/ sam=(unit sample) (direct-gate-sample u.head)
8597+ ?~ sam ~
8598+ ?. ?=(%cell -.u.sam) ~
8599+ =/ fit=ifit (direct-positional-fit args.e items.u.sam actual expected env state sub.state next.state)
8600+ ?. ?=(%ok -.fit) ~
8601+ :: Enclosing inference may add constraints after this call. Only a
8602+ :: closed call-sample proof can remain stable under those later bindings.
8603+ =/ actual-final=itype (itype-normalize actual sub.fit)
8604+ =/ expected-final=itype (itype-normalize expected sub.fit)
8605+ ?^ (itype-vars actual-final) ~
8606+ ?^ (itype-vars expected-final) ~
8607+ ?: |((itype-has-tag actual-final) (itype-has-tag expected-final)) ~
8608+ :: A later argument may resolve a variable used by an earlier slot.
8609+ :: Recheck every fit and face against the completed substitution; no
8610+ :: additional binding or fresh variable is permitted in the second pass.
8611+ =/ verified=ifit (direct-positional-fit args.e items.u.sam actual expected env state sub.fit next.fit)
8612+ ?. ?=(%ok -.verified) ~
8613+ ?. &(=(sub.fit sub.verified) =(next.fit next.verified)) ~
8614+ `fit
8615+::
8616+++ infer-call-with-head
8617+ |= [e=expr env=ienv state=istate head=iresult]
8618+ ^- iresult
8619+ ?> ?=(%call -.e)
8620+ ?~ args.e [%| ["call has no argument" ~]]
8621+ ?: ?=(%| -.head) head
8622+ =/ head-type=itype (itype-walk typ.p.head sub.state.p.head)
8623+ =/ arg=iresult
8624+ ?^ t.args.e
8625+ ?: ?=(%fn -.head-type)
8626+ (infer-call-context-args args.e sample.head-type env state.p.head (span-of head.e))
8627+ (infer-simple-items (turn args.e |=(a=expr [(span-of a) ~ a])) env state.p.head)
8628+ ?: ?=(%fn -.head-type)
8629+ (infer-call-context-arg i.args.e sample.head-type env state.p.head (span-of head.e))
8630+ (infer-fragment i.args.e env state.p.head)
8631+ ?: ?=(%| -.arg) arg
8632+ =/ st=istate state.p.arg
8633+ =/ ht=itype (itype-walk typ.p.head sub.st)
8634+ ?: ?=(%fn -.ht)
8635+ =/ shape=(unit [source=iwfields target=iwfields])
8636+ ?^ t.args.e ~
8637+ (width-shape typ.p.arg sample.ht sub.st)
8638+ ?^ shape [%| ["record width constraint needs unsupported inference" ~]]
8639+ =/ fit=ifit
8640+ ?^ t.args.e (itype-fit-inner typ.p.arg sample.ht sub.st next.st & |)
8641+ (itype-fit typ.p.arg sample.ht sub.st next.st)
8642+ =/ direct=(unit ifit)
8643+ ?: ?=(%ok -.fit) ~
8644+ (direct-gate-call-fit e typ.p.arg sample.ht env st)
8645+ =. fit ?~(direct fit u.direct)
8646+ ?: ?=(%unknown -.fit) [%| ["call constraint is not supported by partial inference" ~]]
8647+ ?: ?=(%bad -.fit)
8648+ ?~ t.args.e
8649+ =/ missing=(unit idiag) (missing-union-tag i.args.e sample.ht sub.st (span-of head.e))
8650+ ?^ missing [%| u.missing]
8651+ =/ nested=(unit idiag) (nested-missing-tag i.args.e typ.p.arg sample.ht sub.st next.st (span-of head.e))
8652+ ?^ nested [%| u.nested]
8653+ [%| ["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)]]]]
8654+ =/ bad=(unit [at=span typ=itype])
8655+ (call-error-site args.e typ.p.arg sample.ht sub.st next.st)
8656+ =/ whole-args=span
8657+ [beg:(span-of i.args.e) end:(span-of (rear args.e))]
8658+ =/ arg-at=span ?~(bad whole-args at.u.bad)
8659+ =/ arg-type=itype ?~(bad typ.p.arg typ.u.bad)
8660+ [%| ["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)]]]]
8661+ =/ face-asym=?
8662+ ?^ direct |
8663+ ?^ t.args.e (itype-positional-face-asym args.e typ.p.arg sample.ht sub.fit)
8664+ (itype-face-asym typ.p.arg sample.ht sub.fit)
8665+ ?: &((itype-has-face typ.p.arg sub.fit) face-asym (itype-output-may-be-cell product.ht sub.fit))
8666+ [%| ["call result face propagation is not supported by partial inference" ~]]
8667+ [%& product.ht st(sub sub.fit, next next.fit)]
8668+ =/ result=itype [%var next.st]
8669+ =/ uni=(unit isub) (itype-unify ht [%fn typ.p.arg result] sub.st)
8670+ ?~ uni
8671+ [%| ["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)]]]]
8672+ [%& result st(next +(next.st), sub u.uni)]
8673+::
74778674++ call-error-site
74788675 |= [args=(list expr) actual=itype expected=itype sub=isub next=@ud]
74798676 ^- (unit [at=span typ=itype])
74808677 ?~ args ~
74818678 =/ original=[left=itype right=itype] [actual expected]
7482− ?: |(?=(%var -.left.original) ?=(%avar -.left.original) ?=(%nvar -.left.original) ?=(%var -.right.original) ?=(%avar -.right.original) ?=(%nvar -.right.original)) ~
8679+ ?: |(?=(%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))) ~
74838680 =. actual (itype-walk actual sub)
74848681 =. expected (itype-walk expected sub)
74858682 ?: &(?=(%face -.expected) !?=(%face -.actual))
@@ -7529,52 +8726,336 @@
75298726 [%| ["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)]]]]
75308727 [%& expected state.p.value(sub sub.fit, next next.fit)]
75318728::
7532−++ infer-call-context-arg
7533− |= [e=expr expected=itype env=ienv state=istate context=span]
8729+:: A known gate may receive an enclosing target before its argument is
8730+:: inferred when its result is open or a direct, matching named generic
8731+:: union. Opaque, recursive, tag-constrained and variable-bound union
8732+:: results keep the existing directional path.
8733+++ infer-contextual-call
8734+ |= [e=expr expected=itype env=ienv state=istate]
75348735 ^- iresult
7535− ?: ?=(%pair -.e) $(e (pair-as-cell e))
7536− ?: ?=(%group -.e) $(e inner.e)
7537− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
7538− ?: ?=(%trace -.e)
7539− =/ traced=iresult (infer-fragment val.e env state)
7540− ?: ?=(%| -.traced) traced
7541− $(e then.e, state state.p.traced)
7542− =/ target=itype (itype-walk expected sub.state)
8736+ ?> ?=(%call -.e)
8737+ ?~ args.e [%| ["call has no argument" ~]]
8738+ =/ head=iresult (infer-fragment head.e env state)
8739+ ?: ?=(%| -.head) head
8740+ =/ ht=itype (itype-walk typ.p.head sub.state.p.head)
8741+ ?. ?=(%fn -.ht) (infer-call-with-head e env state head)
8742+ =/ result=itype (itype-walk product.ht sub.state.p.head)
8743+ =/ eligible=?
8744+ ?: ?=(%var -.result) &
8745+ :: A direct known generic union may receive the same nominal result
8746+ :: context before its arguments are checked. Variable-bound origins,
8747+ :: pending tags, recursive identities and unknown atoms stay open.
8748+ ?. &(?=(%union -.product.ht) ?=(%union -.result) ?=(%union -.expected)) |
8749+ ?~ origin.result |
8750+ ?. =(origin.result origin.expected) |
8751+ ?~ args.result |
8752+ ?. =((lent args.result) (lent args.expected)) |
8753+ ?: |((itype-has-tag (itype-normalize result sub.state.p.head)) (itype-has-tag (itype-normalize expected sub.state.p.head))) |
8754+ ?: |((itype-has-recursive (itype-normalize result sub.state.p.head)) (itype-has-recursive (itype-normalize expected sub.state.p.head))) |
8755+ ?: |((itype-has-any-atom result sub.state.p.head) (itype-has-any-atom expected sub.state.p.head)) |
8756+ &
8757+ ?. eligible (infer-call-with-head e env state head)
8758+ ?: |(?=(%var -.expected) ?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected)) (itype-has-tag (itype-normalize expected sub.state.p.head)))
8759+ (infer-call-with-head e env state head)
8760+ =/ sub=(unit isub) (itype-unify result expected sub.state.p.head)
8761+ ?~ sub (infer-call-with-head e env state head)
8762+ (infer-call-with-head e env state [%& typ.p.head state.p.head(sub u.sub)])
8763+::
8764+:: An eligible fully faced literal receives context by name, in source order.
8765+++ width-literal-fields
8766+ |= [items=(list item) axis=@ud fuel=@ud]
8767+ ^- (unit iwfields)
8768+ =/ order=(list iwfield) ~
8769+ =/ index=(map term iwfield) *(map term iwfield)
75438770 |-
7544− ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
7545− :: In a loobean-singleton context retain the written loobean noun;
7546− :: the usual final fit decides whether that value is permitted.
8771+ ?~ items ~
8772+ ?: =(0 fuel) ~
8773+ ?~ face.i.items ~
8774+ =/ at-axis=@ud ?~(t.items axis (mul 2 axis))
8775+ =/ entry=iwfield [u.face.i.items at-axis [%noun ~]]
8776+ ?: ?=(^ (~(get by index) name.entry)) ~
8777+ =. index (~(put by index) name.entry entry)
8778+ =. order [entry order]
8779+ ?~ t.items `[(flop order) index]
8780+ $(items t.items, axis +((mul 2 axis)), fuel (dec fuel))
8781+++ width-infer-items
8782+ |= [items=(list item) expected=(map term iwfield) env=ienv state=istate context=span]
8783+ ^- iresult
8784+ ?~ items [%| ["empty record is not supported" ~]]
8785+ ?~ face.i.items [%| ["record face needs unsupported inference" ~]]
8786+ =/ field=(unit iwfield) (~(get by expected) u.face.i.items)
8787+ =/ head=iresult
8788+ ?~ field (infer-fragment val.i.items env state)
8789+ (infer-call-context-arg val.i.items typ.u.field env state context)
8790+ ?: ?=(%| -.head) head
8791+ =/ typ=itype [%face u.face.i.items typ.p.head]
8792+ ?~ t.items [%& typ state.p.head]
8793+ =/ tail=iresult $(items t.items, state state.p.head)
8794+ ?: ?=(%| -.tail) tail
8795+ [%& [%cell typ typ.p.tail] state.p.tail]
8796+++ width-infer-literal
8797+ |= [e=expr expected=itype env=ienv state=istate context=span]
8798+ ^- (unit iresult)
8799+ ?. ?=(%tuple -.e) ~
8800+ ?. |(?=(%cell -.expected) ?=(%face -.expected)) ~
8801+ =/ source=(unit iwfields) (width-literal-fields items.e 1 4.096)
8802+ =/ target=(unit iwfields) (width-scan expected sub.state 1 4.096)
8803+ ?~ source ~
8804+ ?~ target ~
8805+ ?: (lth (lent order.u.source) (lent order.u.target)) ~
8806+ ?. (width-in-order order.u.source order.u.target)
8807+ `(infer-simple-items items.e env state)
8808+ `(width-infer-items items.e index.u.target env state context)
8809+::
8810+:: Experimental intrinsic recognition; real bindings retain normal calls.
8811+++ explicit-proj-call
8812+ |= [e=expr env=ienv state=istate]
8813+ ^- ?
8814+ ?. ?=(%call -.e) |
8815+ ?. ?=([* ~] args.e) |
8816+ ?. ?=(%wing -.head.e) |
8817+ ?. =(names.head.e ~[%proj]) |
8818+ ?: ?=(^ (ienv-lookup %proj env)) |
8819+ ?: (lien globals.state |=(n=term =(n %proj))) |
8820+ ?~ prelude.state &
8821+ ?:(?=(^ (ienv-lookup %proj values.u.prelude.state)) | &)
8822+++ infer-proj-source
8823+ |= [e=expr expected=itype env=ienv state=istate context=span]
8824+ ^- iresult
8825+ ?: ?=(%group -.e) $(e inner.e)
8826+ =/ literal=(unit iresult) (width-infer-literal e expected env state context)
8827+ ?^ literal u.literal
8828+ (infer-fragment e env state)
8829+++ infer-proj-context
8830+ |= [e=expr expected=itype env=ienv state=istate context=span]
8831+ ^- iresult
8832+ ?> ?=(%call -.e)
8833+ ?~ args.e [%| ["proj needs one record" ~]]
8834+ ?. |(?=(%cell -.expected) ?=(%face -.expected)) [%| ["proj needs an expected record type" ~]]
8835+ =/ value=iresult (infer-proj-source i.args.e expected env state context)
8836+ ?: ?=(%| -.value) value
8837+ =/ shape=(unit [source=iwfields target=iwfields])
8838+ (width-proj-shape typ.p.value expected sub.state.p.value)
8839+ ?~ shape [%| ["proj needs a known record containing its expected fields" ~]]
8840+ =/ project=(unit iwidth-result) (width-project u.shape sub.state.p.value next.state.p.value)
8841+ ?~ project [%| ["proj constraint needs unsupported inference" ~]]
8842+ =/ st=istate state.p.value(sub sub.u.project, next next.u.project)
8843+ [%& expected st(projections [[at.e e typ.p.value expected steps.u.project] projections.st])]
8844+::
8845+:: A known literal singleton in a direct union can contextualize a
8846+:: loobean literal of the same noun. Only explicit singleton and cell
8847+:: competitors are considered; opaque or variable cases stay unknown.
8848+++ explicit-singleton-in-union
8849+ |= [t=itype noun=@]
8850+ ^- ?
8851+ ?. ?=(%union -.t) |
8852+ =/ cases=(list itype) cases.t
8853+ =/ found=? |
8854+ |-
8855+ ?~ cases found
8856+ =/ c=itype i.cases
8857+ ?: ?=(%cell -.c) $(cases t.cases)
8858+ ?. ?=(%const -.c) |
8859+ ?: =(noun val.literal.c)
8860+ ?: found |
8861+ $(cases t.cases, found &)
8862+ $(cases t.cases)
8863+::
8864+:: Select a written literal-headed case only when every competing case is
8865+:: also an explicit singleton-headed cell and exactly one matches. Opaque,
8866+:: variable-bound and differently shaped cases keep inference unchanged.
8867+:: This first slice supplies context to a directly called payload. Plain
8868+:: literal data and other expressions retain their existing inference path.
8869+++ contextual-atomic-arguments
8870+ |= args=(list expr)
8871+ ^- ?
8872+ ?~ args &
8873+ ?. ?=(?(%lit %wing %ctor) -.i.args) |
8874+ $(args t.args)
8875+++ contextual-direct-payload-call
8876+ |= e=expr
8877+ ^- ?
8878+ ?: ?=(%group -.e) $(e inner.e)
8879+ ?. ?=(%call -.e) |
8880+ ?. ?=(%wing -.head.e) |
8881+ ?~ args.e |
8882+ (contextual-atomic-arguments args.e)
8883+::
8884+:: A walked variable may have concealed a union inside a substituted
8885+:: structure before this arm was called. Decline in that case rather than
8886+:: deriving provenance from the already-walked type.
8887+++ contextual-simple-sub
8888+ |= sub=isub
8889+ ^- ?
8890+ ?~ sub &
8891+ ?: ?=(?(%cell %face %fn %union %collection) -.val.i.sub) |
8892+ $(sub t.sub)
8893+::
8894+:: Check the syntactic root before scanning; scan substitutions once.
8895+++ grec-direct-context
8896+ |= [expected=itype sub=isub]
8897+ ^- ?
8898+ =/ left=@ud 4.096
8899+ |-
8900+ ?: ?=(%face -.expected)
8901+ ?: =(0 left) |
8902+ $(expected body.expected, left (dec left))
8903+ ?. ?=(%grec -.expected) |
8904+ ?~ sub &
8905+ ?: =(0 left) |
8906+ ?: ?=(?(%cell %face %fn %union %collection %grec) -.val.i.sub) |
8907+ $(sub t.sub, left (dec left))
8908+++ contextual-direct-union
8909+ |= target=itype
8910+ ^- ?
8911+ ?: ?=(%face -.target) $(target body.target)
8912+ ?=(%union -.target)
8913+++ contextual-tagged-case
8914+ |= [target=itype tag=@ sub=isub]
8915+ ^- (unit itype)
8916+ ?. ?=(%union -.target) ~
8917+ =/ remaining=(list itype) cases.target
8918+ =/ found=(unit itype) ~
8919+ =/ seen=(set @) *(set @)
8920+ |-
8921+ ?~ remaining found
8922+ =/ c=itype i.remaining
8923+ ?. ?=(%cell -.c) ~
8924+ =/ head=itype hed.c
8925+ ?. ?=(%const -.head) ~
8926+ ?: (~(has in:..zuse seen) val.literal.head) ~
8927+ =. seen (~(put in:..zuse seen) val.literal.head)
8928+ ?: =(tag val.literal.head)
8929+ $(remaining t.remaining, found `c)
8930+ $(remaining t.remaining)
8931+::
8932+++ infer-call-context-arg
8933+ |= [e=expr expected=itype env=ienv state=istate context=span]
8934+ ^- iresult
8935+ ?: ?=(%pair -.e) $(e (pair-as-cell e))
8936+ ?: ?=(%group -.e) $(e inner.e)
8937+ ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
8938+ ?: ?=(%trace -.e)
8939+ =/ traced=iresult (infer-fragment val.e env state)
8940+ ?: ?=(%| -.traced) traced
8941+ $(e then.e, state state.p.traced)
8942+ =/ target=itype (itype-walk expected sub.state)
8943+ |-
8944+ ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
8945+ ?: (explicit-proj-call e env state)
8946+ (infer-proj-context e expected env state context)
8947+ :: Experimental construction only for a source-proven direct target.
8948+ :: Decline any walked structural binding to retain raw-variable provenance.
8949+ ?: &(?=(%grec -.target) ?=(%tuple -.e) (grec-direct-context expected sub.state))
8950+ =/ unfolded=(unit [view=itype left=@ud]) (grec-unfold-view target jrec-fuel.state)
8951+ ?~ unfolded [%| ["recursive mold unfolding needs unsupported inference" ~]]
8952+ ?~ items.e [%| ["recursive mold constructor needs unsupported inference" ~]]
8953+ =/ first=item i.items.e
8954+ ?. &(?=(~ face.first) ?=(%lit -.val.first) =(%term form.lit.val.first))
8955+ [%| ["recursive mold constructor needs unsupported inference" ~]]
8956+ =/ chosen=(unit itype) (contextual-tagged-case view.u.unfolded val.lit.val.first sub.state)
8957+ ?~ chosen [%| ["recursive mold constructor has no matching case" ~]]
8958+ =/ value=iresult (infer-call-context-items items.e u.chosen env state(jrec-fuel left.u.unfolded) context)
8959+ ?: ?=(%| -.value) value
8960+ =/ fit=ifit (itype-fit typ.p.value u.chosen sub.state.p.value next.state.p.value)
8961+ ?: ?=(%unknown -.fit) [%| ["recursive mold case needs unsupported inference" ~]]
8962+ ?: ?=(%bad -.fit) [%| ["recursive mold case does not fit its source shape" ~]]
8963+ [%& target state.p.value(sub sub.fit, next next.fit)]
8964+ :: Only the source-proven one-layer cell is exposed. Each recursive
8965+ :: descent consumes one written tuple; named values use ordinary fit.
8966+ ?: &(?=(%jrec -.target) ?=(%lit -.e) =(%null form.lit.e))
8967+ ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
8968+ [%& target state(jrec-fuel (dec jrec-fuel.state))]
8969+ ?: &(?=(%jrec -.target) ?=(%tuple -.e))
8970+ ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
8971+ =. state state(jrec-fuel (dec jrec-fuel.state))
8972+ =/ shape=itype
8973+ [%cell [%face head.target [%atom aura.target]] [%face tail.target target]]
8974+ =/ value=iresult (infer-call-context-items items.e shape env state context)
8975+ ?: ?=(%| -.value) value
8976+ =/ fit=ifit (itype-fit typ.p.value shape sub.state.p.value next.state.p.value)
8977+ ?: ?=(%unknown -.fit) [%| ["recursive mold cell constraint needs unsupported inference" ~]]
8978+ ?: ?=(%bad -.fit) [%| ["recursive mold cell does not fit its source shape" ~]]
8979+ [%& target state.p.value(sub sub.fit, next next.fit)]
8980+ ?: ?=(%call -.e) (infer-contextual-call e target env state)
8981+ ?: (single-structured-pattern e)
8982+ ?> ?=(%branch -.e)
8983+ =/ single=(unit iresult) (grec-single-wing-subject subject.e env state)
8984+ ?^ single (infer-known-union-context-subject e target env u.single context)
8985+ (infer-single-case-branch e env state `[target context])
8986+ ?: (cell-binder-pattern e)
8987+ (infer-cell-branch e env state `[target context])
8988+ :: In an explicit singleton context retain the written loobean noun;
8989+ :: the ordinary singleton fit compares its noun, not its spelling.
75478990 =/ singleton=(unit itype)
75488991 ?. ?=(%lit -.e) ~
75498992 ?. =(%loobean form.lit.e) ~
7550− ?. ?=(%const -.target) ~
7551− ?. =(%loobean form.literal.target) ~
8993+ ?. |(?=(%const -.target) &(?=(%union -.expected) (explicit-singleton-in-union expected val.lit.e))) ~
75528994 `[%const lit.e]
75538995 ?^ singleton [%& u.singleton state]
7554− =/ known=(unit itype)
8996+ =/ known=(unit iresult)
75558997 ?: ?=(%branch -.e) (known-union-subject subject.e env state)
75568998 ~
7557− ?: &(?=(^ known) ?=(~ (unit-union-payload u.known)))
7558− (infer-known-union-context e target env state context)
8999+ ?: &(?=(^ known) ?=(%| -.u.known) !(duplicate-loobean-arms e)) u.known
9000+ ?: &(?=(^ known) ?=(%& -.u.known) ?=(~ (unit-union-payload (itype-normalize typ.p.u.known sub.state.p.u.known))))
9001+ (infer-known-union-context-subject e target env u.known context)
75599002 ?: &(?=(%union -.target) ?=(%unit -.e))
75609003 (infer-unit-context e target env state context)
9004+ ?: &(?=(%flag -.target) (context-union-branch e))
9005+ (infer-union-context e target env state context)
75619006 ?: &(?=(%union -.target) (context-union-branch e))
75629007 (infer-union-context e target env state context)
75639008 ?: &(?=(%collection -.target) =(%list name.target) (context-union-branch e))
75649009 (infer-union-context e target env state context)
75659010 ?: &(?=(%collection -.target) =(%list name.target) (context-list-expression e))
75669011 (infer-list-context e target env state context)
9012+ :: A literal-headed tuple can receive the unique case's payload
9013+ :: context. The ordinary final fit still checks the complete union.
9014+ =/ selected=(unit itype)
9015+ ?. &((contextual-simple-sub sub.state) (contextual-direct-union expected) ?=(%union -.target) ?=(%tuple -.e) ?=(^ items.e)) ~
9016+ ?~ t.items.e ~
9017+ ?^ t.t.items.e ~
9018+ ?. (contextual-direct-payload-call val.i.t.items.e) ~
9019+ =/ first=item i.items.e
9020+ ?. &(?=(~ face.first) ?=(%lit -.val.first) |(=(%term form.lit.val.first) =(%null form.lit.val.first) =(%loobean form.lit.val.first))) ~
9021+ (contextual-tagged-case target val.lit.val.first sub.state)
9022+ ?^ selected
9023+ ?> ?=(%tuple -.e)
9024+ :: On this bounded shallow-call shape, preserve any inference that
9025+ :: already fits before trying the new contextual path. Neither pass
9026+ :: can recursively select a nested tuple from the atomic arguments.
9027+ =/ ordinary=(unit iresult)
9028+ =/ initial=iresult (infer-fragment e env state)
9029+ ?: ?=(%| -.initial) ~
9030+ =/ fit=ifit (itype-fit typ.p.initial target sub.state.p.initial next.state.p.initial)
9031+ ?. ?=(%ok -.fit) ~
9032+ `initial
9033+ ?^ ordinary u.ordinary
9034+ =/ value=iresult (infer-call-context-items items.e u.selected env state context)
9035+ ?: ?=(%| -.value) value
9036+ =/ fit=ifit (itype-fit typ.p.value u.selected sub.state.p.value next.state.p.value)
9037+ ?: ?=(%unknown -.fit) [%| ["tagged case needs unsupported inference" ~]]
9038+ ?: ?=(%bad -.fit) [%| ["tagged case does not fit its expected type" ~[[context "expected union case"] [(span-of e) "value"]]]]
9039+ [%& typ.p.value state.p.value(sub sub.fit, next next.fit)]
75679040 ?: &(?=(%cell -.target) ?=(%tuple -.e))
75689041 (infer-call-context-items items.e target env state context)
75699042 (infer-fragment e env state)
75709043::
75719044:: Preserve each written face; the final complete sample fit checks faces.
9045+:: A tuple or positional field face belongs to the enclosing sample,
9046+:: not to the expression at that position. A second face, if present,
9047+:: is part of the value's own expected type.
9048+++ projection-field-target
9049+ |= expected=itype
9050+ ^- itype
9051+ ?:(?=(%face -.expected) body.expected expected)
9052+::
75729053++ infer-call-context-items
75739054 |= [items=(list item) expected=itype env=ienv state=istate context=span]
75749055 ^- iresult
75759056 ?~ items [%| ["empty cell is not supported by partial inference" ~]]
75769057 ?~ t.items
7577− =/ last=iresult (infer-call-context-arg val.i.items expected env state context)
9058+ =/ last=iresult (infer-call-context-arg val.i.items (projection-field-target expected) env state context)
75789059 ?: ?=(%| -.last) last
75799060 =/ typ=itype typ.p.last
75809061 =. typ ?~(face.i.items typ [%face u.face.i.items typ])
@@ -7583,7 +9064,7 @@
75839064 |-
75849065 ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
75859066 ?. ?=(%cell -.target) (infer-simple-items items env state)
7586− =/ head=iresult (infer-call-context-arg val.i.items hed.target env state context)
9067+ =/ head=iresult (infer-call-context-arg val.i.items (projection-field-target hed.target) env state context)
75879068 ?: ?=(%| -.head) head
75889069 =/ typ=itype typ.p.head
75899070 =. typ ?~(face.i.items typ [%face u.face.i.items typ])
@@ -7595,13 +9076,13 @@
75959076 |= [args=(list expr) expected=itype env=ienv state=istate context=span]
75969077 ^- iresult
75979078 ?~ args [%| ["call has no argument" ~]]
7598− ?~ t.args (infer-call-context-arg i.args expected env state context)
9079+ ?~ t.args (infer-call-context-arg i.args (projection-field-target expected) env state context)
75999080 =/ target=itype (itype-walk expected sub.state)
76009081 |-
76019082 ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
76029083 ?. ?=(%cell -.target)
76039084 (infer-simple-items (turn args |=(a=expr [(span-of a) ~ a])) env state)
7604− =/ head=iresult (infer-call-context-arg i.args hed.target env state context)
9085+ =/ head=iresult (infer-call-context-arg i.args (projection-field-target hed.target) env state context)
76059086 ?: ?=(%| -.head) head
76069087 =/ tail=iresult (infer-call-context-args t.args tal.target env state.p.head context)
76079088 ?: ?=(%| -.tail) tail
@@ -7633,7 +9114,7 @@
76339114 ?~ pats [%& ~]
76349115 ?. ?=(%bind -.i.pats) [%| 'branch pattern is not supported by partial inference']
76359116 =/ name=term name.i.pats
7636− ?: |(?=(^ (ienv-lookup name env)) (lien globals |=(n=term =(n name))) (lien seen |=(n=term =(n name))))
9117+ ?: |(=(name %proj) ?=(^ (ienv-lookup name env)) (lien globals |=(n=term =(n name))) (lien seen |=(n=term =(n name))))
76379118 [%| 'pattern shadows a name']
76389119 =/ rest=(each (list term) @t) $(pats t.pats, seen [name seen])
76399120 ?: ?=(%| -.rest) rest
@@ -7658,10 +9139,19 @@
76589139 ?~ t.names |
76599140 =. typ (itype-walk typ sub)
76609141 ?: ?=(%cell -.typ) $(typ tal.typ, names t.names)
7661− |(?=(%union -.typ) ?=(%collection -.typ) ?=(%recursive -.typ) ?=(%noun -.typ) ?=(%fn -.typ) ?=(%tag -.typ))
9142+ |(?=(%union -.typ) ?=(%collection -.typ) ?=(%recursive -.typ) ?=(%jrec -.typ) ?=(%grec -.typ) ?=(%noun -.typ) ?=(%fn -.typ) ?=(%tag -.typ))
9143+::
9144+++ cell-binder-pattern
9145+ |= e=expr
9146+ ^- ?
9147+ ?. ?=(%branch -.e) |
9148+ ?~ arms.e |
9149+ ?^ t.arms.e |
9150+ ?. ?=(%cell -.pat.i.arms.e) |
9151+ !(single-structured-pattern e)
76629152::
76639153++ infer-cell-branch
7664− |= [e=expr env=ienv state=istate]
9154+ |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
76659155 ^- iresult
76669156 ?> ?=(%branch -.e)
76679157 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
@@ -7685,7 +9175,16 @@
76859175 =/ binders=[typ=itype env=ienv next=@ud] (cell-pattern-types p.names env next.st)
76869176 =/ sub=(unit isub) (itype-unify typ.p.subject typ.binders sub.st)
76879177 ?~ sub [%| ["cell pattern does not match the subject type" ~]]
7688− (infer-fragment val.arm env.binders st(next next.binders, sub u.sub))
9178+ =. st st(next next.binders, sub u.sub)
9179+ ?~ expected (infer-fragment val.arm env.binders st)
9180+ =/ body=iresult (infer-call-context-arg val.arm typ.u.expected env.binders st context.u.expected)
9181+ ?: ?=(%| -.body) body
9182+ =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
9183+ ?: ?=(%unknown -.fit) [%| ["cell branch result constraint is not supported by partial inference" ~]]
9184+ ?: ?=(%bad -.fit) [%| ["cell branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.arm) "branch arm"]]]]
9185+ ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
9186+ [%| ["cell branch result needs context in partial inference" ~]]
9187+ [%& typ.u.expected state.p.body(sub sub.fit, next next.fit)]
76899188::
76909189++ show-itype
76919190 |= [t=itype sub=isub]
@@ -7698,9 +9197,15 @@
76989197 %avar
76999198 ?: (lth id.t 26) [(add 65 id.t) ~]
77009199 "T{<id.t>}"
9200+ %rvar
9201+ ?: (lth id.t 26) [(add 65 id.t) ~]
9202+ "T{<id.t>}"
77019203 %nvar
77029204 ?: (lth id.t 26) [(add 65 id.t) ~]
77039205 "T{<id.t>}"
9206+ %rnvar
9207+ ?: (lth id.t 26) [(add 65 id.t) ~]
9208+ "T{<id.t>}"
77049209 %atom "@{(trip aura.t)}"
77059210 %any-atom "@"
77069211 %flag "?"
@@ -7712,6 +9217,8 @@
77129217 ?~ args.t (trip u.label.t)
77139218 "({(trip u.label.t)} {(show-itype-cases args.t sub)})"
77149219 %recursive ?~(label.t "recursive mold" (trip u.label.t))
9220+ %jrec ?~(label.t "recursive mold" (trip u.label.t))
9221+ %grec ?~(label.t "recursive mold" "({(trip u.label.t)} {(show-itype-cases args.t sub)})")
77159222 %collection "({(trip name.t)} {(show-itype-cases args.t sub)})"
77169223 %face "[{(trip name.t)}={(show-itype-context body.t sub)}]"
77179224 %fn "$-({(show-itype-context sample.t sub)} {(show-itype-context product.t sub)})"
@@ -7747,8 +9254,10 @@
77479254 ^- ?
77489255 ?- -.typ
77499256 %nvar &
9257+ %rnvar &
77509258 %var |
77519259 %avar |
9260+ %rvar |
77529261 %atom |
77539262 %any-atom |
77549263 %flag |
@@ -7757,6 +9266,8 @@
77579266 %const |
77589267 %union |((lien cases.typ |=(c=itype (itype-has-nvar c))) (lien args.typ |=(c=itype (itype-has-nvar c))))
77599268 %recursive |
9269+ %jrec |
9270+ %grec (lien args.typ |=(c=itype (itype-has-nvar c)))
77609271 %collection (lien args.typ |=(c=itype (itype-has-nvar c)))
77619272 %face $(typ body.typ)
77629273 %fn |($(typ sample.typ) $(typ product.typ))
@@ -7767,7 +9278,7 @@
77679278 |= [label=tape typ=itype sub=isub]
77689279 ^- tape
77699280 =/ normalized=itype (itype-normalize typ sub)
7770− ?: |(?=(%var -.normalized) ?=(%avar -.normalized) (itype-has-nvar normalized) (itype-has-tag normalized) (itype-has-union normalized)) label
9281+ ?: |(?=(%var -.normalized) ?=(%avar -.normalized) ?=(%rvar -.normalized) (itype-has-nvar normalized) (itype-has-tag normalized) (itype-has-union normalized)) label
77719282 ?: (itype-has-hidden-recursive normalized) label
77729283 =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
77739284 ?: (gth (lent vars) 26) label
@@ -7789,6 +9300,7 @@
77899300 ?+ -.resolved ~
77909301 %var `id.resolved
77919302 %avar `id.resolved
9303+ %rvar `id.resolved
77929304 ==
77939305 ?~ ident $(caps t.caps)
77949306 ?: =(n u.ident) &
@@ -7803,6 +9315,7 @@
78039315 ?+ -.resolved ~
78049316 %var `id.resolved
78059317 %avar `id.resolved
9318+ %rvar `id.resolved
78069319 ==
78079320 ?~ ident $(caps t.caps)
78089321 ?: =(n u.ident) `i.caps
@@ -7817,6 +9330,7 @@
78179330 ?+ -.resolved ~
78189331 %var `id.resolved
78199332 %avar `id.resolved
9333+ %rvar `id.resolved
78209334 ==
78219335 ?~ ident $(caps t.caps)
78229336 =/ found=(unit icap) (cap-with-id u.ident t.caps sub)
@@ -7832,6 +9346,7 @@
78329346 ?+ -.resolved ~
78339347 %var `id.resolved
78349348 %avar `id.resolved
9349+ %rvar `id.resolved
78359350 ==
78369351 ?~ ident &
78379352 ?: (cap-id-in u.ident t.caps sub) &
@@ -7846,8 +9361,8 @@
78469361 ^- ?
78479362 ?~ caps |
78489363 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
7849− ?: ?=(%avar -.resolved)
7850− ?: =(n id.resolved) &
9364+ ?: |(?=(%avar -.resolved) ?=(%rvar -.resolved))
9365+ ?: =(n +.resolved) &
78519366 $(caps t.caps)
78529367 $(caps t.caps)
78539368::
@@ -7857,7 +9372,9 @@
78579372 ?- -.t
78589373 %var |
78599374 %avar =(n id.t)
9375+ %rvar =(n id.t)
78609376 %nvar |
9377+ %rnvar |
78619378 %atom |
78629379 %any-atom |
78639380 %flag |
@@ -7866,6 +9383,8 @@
78669383 %const |
78679384 %union |((lien cases.t |=(c=itype (has-atom-var n c))) (lien args.t |=(c=itype (has-atom-var n c))))
78689385 %recursive |
9386+ %jrec |
9387+ %grec (lien args.t |=(c=itype (has-atom-var n c)))
78699388 %collection (lien args.t |=(c=itype (has-atom-var n c)))
78709389 %face $(t body.t)
78719390 %fn |($(t sample.t) $(t product.t))
@@ -7905,6 +9424,10 @@
79059424 =/ out=tape ""
79069425 |-
79079426 ?~ vars out
9427+ ?: (itype-var-is-restricted i.vars t)
9428+ =/ sep=tape ?:(printed ", " " where ")
9429+ =/ clause=tape "{sep}{(show-itype [%rvar i.vars] ~)} is an atom other than ?"
9430+ $(vars t.vars, printed &, out (weld out clause))
79089431 ?: (itype-var-is-atom i.vars t)
79099432 =/ sep=tape ?:(printed ", " " where ")
79109433 =/ clause=tape "{sep}{(show-itype [%avar i.vars] ~)} is an atom"
@@ -8005,6 +9528,7 @@
80059528++ infer-recursive-gate
80069529 |= [d=def env=ienv state=istate]
80079530 ^- iresult
9531+ =. gate-defs.state ~
80089532 ?. ?=(%value -.d) [%| ["recursive definition is not a gate" ~]]
80099533 ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
80109534 [%| ["recursive definition is not a gate" ~]]
@@ -8214,6 +9738,7 @@
82149738 ?: (constrained-capitals caps.entry sub.state)
82159739 [%| ["explicit capital constraints are not supported by partial inference" ~]]
82169740 =/ typ=itype (itype-normalize typ.entry sub.state)
9741+ ?: (itype-has-nvar typ) [%| ["recursive group needs unsupported inference" ~]]
82179742 ?: |((itype-has-tag typ) (itype-has-hidden-generic typ) (itype-has-hidden-recursive typ) (unsupported-atom-vars typ caps.entry binders.state sub.state))
82189743 [%| ["recursive group needs unsupported inference" ~]]
82199744 =/ free=(list @ud) (weld (free-env-vars env sub.state) (free-cap-vars caps.outer sub.state))
@@ -8232,41 +9757,46 @@
82329757 [%| ["recursive group contains duplicate names" ~]]
82339758 ?: (lien names |=(n=term ?=(^ (ienv-lookup n env))))
82349759 [%| ["recursive group shadows a name" ~]]
8235− =/ scoped=istate state(globals (weld names globals.state))
9760+ =/ scoped=istate state(globals (weld names globals.state), gate-defs ~)
82369761 =/ seeded=igate-seeds (seed-gate-group ds env scoped)
82379762 ?: ?=(%| -.seeded) seeded
82389763 =/ seeds=ienv (group-seed-env entries.p.seeded ~)
82399764 =/ body=igate-seeds (infer-gate-group-bodies entries.p.seeded seeds state.p.seeded)
82409765 ?: ?=(%| -.body) body
9766+ :: Per-member ownership through mutual recursion is not implemented.
9767+ ?: !=(projections.state.p.body projections.state)
9768+ [%| ["record projection in recursive groups needs unsupported inference" ~]]
9769+ ?: !=(holes.state.p.body holes.state)
9770+ [%| ["holes in recursive groups need unsupported inference" ~]]
82419771 ?: (pending-tags tags.state.p.body sub.state.p.body)
82429772 [%| ["recursive group has unresolved literal constraints" ~]]
82439773 =/ schemes=(each ienv idiag) (group-schemes entries.p.body env state state.p.body)
82449774 ?: ?=(%| -.schemes) schemes
82459775 [%& [(weld p.schemes env) state.p.body(globals globals.state)]]
82469776::
9777+++ width-finalize
9778+ |= [ps=(list iwprojection) sub=isub visible=(list @ud)]
9779+ ^- (unit (list iwprojection))
9780+ ?~ ps `~
9781+ ?: (lien t.ps |=(p=iwprojection =(at.p at.i.ps))) ~
9782+ =/ src=itype (default-decimals (itype-normalize source.i.ps sub))
9783+ =/ dst=itype (default-decimals (itype-normalize target.i.ps sub))
9784+ ?: |((itype-has-nvar src) (itype-has-nvar dst) (itype-has-tag src) (itype-has-tag dst)) ~
9785+ =/ vars=(list @ud) (weld (itype-vars src) (itype-vars dst))
9786+ ?. (levy vars |=(n=@ud (lien visible |=(v=@ud =(n v))))) ~
9787+ =/ rest=(unit (list iwprojection)) $(ps t.ps)
9788+ ?~ rest ~
9789+ =/ entry=iwprojection i.ps
9790+ =. entry entry(source src, target dst)
9791+ `[entry u.rest]
9792+::
82479793++ add-supported-defs
8248− |= [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)]
8249− ^- ienv
8250− ?~ ds env
8251− =/ d=def i.ds
8252− ?: ?=(%mold -.d) $(ds t.ds)
8253− ?. (unique-value-name name.d globals) $(ds t.ds)
8254− ?^ (ienv-lookup name.d env) $(ds t.ds)
8255− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
8256− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude]
8257− =. initial (reserve-def-caps val.d initial)
8258− =/ result=iresult (infer-fragment val.d env initial)
8259− =? result ?=(%| -.result) (infer-recursive-gate d env initial)
8260− ?: ?=(%| -.result) $(ds t.ds)
8261− ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
8262− =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
8263− ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
8264− ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
8265− =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
8266− ?: (gth (lent vars) 26) $(ds t.ds)
8267− $(ds t.ds, env [[name.d [typ vars]] env])
9794+ |= [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)]
9795+ ^- [env=ienv artifacts=(list iwidth-definition)]
9796+ (add-supported-defs-core ds all-defs checked heads env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts ~)
82689797::
8269−+$ iresolved [env=ienv grouped=(list term)]
9798+
9799++$ iresolved [env=ienv grouped=(list term) artifacts=(list iwidth-definition)]
82709800+$ iadj (map term (list term))
82719801+$ ivisited (map term ?)
82729802+$ iwork (list [name=term done=?])
@@ -8360,9 +9890,9 @@
83609890 (lien (graph-edges i.component graph) |=(x=term =(x i.component)))
83619891::
83629892++ add-groups
8363− |= [ds=(list def) components=icomponents graph=iadj env=ienv grouped=(list term) state=istate]
9893+ |= [ds=(list def) components=icomponents graph=iadj env=ienv grouped=(list term) artifacts=(list iwidth-definition) state=istate]
83649894 ^- iresolved
8365− ?~ components [env grouped]
9895+ ?~ components [env grouped artifacts]
83669896 =/ component=(list term) i.components
83679897 ?. (graph-cycle component graph) $(components t.components)
83689898 ?: (lien component |=(n=term ?=(^ (ienv-lookup n env)))) $(components t.components)
@@ -8379,19 +9909,63 @@
83799909++ resolve-groups
83809910 |= [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)]
83819911 ^- iresolved
9912+ (resolve-groups-core ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude ~)
9913+::
9914+
9915+++ add-supported-defs-core
9916+ |= [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)])]
9917+ ^- [env=ienv artifacts=(list iwidth-definition)]
9918+ ?~ ds [env artifacts]
9919+ =/ d=def i.ds
9920+ ?: ?=(%mold -.d) $(ds t.ds)
9921+ ?. (unique-value-name name.d globals) $(ds t.ds)
9922+ ?^ (ienv-lookup name.d env) $(ds t.ds)
9923+ =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9924+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~]
9925+ =. grec-index.initial index
9926+ =. gate-defs.initial checked
9927+ =. head-evidence.initial heads
9928+ =. initial (reserve-def-caps val.d initial)
9929+ =/ result=iresult (infer-fragment val.d env initial)
9930+ =? result ?=(%| -.result) (infer-recursive-gate d env initial)
9931+ ?: ?=(%| -.result) $(ds t.ds)
9932+ =. state.p.result (promote-restricted-numbers state.p.result env)
9933+ =. 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)))
9934+ ?^ (unresolved-hole holes.state.p.result holes.initial state.p.result) $(ds t.ds)
9935+ ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
9936+ =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
9937+ ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
9938+ ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
9939+ =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
9940+ ?: (gth (lent vars) 26) $(ds t.ds)
9941+ =/ finalized=(unit (list iwprojection))
9942+ (width-finalize projections.state.p.result sub.state.p.result vars)
9943+ ?~ finalized $(ds t.ds)
9944+ =? artifacts ?=(^ u.finalized)
9945+ [[name.d val.d typ sub.state.p.result (flop u.finalized)] artifacts]
9946+ =? checked |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) (~(put by checked) name.d d)
9947+ $(ds t.ds, env [[name.d [typ vars]] env], checked checked)
9948+::
9949+++ resolve-groups-core
9950+ |= [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)])]
9951+ ^- iresolved
83829952 =/ env=ienv ~
83839953 =/ grouped=(list term) ~
9954+ =/ artifacts=(list iwidth-definition) ~
83849955 =/ names=(list term) (global-value-names ds)
83859956 =/ nameset=ivisited (graph-nameset names ~)
83869957 =/ graph=iadj (graph-make-forward ds nameset ~)
83879958 =/ components=icomponents (graph-components ds names)
83889959 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9960+ =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude)
83899961 |-
8390− =/ next=ienv (add-supported-defs ds env molds globals externals surs mark-externals marks jimports reserved-molds at prelude)
8391− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude]
8392− =/ out=iresolved (add-groups ds components graph next grouped initial)
9962+ =/ next=[env=ienv artifacts=(list iwidth-definition)]
9963+ (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)
9964+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~]
9965+ =. grec-index.initial index
9966+ =/ out=iresolved (add-groups ds components graph env.next grouped artifacts.next initial)
83939967 ?: =(env env.out) out
8394− $(env env.out, grouped grouped.out)
9968+ $(env env.out, grouped grouped.out, artifacts artifacts.out)
83959969::
83969970++ resolve-supported-defs
83979971 |= [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)]
@@ -8650,11 +10224,142 @@
865010224 [at.first at.second (union-relate a (project-union-mold second molds ~))]
865110225 (weld pairs $(cases t.cases))
865210226::
10227+:: A closed structural mold supplies no equation to determine a hole.
10228+:: Applications, references, unbound capitals and unions are unproved.
10229+++ simple-mold-hole
10230+ |= sh=shape
10231+ ^- (unit (unit span))
10232+ ?: ?=(%generic -.sh)
10233+ ?~ vars.sh ~
10234+ ?. (distinct-params vars.sh) ~
10235+ (simple-mold-hole-in body.sh vars.sh)
10236+ (simple-mold-hole-in sh ~)
10237+++ simple-mold-hole-in
10238+ |= [sh=shape vars=(list @t)]
10239+ ^- (unit (unit span))
10240+ ?- -.sh
10241+ %hole ``at.sh
10242+ ?(%aura %noun %void %flag %const) `~
10243+ %tvar ?:((lien vars |=(v=@t =(v name.sh))) `~ ~)
10244+ %cell (simple-mold-field-holes fields.sh vars)
10245+ %fn
10246+ =/ a=(unit (unit span)) $(sh sample.sh)
10247+ ?~ a ~
10248+ =/ b=(unit (unit span)) $(sh product.sh)
10249+ ?~ b ~
10250+ `?~(u.a u.b u.a)
10251+ %generic ~
10252+ * ~
10253+ ==
10254+++ simple-mold-field-holes
10255+ |= [fields=(list field) vars=(list @t)]
10256+ ^- (unit (unit span))
10257+ ?~ fields `~
10258+ =/ f=field i.fields
10259+ =/ first=(unit (unit span))
10260+ ?- -.f
10261+ %face (simple-mold-hole-in shape.f vars)
10262+ %bare (simple-mold-hole-in shape.f vars)
10263+ %pun ~
10264+ ==
10265+ ?~ first ~
10266+ =/ rest=(unit (unit span)) $(fields t.fields)
10267+ ?~ rest ~
10268+ `?~(u.first u.rest u.first)
10269+++ simple-local-mold-hole
10270+ |= defs=(list def)
10271+ ^- (unit span)
10272+ ?~ defs ~
10273+ ?. ?=(%mold -.i.defs) $(defs t.defs)
10274+ =/ found=(unit (unit span)) (simple-mold-hole shape.i.defs)
10275+ ?~ found $(defs t.defs)
10276+ ?^ u.found u.found
10277+ $(defs t.defs)
10278+::
10279+:: A partial prelude may omit unsupported declarations, but may not
10280+:: publish an interface while a named mold's hole remains unchecked.
10281+++ shape-has-hole
10282+ |= sh=shape
10283+ ^- ?
10284+ ?- -.sh
10285+ %hole &
10286+ %path (lien segs.sh |=(s=pseg ?=(%inferred -.s)))
10287+ %apply (lien args.sh shape-has-hole)
10288+ %union (lien cases.sh shape-has-hole)
10289+ %cell (lien fields.sh field-has-hole)
10290+ %fn |($(sh sample.sh) $(sh product.sh))
10291+ %generic $(sh body.sh)
10292+ * |
10293+ ==
10294+++ field-has-hole
10295+ |= f=field
10296+ ^- ?
10297+ ?- -.f
10298+ %face (shape-has-hole shape.f)
10299+ %bare (shape-has-hole shape.f)
10300+ %pun |
10301+ ==
10302+++ named-mold-has-hole
10303+ |= ds=(list def)
10304+ ^- ?
10305+ ?~ ds |
10306+ ?: &(?=(%mold -.i.ds) (shape-has-hole shape.i.ds)) &
10307+ $(ds t.ds)
10308+::
10309+++ sample-has-hole
10310+ |= sam=sample
10311+ ^- ?
10312+ ?- -.sam
10313+ %face (shape-has-hole shape.sam)
10314+ %bare (shape-has-hole shape.sam)
10315+ %cell (lien items.sam sample-has-hole)
10316+ * |
10317+ ==
10318+++ def-has-hole
10319+ |= d=def
10320+ ^- ?
10321+ ?- -.d
10322+ %mold (shape-has-hole shape.d)
10323+ %value (expr-has-hole val.d)
10324+ ==
10325+++ expr-has-hole
10326+ |= e=expr
10327+ ^- ?
10328+ ?- -.e
10329+ %str (lien pieces.e |=(p=piece ?:(?=(%expr -.p) (expr-has-hole p.p) |)))
10330+ %qath (lien segs.e |=(p=qseg ?:(?=(%expr -.p) (expr-has-hole p.p) |)))
10331+ %change (lien edits.e |=(p=edit (expr-has-hole val.p)))
10332+ %pair $(e val.e)
10333+ %unit $(e val.e)
10334+ %group $(e inner.e)
10335+ %list (lien items.e expr-has-hole)
10336+ %tuple (lien items.e |=(i=item (expr-has-hole val.i)))
10337+ ?(%gate %gate-wide) |((sample-has-hole sample.e) $(e body.e))
10338+ %cast |((shape-has-hole shape.e) $(e val.e))
10339+ %call |($(e head.e) (lien args.e expr-has-hole))
10340+ %trace |($(e val.e) $(e then.e))
10341+ %branch |($(e subject.e) (lien arms.e |=(a=arm (expr-has-hole val.a))))
10342+ %body |((lien defs.e def-has-hole) $(e final.e))
10343+ * |
10344+ ==
10345+++ hole-values-present
10346+ |= [ds=(list def) env=ienv]
10347+ ^- ?
10348+ ?~ ds &
10349+ ?. ?=(%value -.i.ds) $(ds t.ds)
10350+ ?: (expr-has-hole val.i.ds)
10351+ ?. ?=(^ (ienv-lookup name.i.ds env)) |
10352+ $(ds t.ds)
10353+ $(ds t.ds)
865310354++ show-partial-mold
865410355 |= [file=path src=@t d=def molds=imolds]
865510356 ^- @t
865610357 ?> ?=(%mold -.d)
865710358 =/ sh=shape shape.d
10359+ =/ hole=(unit (unit span)) (simple-mold-hole sh)
10360+ ?: &(?=(^ hole) ?=(^ u.hole))
10361+ =/ text=@t (show-error src [file line.beg.u.u.hole col.beg.u.u.hole "unresolved type hole"])
10362+ (of-wain:format ~[(crip "+$ {(trip name.d)}: type hole needs a determined type") text])
865810363 =? sh ?=(%generic -.sh) body.sh
865910364 ?. ?=(%union -.sh) (crip "+$ {(trip name.d)}: not checked")
866010365 =/ pairs=(list upair) (union-pairs cases.sh molds)
@@ -8681,6 +10386,21 @@
868110386 (show-error src [file line.beg.at.site col.beg.at.site note.site])
868210387 (of-wain:format [summary excerpts])
868310388::
10389+:: Both written field sites are shown in the source that declares them.
10390+++ show-duplicate-fields
10391+ |= [file=path src=@t diagnostic=idiag]
10392+ ^- @t
10393+ =/ excerpts=(list @t)
10394+ %+ turn sites.diagnostic
10395+ |= site=[at=span note=tape]
10396+ (show-error src [file line.beg.at.site col.beg.at.site note.site])
10397+ (of-wain:format [(crip msg.diagnostic) excerpts])
10398+::
10399+++ duplicate-fields-report
10400+ |= [file=path src=@t diagnostic=idiag]
10401+ ^- @t
10402+ (of-wain:format ~['partial inference; module not checked' (show-duplicate-fields file src diagnostic)])
10403+::
868410404:: +golden-types: a partial report; it does not claim the module checks
868510405::
868610406++ golden-types
@@ -8710,6 +10430,180 @@
871010430+$ jfile-result (each [iface=ifile cache=jcache] @t)
871110431+$ jimports-result (each [resolved=ijimports cache=jcache] @t)
871210432::
10433+:: Written record fields each have their own lexical record scope.
10434++$ written-fields (map term span)
10435+++ duplicate-written-field
10436+ |= [name=term at=span seen=written-fields]
10437+ ^- (unit idiag)
10438+ =/ prior=(unit span) (~(get by seen) name)
10439+ ?~ prior ~
10440+ `["record field `{(trip name)}` is repeated" ~[[u.prior "first field"] [at "repeated field"]]]
10441+++ duplicate-shapes
10442+ |= xs=(list shape)
10443+ ^- (unit idiag)
10444+ ?~ xs ~
10445+ =/ first (duplicate-shape i.xs)
10446+ ?^ first first
10447+ $(xs t.xs)
10448+++ duplicate-fields
10449+ |= [fields=(list field) seen=written-fields]
10450+ ^- (unit idiag)
10451+ ?~ fields ~
10452+ =/ f=field i.fields
10453+ =/ n=(unit term)
10454+ ?- -.f
10455+ %face `name.f
10456+ %pun `name.f
10457+ %bare ~
10458+ ==
10459+ =/ dup=(unit idiag) ?~(n ~ (duplicate-written-field u.n at.f seen))
10460+ ?^ dup dup
10461+ =/ inner=(unit idiag)
10462+ ?- -.f
10463+ %face (duplicate-shape shape.f)
10464+ %pun ~
10465+ %bare (duplicate-shape shape.f)
10466+ ==
10467+ ?^ inner inner
10468+ $(fields t.fields, seen ?~(n seen (~(put by seen) u.n at.f)))
10469+++ duplicate-shape
10470+ |= s=shape
10471+ ^- (unit idiag)
10472+ ?- -.s
10473+ %cell (duplicate-fields fields.s ~)
10474+ %apply (duplicate-shapes args.s)
10475+ %union (duplicate-shapes cases.s)
10476+ %fn
10477+ =/ left (duplicate-shape sample.s)
10478+ ?^ left left
10479+ (duplicate-shape product.s)
10480+ %generic (duplicate-shape body.s)
10481+ * ~
10482+ ==
10483+++ duplicate-samples
10484+ |= [items=(list sample) seen=written-fields]
10485+ ^- (unit idiag)
10486+ ?~ items ~
10487+ =/ a=sample i.items
10488+ =/ n=(unit term)
10489+ ?- -.a
10490+ %bind `name.a
10491+ %face `name.a
10492+ %pun `name.a
10493+ * ~
10494+ ==
10495+ =/ dup=(unit idiag) ?~(n ~ (duplicate-written-field u.n at.a seen))
10496+ ?^ dup dup
10497+ =/ inner (duplicate-sample a)
10498+ ?^ inner inner
10499+ $(items t.items, seen ?~(n seen (~(put by seen) u.n at.a)))
10500+++ duplicate-sample
10501+ |= s=sample
10502+ ^- (unit idiag)
10503+ ?- -.s
10504+ %cell (duplicate-samples items.s ~)
10505+ %face (duplicate-shape shape.s)
10506+ %bare (duplicate-shape shape.s)
10507+ * ~
10508+ ==
10509+++ duplicate-exprs
10510+ |= xs=(list expr)
10511+ ^- (unit idiag)
10512+ ?~ xs ~
10513+ =/ first (duplicate-expr i.xs)
10514+ ?^ first first
10515+ $(xs t.xs)
10516+++ duplicate-items
10517+ |= [items=(list item) seen=written-fields]
10518+ ^- (unit idiag)
10519+ ?~ items ~
10520+ =/ a=item i.items
10521+ =/ dup=(unit idiag) ?~(face.a ~ (duplicate-written-field u.face.a at.a seen))
10522+ ?^ dup dup
10523+ =/ inner (duplicate-expr val.a)
10524+ ?^ inner inner
10525+ $(items t.items, seen ?~(face.a seen (~(put by seen) u.face.a at.a)))
10526+++ duplicate-pieces
10527+ |= pieces=(list piece)
10528+ ^- (unit idiag)
10529+ ?~ pieces ~
10530+ =/ first=(unit idiag) ?:(?=(%expr -.i.pieces) (duplicate-expr p.i.pieces) ~)
10531+ ?^ first first
10532+ $(pieces t.pieces)
10533+++ duplicate-qsegs
10534+ |= segs=(list qseg)
10535+ ^- (unit idiag)
10536+ ?~ segs ~
10537+ =/ first=(unit idiag) ?:(?=(%expr -.i.segs) (duplicate-expr p.i.segs) ~)
10538+ ?^ first first
10539+ $(segs t.segs)
10540+++ duplicate-edits
10541+ |= edits=(list edit)
10542+ ^- (unit idiag)
10543+ ?~ edits ~
10544+ =/ first (duplicate-expr val.i.edits)
10545+ ?^ first first
10546+ $(edits t.edits)
10547+++ duplicate-arms
10548+ |= arms=(list arm)
10549+ ^- (unit idiag)
10550+ ?~ arms ~
10551+ =/ first (duplicate-expr val.i.arms)
10552+ ?^ first first
10553+ $(arms t.arms)
10554+++ duplicate-defs
10555+ |= defs=(list def)
10556+ ^- (unit idiag)
10557+ ?~ defs ~
10558+ =/ first=(unit idiag)
10559+ ?- -.i.defs
10560+ %mold (duplicate-shape shape.i.defs)
10561+ %value (duplicate-expr val.i.defs)
10562+ ==
10563+ ?^ first first
10564+ $(defs t.defs)
10565+++ duplicate-expr
10566+ |= e=expr
10567+ ^- (unit idiag)
10568+ ?- -.e
10569+ %str (duplicate-pieces pieces.e)
10570+ %qath (duplicate-qsegs segs.e)
10571+ %change (duplicate-edits edits.e)
10572+ %pair (duplicate-expr val.e)
10573+ %unit (duplicate-expr val.e)
10574+ %group (duplicate-expr inner.e)
10575+ %list (duplicate-exprs items.e)
10576+ %tuple (duplicate-items items.e ~)
10577+ %gate-wide
10578+ =/ first (duplicate-sample sample.e)
10579+ ?^ first first
10580+ (duplicate-expr body.e)
10581+ %gate
10582+ =/ first (duplicate-sample sample.e)
10583+ ?^ first first
10584+ (duplicate-expr body.e)
10585+ %cast
10586+ =/ first (duplicate-shape shape.e)
10587+ ?^ first first
10588+ (duplicate-expr val.e)
10589+ %call
10590+ =/ first (duplicate-expr head.e)
10591+ ?^ first first
10592+ (duplicate-exprs args.e)
10593+ %trace
10594+ =/ first (duplicate-expr val.e)
10595+ ?^ first first
10596+ (duplicate-expr then.e)
10597+ %branch
10598+ =/ first (duplicate-expr subject.e)
10599+ ?^ first first
10600+ (duplicate-arms arms.e)
10601+ %body
10602+ =/ first (duplicate-defs defs.e)
10603+ ?^ first first
10604+ (duplicate-expr final.e)
10605+ * ~
10606+ ==
871310607++ import-binding-names
871410608 |= imports=(list import)
871510609 ^- (list term)
@@ -8722,6 +10616,60 @@
872210616 ==
872310617 [n $(imports t.imports)]
872410618::
10619+++ reserved-proj-sample
10620+ |= sam=sample
10621+ ^- ?
10622+ ?- -.sam
10623+ %bind =(name.sam %proj)
10624+ %face =(name.sam %proj)
10625+ %pun =(name.sam %proj)
10626+ %cell (lien items.sam reserved-proj-sample)
10627+ * |
10628+ ==
10629+++ reserved-proj-pattern
10630+ |= p=pattern
10631+ ^- ?
10632+ ?- -.p
10633+ %bind =(name.p %proj)
10634+ %cell (lien items.p reserved-proj-pattern)
10635+ * |
10636+ ==
10637+++ reserved-proj-def
10638+ |= d=def
10639+ ^- ?
10640+ ?: =(name.d %proj) &
10641+ ?: ?=(%value -.d) (reserved-proj-expr val.d)
10642+ |
10643+++ reserved-proj-expr
10644+ |= e=expr
10645+ ^- ?
10646+ ?- -.e
10647+ %str (lien pieces.e |=(p=piece ?:(?=(%expr -.p) (reserved-proj-expr p.p) |)))
10648+ %qath (lien segs.e |=(p=qseg ?:(?=(%expr -.p) (reserved-proj-expr p.p) |)))
10649+ %change (lien edits.e |=(p=edit (reserved-proj-expr val.p)))
10650+ %pair $(e val.e)
10651+ %unit $(e val.e)
10652+ %group $(e inner.e)
10653+ %list (lien items.e reserved-proj-expr)
10654+ %tuple (lien items.e |=(i=item (reserved-proj-expr val.i)))
10655+ ?(%gate %gate-wide) |((reserved-proj-sample sample.e) $(e body.e))
10656+ %cast $(e val.e)
10657+ %call |($(e head.e) (lien args.e reserved-proj-expr))
10658+ %trace |($(e val.e) $(e then.e))
10659+ %branch |($(e subject.e) (lien arms.e |=(a=arm |((reserved-proj-pattern pat.a) (reserved-proj-expr val.a)))))
10660+ %body |((lien defs.e reserved-proj-def) $(e final.e))
10661+ * |
10662+ ==
10663+::
10664+++ module-has-reserved-proj
10665+ |= mod=module
10666+ ^- ?
10667+ =/ imported=(list term) (import-binding-names imports.mod)
10668+ =/ vals=(list term) (global-value-names defs.mod)
10669+ =/ molds=imolds (collect-simple-molds defs.mod)
10670+ =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10671+ |((lien (weld imported (weld vals mold-names)) |=(n=term =(n %proj))) (lien defs.mod reserved-proj-def))
10672+::
872510673++ module-scope-valid
872610674 |= [mod=module prelude-values=(list term) prelude-molds=(list term)]
872710675 ^- ?
@@ -8729,6 +10677,7 @@
872910677 =/ vals=(list term) (global-value-names defs.mod)
873010678 =/ molds=imolds (collect-simple-molds defs.mod)
873110679 =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10680+ ?: (module-has-reserved-proj mod) |
873210681 ?. %+ levy imported
873310682 |= n=term
873410683 &((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))))
@@ -8810,10 +10759,17 @@
881010759 =(var name.i.args.tail)
881110760::
881210761++ prelude-label
8813− |= [typ=itype name=term]
10762+ |= [typ=itype name=term vars=(list @ud)]
881410763 ^- itype
10764+ ?: ?=(%jrec -.typ) typ(label `name)
10765+ ?: ?=(%grec -.typ)
10766+ ?. (identity-union-parameters vars args.typ) typ(label ~)
10767+ typ(label `name)
881510768 ?. ?=(%union -.typ) typ
8816− ?^ args.typ typ
10769+ ?. (identity-union-parameters vars args.typ)
10770+ ?~ origin.typ typ
10771+ ?: =(at.u.origin.typ /lib/jibb/internal/jibb) typ(label ~)
10772+ typ
881710773 typ(label `name)
881810774::
881910775++ partial-prelude-molds
@@ -8828,9 +10784,100 @@
882810784 (infer-mold-template body.m state(active [name.m active.state], in-mold &))
882910785 ?~ out $(molds t.molds)
883010786 =. typ.template.u.out (label-direct-union typ.template.u.out body.m name.m state)
8831− =. typ.template.u.out (prelude-label typ.template.u.out name.m)
10787+ =. typ.template.u.out (prelude-label typ.template.u.out name.m vars.template.u.out)
883210788 [[name.m template.u.out] $(molds t.molds)]
883310789::
10790+:: A compiler-owned interface available only to the dedicated
10791+:: internal-prelude preparation path, never the ordinary module resolver.
10792+++ private-primitive-interface
10793+ ^- ifile
10794+ =/ a=itype [%avar 0]
10795+ =/ pair=itype [%cell a a]
10796+ =/ b=itype [%rvar 0]
10797+ =/ plus=ischeme [[%fn [%cell b b] b] ~[0]]
10798+ =/ minus=ischeme [[%fn b b] ~[0]]
10799+ =/ greater=ischeme [[%fn pair [%flag ~]] ~[0]]
10800+ [~[[%raw-add plus] [%raw-dec minus] [%raw-gth greater]] ~ /lib/jibb/primitives/jibb ~ ~ ~ ~ ~]
10801+::
10802+++ infer-private-internal
10803+ |= [src=@t public-source=@t]
10804+ ^- (unit ifile)
10805+ =/ at=path /lib/jibb/internal/jibb
10806+ =/ parsed (parse at src)
10807+ ?: ?=(%| -.parsed) ~
10808+ =/ mod=module p.parsed
10809+ ?^ (duplicate-defs defs.mod) ~
10810+ ?~ imports.mod
10811+ =/ built=jfile-result (infer-jibb-file at src ~ ~ ~ ~[at] ~ ~ ~ ~)
10812+ ?: ?=(%| -.built) ~
10813+ `iface.p.built
10814+ ?. ?=([[%jibb *] ~] imports.mod) ~
10815+ ?. =(path.i.imports.mod /lib/jibb/primitives) ~
10816+ ?. (module-scope-valid mod ~ ~) ~
10817+ =/ vals=(list term) (global-value-names defs.mod)
10818+ ?: (lien vals |=(n=term =(n %main))) ~
10819+ =/ molds=imolds (collect-simple-molds defs.mod)
10820+ =/ globals=(list term) (weld (import-binding-names imports.mod) vals)
10821+ :: The private source can use the public list and unit molds before the
10822+ :: prelude is otherwise prepared. Re-read the trusted public source here
10823+ :: and admit only its validated canonical templates; do not accept schemes
10824+ :: supplied independently by the caller.
10825+ =/ public=(each module error) (parse /lib/jibb/prelude/jibb public-source)
10826+ ?: ?=(%| -.public) ~
10827+ ?^ (duplicate-defs defs.p.public) ~
10828+ ?. (module-scope-valid p.public ~ ~) ~
10829+ =/ source-molds=imolds (collect-simple-molds defs.p.public)
10830+ =/ written-list=(unit shape) (find-simple-mold %list source-molds)
10831+ =/ source-list=(unit ischeme)
10832+ ?~ written-list ~
10833+ ?. (standard-prelude-list u.written-list) ~
10834+ `[[%collection %list ~[[%var 0]]] ~[0]]
10835+ :: Derive the public unit template from its actual source, then compare
10836+ :: the complete nominal template before making it available privately.
10837+ =/ unit-decl=(unit shape) (find-simple-mold %unit source-molds)
10838+ =/ source-unit=(unit ischeme)
10839+ ?~ unit-decl ~
10840+ =/ unit-molds=imolds ~[[%unit u.unit-decl]]
10841+ =/ unit-state=istate [0 ~ ~ ~ unit-molds ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | /lib/jibb/prelude/jibb ~[%unit] ~ ~ 256 ~ ~ ~ ~]
10842+ =/ unit-types=imold-types (partial-prelude-molds unit-molds unit-state)
10843+ =/ unit-iface=ifile [~ unit-types /lib/jibb/prelude/jibb ~ ~ ~ ~ ~]
10844+ =/ found=(unit ischeme) (find-jibb-mold %unit unit-iface)
10845+ ?~ found ~
10846+ ?. (standard-unit-template u.found /lib/jibb/prelude/jibb) ~
10847+ found
10848+ =/ primitive=ifile private-primitive-interface
10849+ =? primitive ?=(^ source-list)
10850+ primitive(molds [[%list u.source-list] molds.primitive])
10851+ =? primitive ?=(^ source-unit)
10852+ primitive(molds [[%unit u.source-unit] molds.primitive])
10853+ =/ js=ijimports ~[[face.i.imports.mod primitive]]
10854+ =/ reserved=(list term) ~[face.i.imports.mod]
10855+ =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10856+ =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ js reserved ~ ~ ~ | at top ~ ~ 256 ~ ~ ~ ~]
10857+ =/ mts=(each imold-types @t) (module-mold-types molds state)
10858+ =/ usable=(unit imold-types)
10859+ ?: ?=(%& -.mts) `p.mts
10860+ :: Missing public templates may make an unrelated internal mold
10861+ :: unavailable. Validate all molds once with isolated canonical
10862+ :: templates before admitting only those inferred using the actual
10863+ :: source-backed templates. The proof interface is never exported.
10864+ ?. |(?=(~ source-list) ?=(~ source-unit)) ~
10865+ =/ nil=itype [%const [%null %n 0 '~']]
10866+ =/ canonical-unit=ischeme
10867+ [[%union ~[nil [%cell nil [%face %u [%var 0]]]] `[/lib/jibb/prelude/jibb %unit] `%unit ~[[%var 0]]] ~[0]]
10868+ =/ canonical-list=ischeme [[%collection %list ~[[%var 0]]] ~[0]]
10869+ =/ proof-primitive=ifile private-primitive-interface
10870+ =. molds.proof-primitive ~[[%list canonical-list] [%unit canonical-unit]]
10871+ =/ proof-imports=ijimports ~[[face.i.imports.mod proof-primitive]]
10872+ =/ proof=(each imold-types @t) (module-mold-types molds state(jimports proof-imports))
10873+ ?: ?=(%| -.proof) ~
10874+ `(partial-prelude-molds molds state)
10875+ ?~ usable ~
10876+ =/ resolution=iresolved (resolve-groups defs.mod molds globals ~ ~ ~ ~ js reserved at ~)
10877+ =/ env=ienv env.resolution
10878+ ?. (module-values-complete defs.mod env) ~
10879+ `[env u.usable at ~ artifacts.resolution ~ `src ~]
10880+::
883410881++ partial-prelude-interface-with-internal
883510882 |= [src=@t internal-source=(unit @t)]
883610883 ^- (unit ifile)
@@ -8838,15 +10885,16 @@
883810885 =/ at=path /lib/jibb/prelude/jibb
883910886 =/ parsed (parse at src)
884010887 ?: ?=(%| -.parsed) ~
10888+ ?: (named-mold-has-hole defs.p.parsed) ~
10889+ ?^ (duplicate-defs defs.p.parsed) ~
884110890 =/ private=(unit ijimports)
884210891 ?~ imports.p.parsed `~
884310892 ?. ?=([[%jibb *] ~] imports.p.parsed) ~
884410893 ?. =(path.i.imports.p.parsed /lib/jibb/internal) ~
884510894 ?~ internal-source ~
8846− =/ built=jfile-result
8847− (infer-jibb-file /lib/jibb/internal/jibb u.internal-source ~ ~ ~ ~[/lib/jibb/internal/jibb] ~ ~ ~ ~)
8848− ?: ?=(%| -.built) ~
8849− `~[[face.i.imports.p.parsed iface.p.built]]
10895+ =/ built=(unit ifile) (infer-private-internal u.internal-source src)
10896+ ?~ built ~
10897+ `~[[face.i.imports.p.parsed u.built]]
885010898 ?~ private ~
885110899 ?~ defs.p.parsed ~
885210900 ?. (module-scope-valid p.parsed ~ ~) ~
@@ -8861,9 +10909,16 @@
886110909 =? env-molds declared
886210910 (skim molds |=(m=[name=term body=shape] !=(%list name.m)))
886310911 =/ reserved=(list term) ?:(declared ~[%list] ~)
8864− =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ u.private reserved ~ ~ ~ | at names ~]
8865− =/ mt=imold-types (partial-prelude-molds molds state)
8866− =/ partial=ifile [~ mt at ~]
10912+ =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ u.private reserved ~ ~ ~ | at names ~ ~ 256 ~ ~ ~ ~]
10913+ :: Other prelude molds may use list only after its source has passed
10914+ :: the standard-list check. The raw declaration remains removed.
10915+ =/ declared-list=(unit shape) (find-simple-mold %list molds)
10916+ =/ mold-prelude=(unit ifile)
10917+ ?~ declared-list ~
10918+ ?. (standard-prelude-list u.declared-list) ~
10919+ `[~ ~[[%list [[%collection %list ~[[%var 0]]] ~[0]]]] at ~ ~ ~ ~ ~]
10920+ =/ mt=imold-types (partial-prelude-molds molds state(prelude mold-prelude))
10921+ =/ partial=ifile [~ mt at ~ ~ ~ ~ ~]
886710922 :: An explicitly qualified re-export must resolve. Other unsupported
886810923 :: prelude declarations remain reserved but absent from the interface.
886910924 =/ required=imolds
@@ -8874,8 +10929,13 @@
887410929 ?~ names.sh |
887510930 ?=(^ t.names.sh)
887610931 ?. (levy required |=(m=[name=term body=shape] ?=(^ (find-jibb-mold name.m partial)))) ~
8877− =/ env=ienv (resolve-supported-defs ds env-molds globals ~ ~ ~ ~ u.private reserved at `partial)
8878− `[env mt at ~]
10932+ =/ resolution=iresolved (resolve-groups ds env-molds globals ~ ~ ~ ~ u.private reserved at `partial)
10933+ =/ env=ienv env.resolution
10934+ ?. (hole-values-present ds env) ~
10935+ =/ deps=(list iwidth-dependency)
10936+ ?~ u.private ~
10937+ ~[[at.interface.i.u.private source.interface.i.u.private elaborations.interface.i.u.private]]
10938+ `[env mt at ~ artifacts.resolution deps `src ~]
887910939::
888010940++ partial-prelude-interface
888110941 |= src=@t
@@ -8926,6 +10986,66 @@
892610986 ?: =(at at.i.cache) `iface.i.cache
892710987 $(cache t.cache)
892810988::
10989+:: These certificates retain the complete checked source closure. The
10990+:: trusted host must supply the identical prepared prelude and reader nouns.
10991+:: Exact bundle equality binds all source paths and versions; the set
10992+:: retains transitive paths for active-cycle checks. Request-bearing graphs
10993+:: alone have a size limit; incompatible diamond evidence fails closed.
10994+++ request-graph-requests-add
10995+ |= [pending=(list irequest-evidence) acc=(list irequest-evidence) fuel=@ud]
10996+ ^- (unit (list irequest-evidence))
10997+ ?~ pending `acc
10998+ ?: =(0 fuel) ~
10999+ =/ hit=(list irequest-evidence)
11000+ (skim acc |=(x=irequest-evidence &(=(api-at.x api-at.i.pending) =(name.x name.i.pending))))
11001+ ?^ hit
11002+ ?. ?=([* ~] hit) ~
11003+ ?. =(i.hit i.pending) ~
11004+ $(pending t.pending, fuel (dec fuel))
11005+ $(pending t.pending, acc [i.pending acc], fuel (dec fuel))
11006+++ request-graph-inputs-match
11007+ |= [g=irequest-graph externals=iexternals marks=imark-externals modules=jbundle values=(list term) molds=(list term) prelude=(unit ifile)]
11008+ ^- ?
11009+ ?& =(bundle-input.g modules)
11010+ =(prelude-input.g prelude)
11011+ =(prelude-values.g values)
11012+ =(prelude-molds.g molds)
11013+ =(externals.g externals)
11014+ =(marks.g marks)
11015+ ==
11016+++ request-graph-merge
11017+ |= [imports=ijimports g=irequest-graph fuel=@ud]
11018+ ^- (unit irequest-graph)
11019+ ?~ imports `g
11020+ ?: =(0 fuel) ~
11021+ =/ child=ifile interface.i.imports
11022+ ?~ graph.child ~
11023+ =/ cg=irequest-graph u.graph.child
11024+ ?. ?& =(bundle-input.g bundle-input.cg)
11025+ =(prelude-input.g prelude-input.cg)
11026+ =(prelude-values.g prelude-values.cg)
11027+ =(prelude-molds.g prelude-molds.cg)
11028+ =(externals.g externals.cg)
11029+ =(marks.g marks.cg)
11030+ ==
11031+ ~
11032+ =/ merged=(set path) (~(uni in:..zuse paths.g) paths.cg)
11033+ =/ rs=(unit (list irequest-evidence))
11034+ (request-graph-requests-add requests.cg requests.g (add 1 (lent requests.cg)))
11035+ ?~ rs ~
11036+ ?: &(?=(^ u.rs) |((gth (lent ~(tap in:..zuse merged)) 256) (gth (lent u.rs) 256))) ~
11037+ $(imports t.imports, g g(paths merged, requests u.rs), fuel (dec fuel))
11038+++ request-graph-reusable
11039+ |= [f=ifile src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) values=(list term) molds=(list term) prelude=(unit ifile)]
11040+ ^- ?
11041+ ?~ source.f |
11042+ ?. =(u.source.f src) |
11043+ ?~ graph.f |
11044+ =/ g=irequest-graph u.graph.f
11045+ ?. (request-graph-inputs-match g externals marks modules values molds prelude) |
11046+ ?. (~(has in:..zuse paths.g) at.f) |
11047+ !(lien active |=(p=path (~(has in:..zuse paths.g) p)))
11048+::
892911049++ resolve-jibb-imports
893011050 |= [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)]
893111051 ^- jimports-result
@@ -8934,6 +11054,8 @@
893411054 =/ at=path (weld path.i.imports `path`~[%jibb])
893511055 ?: =(at /lib/jibb/internal/jibb)
893611056 [%| 'the prelude internal module is private']
11057+ ?: =(at /lib/jibb/primitives/jibb)
11058+ [%| 'the prelude primitive interface is private']
893711059 ?: (lien active |=(p=path =(p at)))
893811060 [%| (crip "import cycle at {(spud at)}")]
893911061 =/ found=jbundle (skim modules |=(m=jsource =(at at.m)))
@@ -8941,7 +11063,16 @@
894111063 ?^ t.found [%| (crip "duplicate module sources: {(spud at)}")]
894211064 =/ cached=(unit ifile) (find-jibb-cache at cache)
894311065 =/ iface=jfile-result
8944− ?^ cached [%& [u.cached cache]]
11066+ ?^ cached
11067+ ?. =(at.u.cached at) [%| 'cached module identity needs unsupported inference']
11068+ ?~ graph.u.cached
11069+ :: A detached legacy interface has unknown evidence. Rebuild it
11070+ :: against the current graph, without retaining any stale entry.
11071+ =/ clean=jcache (skim cache |=(x=[at=path iface=ifile] !=(at.x at)))
11072+ (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds clean prelude)
11073+ ?. (request-graph-reusable u.cached source.i.found externals mark-externals modules active prelude-values prelude-molds prelude)
11074+ [%| 'cached module evidence needs unsupported inference']
11075+ [%& [u.cached cache]]
894511076 (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
894611077 ?: ?=(%| -.iface) [%| p.iface]
894711078 =/ rest=jimports-result $(imports t.imports, cache cache.p.iface)
@@ -8992,7 +11123,7 @@
899211123 ?~ segments `~
899311124 ?: ?=(%knot -.i.segments) $(segments t.segments)
899411125 =/ seg=pseg i.segments
8995− ?> ?=(%typed -.seg)
11126+ ?. ?=(%typed -.seg) ~
899611127 ?: =(0 aura.seg) ~
899711128 ?: (lien seen |=(n=term =(n name.seg))) ~
899811129 =/ rest=(unit (list iapi-parameter)) $(segments t.segments, seen [name.seg seen])
@@ -9078,6 +11209,7 @@
907811209 ^- ?
907911210 =/ path-names=(list term) (turn paths |=(p=iapi-path name.p))
908011211 =/ derived=(list term) (weld path-names poke-names)
11212+ ?: (lien derived |=(n=term =(n %proj))) |
908111213 =/ outer=(list term) (weld prelude-values (weld (global-value-names defs.mod) (api-import-faces imports.mod)))
908211214 (levy derived |=(n=term &((unique-value-name n derived) !(lien outer |=(x=term =(n x))))))
908311215::
@@ -9123,6 +11255,8 @@
912311255++ api-path-analysis
912411256 |= [mod=module externals=imark-externals prelude-values=(list term) prelude-molds=(list term)]
912511257 ^- (unit (list iapi-path-typed))
11258+ ?: (lien defs.mod def-has-hole) ~
11259+ ?^ (duplicate-defs defs.mod) ~
912611260 =/ ds=(list def) defs.mod
912711261 =/ declarations=(list def)
912811262 (skim ds |=(d=def &(?=(%mold -.d) =(%paths name.d))))
@@ -9150,9 +11284,11 @@
915011284 |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
915111285 ^- (each (list iapi-path-typed) @t)
915211286 ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path analysis requires /ui/api/<agent>.jibb']
9153− ?~ prepared [%| 'API path analysis needs the prepared prelude']
915411287 =/ parsed (parse file src)
915511288 ?: ?=(%| -.parsed) [%| 'API path source does not parse']
11289+ =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11290+ ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
11291+ ?~ prepared [%| 'API path analysis needs the prepared prelude']
915611292 =/ prelude=(unit ifile) `iface.u.prepared
915711293 =/ deps=jimports-result
915811294 (resolve-jibb-imports imports.p.parsed externals marks modules ~[file] values.u.prepared molds.u.prepared ~ prelude)
@@ -9162,6 +11298,346 @@
916211298 ?~ paths [%| 'API path declaration needs unsupported analysis']
916311299 [%& u.paths]
916411300::
11301+:: Analysis evidence retains the API source, the prepared interface, the
11302+:: caller's reader results and the resolved Jibb dependency cache alongside
11303+:: the typed path declarations. Reader results and prepared interfaces are
11304+:: trusted inputs: this does not verify their underlying Hoon source/version,
11305+:: create requests or check the provenance of arbitrary values.
11306++$ iapi-path-evidence
11307+ [at=path source=@t prepared=iprelude externals=iexternals marks=imark-externals dependencies=jcache paths=(list iapi-path-typed)]
11308+++ api-path-evidence-source
11309+ |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
11310+ ^- (each iapi-path-evidence @t)
11311+ ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path evidence requires /ui/api/<agent>.jibb']
11312+ =/ parsed (parse file src)
11313+ ?: ?=(%| -.parsed) [%| 'API path evidence source does not parse']
11314+ =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11315+ ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
11316+ ?~ prepared [%| 'API path evidence needs the prepared prelude']
11317+ =/ public=ifile iface.u.prepared
11318+ =/ deps=jimports-result
11319+ (resolve-jibb-imports imports.p.parsed externals marks modules ~[file] values.u.prepared molds.u.prepared ~ `public)
11320+ ?: ?=(%| -.deps) [%| p.deps]
11321+ =/ paths=(unit (list iapi-path-typed))
11322+ (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
11323+ ?~ paths [%| 'API path declaration needs unsupported analysis']
11324+ [%& [file src u.prepared externals marks cache.p.deps u.paths]]
11325+:: Graph-aware variant preserves the caller active stack and cache.
11326+++ api-path-evidence-graph
11327+ |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
11328+ ^- (each iapi-path-evidence @t)
11329+ ?~ active [%| 'API analysis needs an active graph']
11330+ ?. =(i.active file) [%| 'API analysis active graph does not start at the source']
11331+ ?: (lien t.active |=(p=path =(p file))) [%| 'API analysis active graph contains a cycle']
11332+ ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path evidence requires /ui/api/<agent>.jibb']
11333+ =/ parsed (parse file src)
11334+ ?: ?=(%| -.parsed) [%| 'API path evidence source does not parse']
11335+ =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11336+ ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
11337+ ?~ prepared [%| 'API path evidence needs the prepared prelude']
11338+ =/ public=ifile iface.u.prepared
11339+ =/ deps=jimports-result
11340+ (resolve-jibb-imports imports.p.parsed externals marks modules active values.u.prepared molds.u.prepared cache `public)
11341+ ?: ?=(%| -.deps) [%| p.deps]
11342+ =/ paths=(unit (list iapi-path-typed))
11343+ (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
11344+ ?~ paths [%| 'API path declaration needs unsupported analysis']
11345+ [%& [file src u.prepared externals marks cache.p.deps u.paths]]
11346+::
11347+:: This query classifies a unique path declaration only. Missing evidence
11348+:: or a nonunique name is unknown; it proves nothing about an ask value.
11349+:: Like prepared interfaces, the supplied evidence is a trusted host input.
11350+++ api-path-watchability
11351+ |= [evidence=(unit iapi-path-evidence) case-name=term]
11352+ ^- ?(%watchable %not-watchable %unknown)
11353+ ?~ evidence %unknown
11354+ =/ found=(list iapi-path-typed)
11355+ (skim paths.u.evidence |=(p=iapi-path-typed =(name.path.p case-name)))
11356+ ?. ?=([* ~] found) %unknown
11357+ ?~ scry.path.i.found %watchable
11358+ %not-watchable
11359+::
11360+:: These are declaration-derived request components, not a callable gate,
11361+:: an ask value, or proof of a value's provenance. Keep the exact trusted
11362+:: source/reader evidence until a later checked interface and lowerer can
11363+:: attach it to a generated request. No argument ordering is claimed here.
11364++$ iapi-request-parameter [name=term typ=itype at=span]
11365++$ iapi-request-parts
11366+ [evidence=iapi-path-evidence path=iapi-path-typed parameters=(list iapi-request-parameter) reply-sample=itype fold=(unit itype) watchability=?(%watchable %not-watchable)]
11367+++ api-request-parameter-types
11368+ |= params=(list iapi-parameter)
11369+ ^- (unit (list iapi-request-parameter))
11370+ ?~ params `~
11371+ =/ aura=@ta aura.i.params
11372+ ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
11373+ =/ rest=(unit (list iapi-request-parameter)) $(params t.params)
11374+ ?~ rest ~
11375+ `[[name.i.params [%atom aura] at.i.params] u.rest]
11376+::
11377+:: A single diff's fold consumes the tagged diff and the previous full value.
11378+:: Multiple-diff unions need a checked union representation and remain open.
11379+++ api-request-fold-type
11380+ |= p=iapi-path-typed
11381+ ^- (unit (unit itype))
11382+ ?~ diffs.p `~
11383+ ?^ t.diffs.p ~
11384+ =/ d=iapi-mark-type i.diffs.p
11385+ =/ literal=lit [%term %tas name.d (crip ['%' (trip name.d)])]
11386+ =/ sample=itype [%cell [%cell [%const literal] typ.d] full.p]
11387+ ``[%fn sample full.p]
11388+::
11389+++ api-request-parts
11390+ |= [evidence=(unit iapi-path-evidence) case-name=term]
11391+ ^- (unit iapi-request-parts)
11392+ ?~ evidence ~
11393+ =/ found=(list iapi-path-typed)
11394+ (skim paths.u.evidence |=(p=iapi-path-typed =(name.path.p case-name)))
11395+ ?. ?=([* ~] found) ~
11396+ =/ p=iapi-path-typed i.found
11397+ =/ raw=(unit (list iapi-parameter)) (api-path-parameters segments.path.p ~)
11398+ ?~ raw ~
11399+ =/ params=(unit (list iapi-request-parameter)) (api-request-parameter-types u.raw)
11400+ ?~ params ~
11401+ =/ fold=(unit (unit itype)) (api-request-fold-type p)
11402+ ?~ fold ~
11403+ =/ watch=?(%watchable %not-watchable) ?~(scry.path.p %watchable %not-watchable)
11404+ `[u.evidence p u.params full.p u.fold watch]
11405+::
11406+:: Check ordinary API molds and values plus every declared mark type using
11407+:: the same trusted source, prepared prelude and reader inputs as path
11408+:: evidence. Keep elaborations with those inputs for a later interface.
11409+:: This is partial analysis: an unused /- core is not independently checked,
11410+:: definitions needing derived values remain unsupported, and no complete
11411+:: API, request or constructor is exported or given runtime behavior.
11412++$ iapi-support-evidence
11413+ [paths=iapi-path-evidence values=ienv molds=imold-types marks=(list iapi-mark-type) elaborations=(list iwidth-definition)]
11414+++ api-support-analysis-source
11415+ |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
11416+ ^- (each iapi-support-evidence @t)
11417+ =/ path-result (api-path-evidence-source file src externals marks modules prepared)
11418+ ?: ?=(%| -.path-result) [%| p.path-result]
11419+ =/ evidence=iapi-path-evidence p.path-result
11420+ =/ parsed (parse file src)
11421+ ?: ?=(%| -.parsed) [%| 'API source does not parse']
11422+ =/ mod=module p.parsed
11423+ =/ ordinary=(list def)
11424+ (skim defs.mod |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
11425+ =/ prep=iprelude prepared.evidence
11426+ ?. (module-scope-valid mod(defs ordinary) values.prep molds.prep) [%| 'API ordinary scope needs unsupported inference']
11427+ =/ vals=(list term) (global-value-names ordinary)
11428+ ?: (lien vals |=(n=term =(n %main))) [%| 'API module kind needs unsupported inference']
11429+ =/ declared=(list term) (collect-mark-imports imports.mod)
11430+ =/ mark-types=(unit (list iapi-mark-type)) (api-diff-types declared marks declared)
11431+ ?~ mark-types [%| 'API declared marks need unsupported inference']
11432+ =/ prelude=(unit ifile) `iface.prep
11433+ =/ deps=jimports-result
11434+ (resolve-jibb-imports imports.mod externals marks modules ~[file] values.prep molds.prep dependencies.evidence prelude)
11435+ ?: ?=(%| -.deps) [%| p.deps]
11436+ =/ molds=imolds (collect-simple-molds ordinary)
11437+ =/ globals=(list term) (weld values.prep (weld (import-binding-names imports.mod) vals))
11438+ =/ surs=(list term) (collect-sur-imports imports.mod)
11439+ =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
11440+ =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11441+ =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~]
11442+ =/ mts=(each imold-types @t) (module-mold-types molds state)
11443+ ?: ?=(%| -.mts) [%| p.mts]
11444+ =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
11445+ ?. (module-values-complete ordinary env.resolution) [%| 'API ordinary definitions need unsupported inference']
11446+ [%& [evidence env.resolution p.mts u.mark-types artifacts.resolution]]
11447+:: Preserve the same graph context through supporting definitions.
11448+++ api-support-analysis-graph
11449+ |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
11450+ ^- (each iapi-support-evidence @t)
11451+ =/ path-result (api-path-evidence-graph file src externals marks modules active cache prepared)
11452+ ?: ?=(%| -.path-result) [%| p.path-result]
11453+ =/ evidence=iapi-path-evidence p.path-result
11454+ =/ parsed (parse file src)
11455+ ?: ?=(%| -.parsed) [%| 'API source does not parse']
11456+ =/ mod=module p.parsed
11457+ =/ ordinary=(list def)
11458+ (skim defs.mod |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
11459+ =/ prep=iprelude prepared.evidence
11460+ ?. (module-scope-valid mod(defs ordinary) values.prep molds.prep) [%| 'API ordinary scope needs unsupported inference']
11461+ =/ vals=(list term) (global-value-names ordinary)
11462+ ?: (lien vals |=(n=term =(n %main))) [%| 'API module kind needs unsupported inference']
11463+ =/ declared=(list term) (collect-mark-imports imports.mod)
11464+ =/ mark-types=(unit (list iapi-mark-type)) (api-diff-types declared marks declared)
11465+ ?~ mark-types [%| 'API declared marks need unsupported inference']
11466+ =/ prelude=(unit ifile) `iface.prep
11467+ =/ deps=jimports-result
11468+ (resolve-jibb-imports imports.mod externals marks modules active values.prep molds.prep dependencies.evidence prelude)
11469+ ?: ?=(%| -.deps) [%| p.deps]
11470+ =/ molds=imolds (collect-simple-molds ordinary)
11471+ =/ globals=(list term) (weld values.prep (weld (import-binding-names imports.mod) vals))
11472+ =/ surs=(list term) (collect-sur-imports imports.mod)
11473+ =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
11474+ =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11475+ =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~]
11476+ =/ mts=(each imold-types @t) (module-mold-types molds state)
11477+ ?: ?=(%| -.mts) [%| p.mts]
11478+ =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
11479+ ?. (module-values-complete ordinary env.resolution) [%| 'API ordinary definitions need unsupported inference']
11480+ [%& [evidence env.resolution p.mts u.mark-types artifacts.resolution]]
11481+::
11482+:: Type-analysis artifact for one plain request. The resolver may publish
11483+:: its interface only together with trusted source and reader evidence.
11484+:: No lowering or runtime validator exists.
11485+:: Value watchability remains unproved even for a watchable declaration.
11486++$ ione-request-interface
11487+ [support=iapi-support-evidence parts=iapi-request-parts iface=ifile]
11488+++ request-compatible-ask
11489+ |= prelude=iprelude
11490+ ^- (unit ischeme)
11491+ =/ public=ifile iface.prelude
11492+ ?. =(at.public /lib/jibb/prelude/jibb) ~
11493+ =/ ask=(unit ischeme) (find-jibb-mold %ask public)
11494+ ?~ ask ~
11495+ ?. ?=([@ ~] vars.u.ask) ~
11496+ ?. ?=(%union -.typ.u.ask) ~
11497+ ?. =(origin.typ.u.ask `[/lib/jibb/internal/jibb %ask]) ~
11498+ ?. (identity-union-parameters vars.u.ask args.typ.u.ask) ~
11499+ =/ m=@ud i.vars.u.ask
11500+ ?: (itype-var-is-atom m typ.u.ask) ~
11501+ ?. (levy (itype-vars typ.u.ask) |=(n=@ud =(n m))) ~
11502+ ?: (itype-has-tag typ.u.ask) ~
11503+ =/ private=(list iwidth-dependency)
11504+ (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
11505+ ?. ?=([* ~] private) ~
11506+ ?~ source.i.private ~
11507+ =/ path=(unit ischeme) (find-jibb-mold %path public)
11508+ ?~ path ~
11509+ ?^ vars.u.path ~
11510+ =/ path-type=itype [%collection %list ~[[%atom %ta]]]
11511+ ?. =(typ.u.path path-type) ~
11512+ =/ unit-template=(unit ischeme) (find-jibb-mold %unit public)
11513+ ?~ unit-template ~
11514+ ?. (standard-unit-template u.unit-template /lib/jibb/prelude/jibb) ~
11515+ =/ state-unit=(unit itype) (template-apply u.unit-template ~[[%noun ~]])
11516+ ?~ state-unit ~
11517+ =/ path-unit=(unit itype) (template-apply u.unit-template ~[path-type])
11518+ ?~ path-unit ~
11519+ =/ output=itype [%cell [%face %state [%noun ~]] [%face %message [%var m]]]
11520+ =/ agent-input=itype [%cell [%face %mark [%atom %tas]] [%cell [%face %state u.state-unit] [%face %fact [%noun ~]]]]
11521+ =/ store-input=itype [%cell [%face %state u.state-unit] [%face %fact [%noun ~]]]
11522+ =/ pure-case=itype [%cell [%const [%term %tas %pure '%pure']] [%face %value [%var m]]]
11523+ =/ agent-case=itype
11524+ [%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]]]]]]]]
11525+ =/ store-case=itype
11526+ [%cell [%const [%term %tas %store '%store']] [%cell [%face %module [%atom %t]] [%cell [%face %name [%atom %tas]] [%face %receive [%fn store-input output]]]]]
11527+ ?. =(cases.typ.u.ask ~[pure-case agent-case store-case]) ~
11528+ ask
11529+::
11530+:: The first supported standalone API has exactly one mark import and one
11531+:: plain path declaration, with no other definitions or imports. No partial
11532+:: success is published when source, schema, or a required mold is unknown.
11533+++ one-request-interface-source
11534+ |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
11535+ ^- (each ione-request-interface @t)
11536+ =/ out (api-support-analysis-source file src externals marks modules prepared)
11537+ ?: ?=(%| -.out) [%| p.out]
11538+ =/ support=iapi-support-evidence p.out
11539+ =/ ev=iapi-path-evidence paths.support
11540+ =/ parsed (parse file src)
11541+ ?: ?=(%| -.parsed) [%| 'request source does not parse']
11542+ =/ mod=module p.parsed
11543+ ?. ?=(?([[%mark *] ~] [[%mark *] [%mark *] ~]) imports.mod) [%| 'request imports need unsupported inference']
11544+ ?. ?=([[%mold *] ~] defs.mod) [%| 'request definitions need unsupported inference']
11545+ ?. =(%paths name.i.defs.mod) [%| 'request declaration needs unsupported inference']
11546+ ?. ?=([* ~] paths.ev) [%| 'request count needs unsupported inference']
11547+ =/ p=iapi-path-typed i.paths.ev
11548+ =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
11549+ ?~ parts [%| 'request components need unsupported inference']
11550+ ?. ?=(?(~ [* ~]) parameters.u.parts) [%| 'request parameters need unsupported inference']
11551+ ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) [%| 'request parameter and fold need unsupported inference']
11552+ ?^ scry.path.p [%| 'request scry needs unsupported inference']
11553+ =/ valid-marks=?
11554+ ?~ fold.u.parts ?=([* ~] marks.support)
11555+ ?=([* [* ~]] marks.support)
11556+ ?. valid-marks [%| 'request marks need unsupported inference']
11557+ =/ fold-open=?
11558+ ?~ fold.u.parts |
11559+ |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
11560+ ?: fold-open [%| 'request fold needs unsupported inference']
11561+ ?^ (itype-vars reply-sample.u.parts) [%| 'request payload needs unsupported inference']
11562+ ?: (itype-has-tag reply-sample.u.parts) [%| 'request payload needs unsupported inference']
11563+ =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
11564+ ?~ ask [%| 'request ask needs unsupported inference']
11565+ =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
11566+ ?~ result [%| 'request ask needs unsupported inference']
11567+ =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
11568+ =/ sample=itype
11569+ ?^ fold.u.parts [%cell callback u.fold.u.parts]
11570+ ?~ parameters.u.parts callback
11571+ [%cell typ.i.parameters.u.parts callback]
11572+ =/ scheme=ischeme [[%fn sample u.result] ~[0]]
11573+ =/ exports=imold-types
11574+ (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
11575+ =/ prelude=iprelude prepared.ev
11576+ =/ public=ifile iface.prelude
11577+ ?~ source.public [%| 'request prelude source needs unsupported inference']
11578+ =/ private=(list iwidth-dependency)
11579+ (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
11580+ ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
11581+ ?~ source.i.private [%| 'request internal source needs unsupported inference']
11582+ =/ req=irequest-evidence
11583+ [file name.path.p p src u.source.public u.source.i.private values.prelude molds.prelude externals marks]
11584+ =/ interface=ifile [~[[name.path.p scheme]] exports file ~ ~ ~ `src `[(silt `(list path)`~[file]) ~[req] modules `public values.prelude molds.prelude externals marks]]
11585+ [%& [support u.parts interface]]
11586+:: Graph-aware request artifact; resolver use remains type-only.
11587+++ one-request-interface-graph
11588+ |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
11589+ ^- (each ione-request-interface @t)
11590+ =/ out (api-support-analysis-graph file src externals marks modules active cache prepared)
11591+ ?: ?=(%| -.out) [%| p.out]
11592+ =/ support=iapi-support-evidence p.out
11593+ =/ ev=iapi-path-evidence paths.support
11594+ =/ parsed (parse file src)
11595+ ?: ?=(%| -.parsed) [%| 'request source does not parse']
11596+ =/ mod=module p.parsed
11597+ ?. ?=(?([[%mark *] ~] [[%mark *] [%mark *] ~]) imports.mod) [%| 'request imports need unsupported inference']
11598+ ?. ?=([[%mold *] ~] defs.mod) [%| 'request definitions need unsupported inference']
11599+ ?. =(%paths name.i.defs.mod) [%| 'request declaration needs unsupported inference']
11600+ ?. ?=([* ~] paths.ev) [%| 'request count needs unsupported inference']
11601+ =/ p=iapi-path-typed i.paths.ev
11602+ =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
11603+ ?~ parts [%| 'request components need unsupported inference']
11604+ ?. ?=(?(~ [* ~]) parameters.u.parts) [%| 'request parameters need unsupported inference']
11605+ ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) [%| 'request parameter and fold need unsupported inference']
11606+ ?^ scry.path.p [%| 'request scry needs unsupported inference']
11607+ =/ valid-marks=?
11608+ ?~ fold.u.parts ?=([* ~] marks.support)
11609+ ?=([* [* ~]] marks.support)
11610+ ?. valid-marks [%| 'request marks need unsupported inference']
11611+ =/ fold-open=?
11612+ ?~ fold.u.parts |
11613+ |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
11614+ ?: fold-open [%| 'request fold needs unsupported inference']
11615+ ?^ (itype-vars reply-sample.u.parts) [%| 'request payload needs unsupported inference']
11616+ ?: (itype-has-tag reply-sample.u.parts) [%| 'request payload needs unsupported inference']
11617+ =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
11618+ ?~ ask [%| 'request ask needs unsupported inference']
11619+ =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
11620+ ?~ result [%| 'request ask needs unsupported inference']
11621+ =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
11622+ =/ sample=itype
11623+ ?^ fold.u.parts [%cell callback u.fold.u.parts]
11624+ ?~ parameters.u.parts callback
11625+ [%cell typ.i.parameters.u.parts callback]
11626+ =/ scheme=ischeme [[%fn sample u.result] ~[0]]
11627+ =/ exports=imold-types
11628+ (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
11629+ =/ prelude=iprelude prepared.ev
11630+ =/ public=ifile iface.prelude
11631+ ?~ source.public [%| 'request prelude source needs unsupported inference']
11632+ =/ private=(list iwidth-dependency)
11633+ (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
11634+ ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
11635+ ?~ source.i.private [%| 'request internal source needs unsupported inference']
11636+ =/ req=irequest-evidence
11637+ [file name.path.p p src u.source.public u.source.i.private values.prelude molds.prelude externals marks]
11638+ =/ interface=ifile [~[[name.path.p scheme]] exports file ~ ~ ~ `src `[(silt `(list path)`~[file]) ~[req] modules `public values.prelude molds.prelude externals marks]]
11639+ [%& [support u.parts interface]]
11640+::
916511641++ api-mark-exports
916611642 |= [marks=(list term) all=(list term) externals=imark-externals]
916711643 ^- imold-types
@@ -9175,7 +11651,9 @@
917511651++ api-poke-interface
917611652 |= [at=path mod=module mark-externals=imark-externals prelude-values=(list term) prelude-molds=(list term) prelude=(unit ifile)]
917711653 ^- (unit ifile)
11654+ ?: (lien defs.mod def-has-hole) ~
917811655 ?. ?=([%ui %api @ %jibb ~] at) ~
11656+ ?^ (duplicate-defs defs.mod) ~
917911657 ?~ prelude ~
918011658 ?. =(at.u.prelude /lib/jibb/prelude/jibb) ~
918111659 =/ poke=(unit ischeme) (find-jibb-mold %poke u.prelude)
@@ -9203,7 +11681,133 @@
920311681 =/ mark=(unit itype) (find-imported-mark n mark-externals marks)
920411682 ?~ mark ~
920511683 =/ sc=ischeme [[%fn u.mark typ.u.poke] ~]
9206− `[~[[n sc]] (api-mark-exports marks marks mark-externals) at ~[[n i.t.t.at n]]]
11684+ `[~[[n sc]] (api-mark-exports marks marks mark-externals) at ~[[n i.t.t.at n]] ~ ~ ~ ~]
11685+::
11686+:: Source-proven ordinary helpers validate each selected /sur dependency.
11687+:: Unused or less direct cores remain unsupported by this first interface.
11688+++ api-sur-covered
11689+ |= [surs=(list term) defs=(list def) externals=iexternals all=(list term)]
11690+ ^- ?
11691+ ?~ surs &
11692+ =/ found=(list def)
11693+ %+ skim defs
11694+ |= d=def
11695+ ?. ?=(%mold -.d) |
11696+ ?. ?=(%ref -.shape.d) |
11697+ ?. ?=([@ [@ ~]] names.shape.d) |
11698+ =(i.t.names.shape.d i.surs)
11699+ ?~ found |
11700+ =/ selected=def i.found
11701+ ?. ?=(%mold -.selected) |
11702+ =/ sh=shape shape.selected
11703+ ?. ?=(%ref -.sh) |
11704+ ?. ?=([@ [@ ~]] names.sh) |
11705+ =/ checked=(unit itype) (find-imported-mold i.surs i.names.sh externals all)
11706+ ?~ checked |
11707+ $(surs t.surs)
11708+::
11709++$ imulti-request-gates [values=ienv requests=(list irequest-evidence)]
11710+++ api-request-gates
11711+ |= [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]
11712+ ^- (unit imulti-request-gates)
11713+ ?~ paths `[~ ~]
11714+ ?: =(0 fuel) ~
11715+ =/ p=iapi-path-typed i.paths
11716+ =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
11717+ ?~ parts ~
11718+ ?. ?=(?(~ [* ~]) parameters.u.parts) ~
11719+ ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) ~
11720+ ?^ scry.path.p ~
11721+ ?^ (itype-vars reply-sample.u.parts) ~
11722+ ?: (itype-has-tag reply-sample.u.parts) ~
11723+ =/ open-fold=?
11724+ ?~ fold.u.parts |
11725+ |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
11726+ ?: open-fold ~
11727+ =/ result=(unit itype) (template-apply ask ~[[%var 0]])
11728+ ?~ result ~
11729+ =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
11730+ =/ sample=itype
11731+ ?^ fold.u.parts [%cell callback u.fold.u.parts]
11732+ ?~ parameters.u.parts callback
11733+ [%cell typ.i.parameters.u.parts callback]
11734+ =/ scheme=ischeme [[%fn sample u.result] ~[0]]
11735+ =/ prep=iprelude prepared.ev
11736+ =/ req=irequest-evidence
11737+ [file name.path.p p src public internal values.prep molds.prep externals marks]
11738+ =/ rest=(unit imulti-request-gates)
11739+ $(paths t.paths, fuel (dec fuel))
11740+ ?~ rest ~
11741+ `[[[name.path.p scheme] values.u.rest] [req requests.u.rest]]
11742+::
11743+++ api-poke-from-checked
11744+ |= [file=path mod=module marks=imark-externals values=(list term) molds=(list term) prelude=(unit ifile)]
11745+ ^- (unit [values=ienv derived=(list iderived)])
11746+ =/ pokes=(list def)
11747+ (skim defs.mod |=(d=def &(?=(%mold -.d) =(%poke name.d))))
11748+ ?~ pokes `[~ ~]
11749+ ?. ?=([* ~] pokes) ~
11750+ =/ declared=(list term) (collect-mark-imports imports.mod)
11751+ =/ ns=(unit (list term)) (api-poke-mark-names pokes declared)
11752+ ?~ ns ~
11753+ ?. ?=([@ ~] u.ns) ~
11754+ =/ matching=(list import)
11755+ %+ skim imports.mod
11756+ |= i=import
11757+ ?. ?=(%mark -.i) |
11758+ =(mark.i i.u.ns)
11759+ ?. ?=([* ~] matching) ~
11760+ =/ checked=(unit ifile)
11761+ (api-poke-interface file mod(defs pokes, imports matching) marks values molds prelude)
11762+ ?~ checked ~
11763+ `[values.u.checked derived.u.checked]
11764+::
11765+:: The partial interface is published atomically: all paths, ordinary
11766+:: source definitions, declared marks and the poke must check. Unselected
11767+:: /sur bindings, runtime validation and value watchability remain unproved.
11768+++ multi-request-interface-graph
11769+ |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
11770+ ^- (each [iface=ifile cache=jcache] @t)
11771+ =/ out (api-support-analysis-graph file src externals marks modules active cache prepared)
11772+ ?: ?=(%| -.out) [%| p.out]
11773+ =/ support=iapi-support-evidence p.out
11774+ =/ ev=iapi-path-evidence paths.support
11775+ =/ parsed (parse file src)
11776+ ?: ?=(%| -.parsed) [%| 'request source does not parse']
11777+ =/ mod=module p.parsed
11778+ ?. (levy imports.mod |=(i=import ?=(?(%mark %sur) -.i)))
11779+ [%| 'request imports need unsupported inference']
11780+ =/ surs=(list term) (collect-sur-imports imports.mod)
11781+ ?. (api-sur-covered surs defs.mod externals surs)
11782+ [%| 'API source dependency needs unsupported inference']
11783+ ?~ paths.ev [%| 'request count needs unsupported inference']
11784+ =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
11785+ ?~ ask [%| 'request ask needs unsupported inference']
11786+ =/ prep=iprelude prepared.ev
11787+ =/ public=ifile iface.prep
11788+ ?~ source.public [%| 'request prelude source needs unsupported inference']
11789+ =/ private=(list iwidth-dependency)
11790+ (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
11791+ ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
11792+ ?~ source.i.private [%| 'request internal source needs unsupported inference']
11793+ =/ gates=(unit imulti-request-gates)
11794+ (api-request-gates paths.ev ev u.ask file src u.source.public u.source.i.private externals marks 256)
11795+ ?~ gates [%| 'request paths need unsupported inference']
11796+ =/ poke=(unit [values=ienv derived=(list iderived)])
11797+ (api-poke-from-checked file mod marks values.prep molds.prep `public)
11798+ ?~ poke [%| 'API poke needs unsupported inference']
11799+ =/ mark-molds=imold-types
11800+ (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
11801+ =/ exports=imold-types (weld mark-molds molds.support)
11802+ =/ names=(list term) (turn exports |=(m=[name=term template=ischeme] name.m))
11803+ ?. (levy names |=(n=term (unique-value-name n names)))
11804+ [%| 'API exported molds need unsupported inference']
11805+ =/ env=ienv (weld values.u.gates (weld values.u.poke values.support))
11806+ =/ graph=irequest-graph
11807+ [(silt `(list path)`~[file]) requests.u.gates modules `public values.prep molds.prep externals marks]
11808+ =/ iface=ifile
11809+ [env exports file derived.u.poke elaborations.support ~ `src `graph]
11810+ [%& [iface dependencies.ev]]
920711811::
920811812++ infer-jibb-file
920911813 |= [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)]
@@ -9211,10 +11815,30 @@
921111815 =/ parsed (parse at src)
921211816 ?: ?=(%| -.parsed) [%| (crip "module source does not parse: {(spud at)}")]
921311817 =/ mod=module p.parsed
11818+ =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
11819+ ?^ duplicate [%| (show-duplicate-fields at src u.duplicate)]
921411820 ?: ?=([%ui %api *] at)
921511821 =/ iface=(unit ifile) (api-poke-interface at mod mark-externals prelude-values prelude-molds prelude)
9216− ?~ iface [%| (crip "API module needs unsupported inference: {(spud at)}")]
9217− [%& [u.iface [[at u.iface] cache]]]
11822+ ?^ iface
11823+ =/ checked=ifile u.iface(source `src, graph `[(silt `(list path)`~[at]) ~ modules prelude prelude-values prelude-molds externals mark-externals])
11824+ [%& [checked [[at checked] cache]]]
11825+ ?~ prelude [%| (crip "API module needs unsupported inference: {(spud at)}")]
11826+ =/ prepared=iprelude [u.prelude prelude-values prelude-molds]
11827+ =/ narrow=?
11828+ ?. ?=([[%mark *] ~] imports.mod) |
11829+ ?. ?=([[%mold *] ~] defs.mod) |
11830+ ?. =(%paths name.i.defs.mod) |
11831+ !?=(%union -.shape.i.defs.mod)
11832+ ?: narrow
11833+ =/ request=(each ione-request-interface @t)
11834+ (one-request-interface-graph at src externals mark-externals modules active cache `prepared)
11835+ ?: ?=(%| -.request) [%| (crip "API module needs unsupported inference: {(spud at)}")]
11836+ =/ checked=ifile iface.p.request
11837+ [%& [checked [[at checked] dependencies.paths.support.p.request]]]
11838+ =/ multi=(each [iface=ifile cache=jcache] @t)
11839+ (multi-request-interface-graph at src externals mark-externals modules active cache `prepared)
11840+ ?: ?=(%| -.multi) [%| (crip "API module needs unsupported inference: {(spud at)}")]
11841+ [%& [iface.p.multi [[at iface.p.multi] cache.p.multi]]]
921811842 ?. (module-scope-valid mod prelude-values prelude-molds)
921911843 ?: (pending-declared-poke at mod prelude-values prelude-molds)
922011844 [%| (crip "module kind or scope needs unsupported inference: {(spud at)}")]
@@ -9224,19 +11848,97 @@
922411848 [%| (crip "module kind needs unsupported inference: {(spud at)}")]
922511849 =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
922611850 ?: ?=(%| -.js) [%| p.js]
9227− =/ molds=imolds (collect-simple-molds defs.mod)
11851+ =/ collected=grec-collected
11852+ ?^ imports.mod [(collect-simple-molds defs.mod) *(map term shape)]
11853+ (grec-collect-molds defs.mod)
11854+ =/ molds=imolds molds.collected
922811855 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
922911856 =/ surs=(list term) (collect-sur-imports imports.mod)
923011857 =/ marks=(list term) (collect-mark-imports imports.mod)
923111858 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
923211859 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9233− =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude]
11860+ =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~]
11861+ :: Source and scope were checked above; preserve that exact root and prelude.
11862+ :: This first integration only indexes import-free library sources.
11863+ =/ index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])
11864+ ?^ imports.mod ~
11865+ ?~ prelude ~
11866+ =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude)
11867+ ?~ standard ~
11868+ ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]]) ~
11869+ =/ index=(map term shape) proofs.collected
11870+ ?. !=(index *(map term shape)) ~
11871+ ?: (lien molds |=(m=[name=term body=shape] =(%list name.m))) ~
11872+ `[at src u.prelude index]
11873+ =. grec-index.state index
923411874 =/ mts=(each imold-types @t) (module-mold-types molds state)
923511875 ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
9236− =/ env=ienv (resolve-supported-defs defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
11876+ =/ resolution=iresolved
11877+ ?~ index
11878+ (resolve-groups defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
11879+ (resolve-groups-core defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude index)
11880+ =/ env=ienv env.resolution
923711881 ?. (module-values-complete defs.mod env)
923811882 [%| (crip "module definitions need unsupported inference: {(spud at)}")]
9239− [%& [[env p.mts at ~] [[at [env p.mts at ~]] cache.p.js]]]
11883+ =/ initial=irequest-graph [(silt `(list path)`~[at]) ~ modules prelude prelude-values prelude-molds externals mark-externals]
11884+ =/ graph=(unit irequest-graph) (request-graph-merge resolved.p.js initial (add 1 (lent resolved.p.js)))
11885+ ?~ graph [%| 'module request evidence needs unsupported inference']
11886+ =/ iface=ifile [env p.mts at ~ artifacts.resolution ~ `src graph]
11887+ [%& [iface [[at iface] cache.p.js]]]
11888+::
11889+:: A source-bound analysis of one named mold, not a module, island,
11890+:: request, watchability or runtime check. The host owns the trusted
11891+:: prepared prelude, canonical paths and reader/source version identities.
11892+:: The 256-node cap covers only classification, not source/graph work.
11893++$ igate-free-mold
11894+ [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]
11895+++ gate-free-mold-source
11896+ |= [file=path src=@t name=term externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude) fuel=@ud]
11897+ ^- (each igate-free-mold @t)
11898+ ?~ file [%| 'mold analysis needs a path ending in jibb']
11899+ ?. =(%jibb (rear file)) [%| 'mold analysis needs a path ending in jibb']
11900+ ?: |(=(file /lib/jibb/internal/jibb) =(file /lib/jibb/primitives/jibb))
11901+ [%| 'the prelude internal modules are private']
11902+ ?: ?=([%ui %api *] file) [%| 'API declarations need unsupported mold analysis']
11903+ ?: ?=([%ui %stores *] file) [%| 'store declarations need unsupported mold analysis']
11904+ =/ entries=jbundle (skim modules |=(m=jsource =(file at.m)))
11905+ ?: (gth (lent entries) 1) [%| 'duplicate root module sources']
11906+ =/ wrong-root=? ?~(entries | !=(source.i.entries src))
11907+ ?: wrong-root [%| 'root module source does not match bundle']
11908+ =/ parsed (parse file src)
11909+ ?: ?=(%| -.parsed) [%| 'mold source does not parse']
11910+ =/ mod=module p.parsed
11911+ =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
11912+ ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
11913+ ?~ prepared [%| 'mold analysis needs the prepared prelude']
11914+ ?. (module-scope-valid mod values.u.prepared molds.u.prepared)
11915+ [%| 'mold source has conflicting or unsupported scope']
11916+ =/ selected=(list def)
11917+ (skim defs.mod |=(d=def &(?=(%mold -.d) =(name.d name))))
11918+ ?~ selected [%| 'selected mold is not declared']
11919+ ?^ t.selected [%| 'selected mold is not unique']
11920+ ?> ?=(%mold -.i.selected)
11921+ =/ public=ifile iface.u.prepared
11922+ =/ js=jimports-result
11923+ (resolve-jibb-imports imports.mod externals marks modules ~[file] values.u.prepared molds.u.prepared ~ `public)
11924+ ?: ?=(%| -.js) [%| p.js]
11925+ =/ ms=imolds (collect-simple-molds defs.mod)
11926+ =/ vals=(list term) (global-value-names defs.mod)
11927+ =/ globals=(list term) (weld values.u.prepared (weld (import-binding-names imports.mod) vals))
11928+ =/ surs=(list term) (collect-sur-imports imports.mod)
11929+ =/ declared=(list term) (collect-mark-imports imports.mod)
11930+ =/ reserved=(list term) (weld molds.u.prepared (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
11931+ =/ top=(list term) (turn ms |=(m=[name=term body=shape] name.m))
11932+ =/ state=istate [0 ~ ~ ~ ms globals externals surs marks declared resolved.p.js reserved ~ ~ ~ | file top `public ~ 256 ~ ~ ~ ~]
11933+ =/ inferred=(unit [template=ischeme state=istate])
11934+ (infer-mold-template shape.i.selected state(active ~[name], in-mold &))
11935+ ?~ inferred [%| 'selected mold needs unsupported inference']
11936+ =/ template=ischeme template.u.inferred
11937+ =. typ.template (label-direct-union typ.template shape.i.selected name state)
11938+ =. typ.template (itype-normalize typ.template sub.state.u.inferred)
11939+ =/ cap=@ud (min fuel 256)
11940+ =/ analysis=igate-free (gate-free-type typ.template cap ~)
11941+ [%& [file src name u.prepared externals marks modules cache.p.js template fuel cap analysis]]
924011942::
924111943:: +golden-types-with-modules fails closed for imports without prelude
924211944:: scope. +golden-types-with-prelude resolves supported library graphs;
@@ -9247,6 +11949,8 @@
924711949 ^- @t
924811950 =/ parsed (parse file src)
924911951 ?: ?=(%| -.parsed) (show-error src p.parsed)
11952+ =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11953+ ?^ duplicate (duplicate-fields-report file src u.duplicate)
925011954 ?: (lien imports.p.parsed |=(i=import ?=(%jibb -.i)))
925111955 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
925211956 (golden-types-with-marks file src externals mark-externals)
@@ -9261,6 +11965,8 @@
926111965 ^- @t
926211966 =/ parsed (parse file src)
926311967 ?: ?=(%| -.parsed) (show-error src p.parsed)
11968+ =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11969+ ?^ duplicate (duplicate-fields-report file src u.duplicate)
926411970 ?: =(0 prelude-source) 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
926511971 =/ prelude (parse /lib/jibb/prelude/jibb prelude-source)
926611972 ?: ?=(%| -.prelude) 'partial inference; module not checked\0aprelude source does not parse; module import inference unsupported'
@@ -9279,6 +11985,8 @@
927911985 ^- @t
928011986 =/ parsed (parse file src)
928111987 ?: ?=(%| -.parsed) (show-error src p.parsed)
11988+ =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11989+ ?^ duplicate (duplicate-fields-report file src u.duplicate)
928211990 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
928311991 =/ prelude-values=(list term) values.u.prepared
928411992 =/ prelude-molds=(list term) molds.u.prepared
@@ -9326,6 +12034,10 @@
932612034 =. reserved-molds (weld reserved-molds (turn jimports |=(j=[face=term interface=ifile] face.j)))
932712035 =/ parsed (parse file src)
932812036 ?: ?=(%| -.parsed) (show-error src p.parsed)
12037+ =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
12038+ ?^ duplicate (duplicate-fields-report file src u.duplicate)
12039+ ?: (module-has-reserved-proj p.parsed)
12040+ 'module has reserved proj name'
932912041 =/ ds=(list def) defs.p.parsed
933012042 =/ molds=imolds (collect-simple-molds ds)
933112043 =/ globals=(list term) (weld prelude-values (weld (turn jimports |=(j=[face=term interface=ifile] face.j)) (global-value-names ds)))
@@ -9334,6 +12046,8 @@
933412046 =/ resolution=iresolved (resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds file prelude)
933512047 =/ cycles=(list icycle) (definite-value-cycles ds globals)
933612048 =/ env=ienv env.resolution
12049+ =/ source-defs=(map term def) (direct-checked-gates ds env)
12050+ =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude)
933712051 =/ lines=(list @t) ~
933812052 |-
933912053 ?~ ds (of-wain:format ['partial inference; module not checked' (flop lines)])
@@ -9353,7 +12067,9 @@
935312067 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype typ ~)}{(show-atom-constraint typ)}")
935412068 $(ds t.ds, lines [line lines])
935512069 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9356− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude]
12070+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~]
12071+ =. gate-defs.initial source-defs
12072+ =. head-evidence.initial heads
935712073 =. initial (reserve-def-caps val.d initial)
935812074 =/ result=iresult
935912075 ?: |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
@@ -9361,6 +12077,11 @@
936112077 (infer-fragment val.d env initial)
936212078 ?: ?=(%| -.result)
936312079 $(ds t.ds, lines [(show-inference-diagnostic file src name.d p.result) lines])
12080+ =. state.p.result (promote-restricted-numbers state.p.result env)
12081+ =. 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)))
12082+ =/ hole=(unit idiag) (unresolved-hole holes.state.p.result holes.initial state.p.result)
12083+ ?^ hole
12084+ $(ds t.ds, lines [(show-inference-diagnostic file src name.d u.hole) lines])
936412085 =/ merged=(unit [first=icap second=icap])
936512086 (merged-capitals caps.state.p.result sub.state.p.result)
936612087 ?^ merged
@@ -9383,7 +12104,126 @@
938312104 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
938412105 ?: (gth (lent vars) 26)
938512106 $(ds t.ds, lines [(crip "++ {(trip name.d)}: too many variables for partial printer") lines])
12107+ ?~ (width-finalize projections.state.p.result sub.state.p.result vars)
12108+ $(ds t.ds, lines [(crip "++ {(trip name.d)}: record projection elaboration needs unsupported inference") lines])
938612109 =/ printable=itype (canonical-itype typ vars)
938712110 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
938812111 $(ds t.ds, lines [line lines])
12112+:: Experimental per-module, source-derived recursive tree index.
12113+:: The two tags and the exact children/list/self layout are fixed-shape
12114+:: checks, so ordinary definitions incur no type-tree or source scans.
12115+++ grec-tagged-fields
12116+ |= sh=shape
12117+ ^- (unit [tag=@ fields=(list field)])
12118+ ?. ?=(%cell -.sh) ~
12119+ ?~ fields.sh ~
12120+ =/ head=field i.fields.sh
12121+ ?. ?=(%bare -.head) ~
12122+ ?. ?=(%const -.shape.head) ~
12123+ ?. &(?=(%term form.lit.shape.head) =(%tas aura.lit.shape.head)) ~
12124+ `[val.lit.shape.head t.fields.sh]
12125+++ grec-tree-children
12126+ |= [fs=(list field) param=@t]
12127+ ^- (unit field)
12128+ ?~ fs ~
12129+ ?~ t.fs `i.fs
12130+ ?^ t.t.fs ~
12131+ =/ event=field i.fs
12132+ =/ kids=field i.t.fs
12133+ ?. &(?=(%face -.event) ?=(%face -.kids)) ~
12134+ ?. !=(name.event name.kids) ~
12135+ ?. ?=(%fn -.shape.event) ~
12136+ ?. ?=(%aura -.sample.shape.event) ~
12137+ ?. =(%t aura.sample.shape.event) ~
12138+ ?. ?=(%tvar -.product.shape.event) ~
12139+ ?. =(param name.product.shape.event) ~
12140+ `kids
12141+::
12142+++ grec-tree-proof
12143+ |= [name=term sh=shape]
12144+ ^- ?
12145+ ?. ?=(%generic -.sh) |
12146+ ?. ?=([@ ~] vars.sh) |
12147+ =/ param=@t i.vars.sh
12148+ ?. ?=(%union -.body.sh) |
12149+ ?. ?=([* [* ~]] cases.body.sh) |
12150+ =/ a=(unit [tag=@ fields=(list field)]) (grec-tagged-fields i.cases.body.sh)
12151+ =/ b=(unit [tag=@ fields=(list field)]) (grec-tagged-fields i.t.cases.body.sh)
12152+ ?~ a |
12153+ ?~ b |
12154+ ?. !=(tag.u.a tag.u.b) |
12155+ ?. ?=([* ~] fields.u.a) |
12156+ =/ value=field i.fields.u.a
12157+ ?. ?=(%face -.value) |
12158+ ?. ?=(%aura -.shape.value) |
12159+ ?. =(%t aura.shape.value) |
12160+ =/ selected=(unit field) (grec-tree-children fields.u.b param)
12161+ ?~ selected |
12162+ =/ kids=field u.selected
12163+ ?. ?=(%face -.kids) |
12164+ ?. ?=(%apply -.shape.kids) |
12165+ ?. =(ref.shape.kids ~[%list]) |
12166+ ?. ?=([* ~] args.shape.kids) |
12167+ =/ self=shape i.args.shape.kids
12168+ ?. ?=(%apply -.self) |
12169+ ?. =(ref.self ~[name]) |
12170+ ?. ?=([* ~] args.self) |
12171+ ?. ?=(%tvar -.i.args.self) |
12172+ =(name.i.args.self param)
12173++$ grec-collected [molds=imolds proofs=(map term shape)]
12174+:: Experimental one-layer analysis view, never an exported mold identity.
12175+++ grec-unfold-view
12176+ |= [typ=itype fuel=@ud]
12177+ ^- (unit [view=itype left=@ud])
12178+ ?. ?=(%grec -.typ) ~
12179+ ?: =(fuel 0) ~
12180+ ?. ?=([* ~] args.typ) ~
12181+ =/ sh=shape proof.typ
12182+ ?. (grec-tree-proof name.typ sh) ~
12183+ ?> ?=(%generic -.sh)
12184+ ?> ?=([@ ~] vars.sh)
12185+ ?> ?=(%union -.body.sh)
12186+ ?> ?=([* [* ~]] cases.body.sh)
12187+ =/ ca=shape i.cases.body.sh
12188+ =/ cb=shape i.t.cases.body.sh
12189+ ?> ?=(%cell -.ca)
12190+ ?> ?=(%cell -.cb)
12191+ ?> ?=([* [* ~]] fields.ca)
12192+ ?> ?=([* *] fields.cb)
12193+ =/ tag-a=field i.fields.ca
12194+ =/ tag-b=field i.fields.cb
12195+ ?> ?=(%bare -.tag-a)
12196+ ?> ?=(%bare -.tag-b)
12197+ ?> ?=(%const -.shape.tag-a)
12198+ ?> ?=(%const -.shape.tag-b)
12199+ =/ text-field=field i.t.fields.ca
12200+ ?> ?=(%face -.text-field)
12201+ =/ branch=(list field) t.fields.cb
12202+ =/ kids=(unit field) (grec-tree-children branch i.vars.sh)
12203+ ?~ kids ~
12204+ ?> ?=(%face -.u.kids)
12205+ =/ children=itype [%face name.u.kids [%collection %list ~[typ]]]
12206+ ?> ?=(^ branch)
12207+ =/ payload=itype
12208+ ?~ t.branch children
12209+ =/ event=field i.branch
12210+ ?> ?=(%face -.event)
12211+ [%cell [%face name.event [%fn [%atom %t] i.args.typ]] children]
12212+ =/ leaf=itype [%cell [%const lit.shape.tag-a] [%face name.text-field [%atom %t]]]
12213+ =/ node=itype [%cell [%const lit.shape.tag-b] payload]
12214+ `[[%union ~[leaf node] ~ ~ ~] (dec fuel)]
12215+::
12216+++ grec-collect-molds
12217+ |= ds=(list def)
12218+ ^- grec-collected
12219+ ?~ ds [~ *(map term shape)]
12220+ =/ rest=grec-collected $(ds t.ds)
12221+ ?. ?=(%mold -.i.ds) rest
12222+ =/ name=term name.i.ds
12223+ =/ body=shape shape.i.ds
12224+ =/ proofs=(map term shape) proofs.rest
12225+ =? proofs (grec-tree-proof name body) (~(put by proofs) name body)
12226+ [[[name body] molds.rest] proofs]
12227+::
12228+
938912229--