@@ -874,7 +874,7 @@
874874 %'~[' %'|=(' %'$-(' :: openers
875875 %'%/' %'/' :: paths
876876 %'+' %'`' %'=' :: pair, unit, face
877− %'*' %'?' %'_' :: noun, loobean, type hole
877+ %'*' %'?' :: noun, loobean mold
878878 %'++' %'+$' %'|=' %'|$' :: runes
879879 %'^-' %'~&' %'?-' %'!!' :: runes
880880 %'/-' %'/%' %'/=' :: imports
@@ -1016,7 +1016,6 @@
10161016 [%const at=span =lit] :: ~ %add %.y
10171017 [%ref at=span names=(list term)] :: state item.todo
10181018 [%tvar at=span name=@t] :: M
1019− [%hole at=span ~] :: _
10201019 [%path at=span segs=(list pseg)] :: / /todos /todo/[id=@ud]
10211020 [%apply at=span ref=(list term) args=(list shape)] :: (list @t)
10221021 [%cell at=span fields=(list field)] :: [text=@t done=?]
@@ -1025,9 +1024,9 @@
10251024 [%generic at=span vars=(list @t) body=shape] :: +$ name |$ [M] …
10261025 ==
10271026::
1028−:: +pseg: a path mold's segment, a knot, [name=aura], or [name=_]
1027+:: +pseg: a path mold's segment, a knot or [name=aura]
10291028::
1030−+$ pseg $%([%knot p=@ta] [%typed at=span name=term aura=@ta] [%inferred at=span name=term hole-at=span])
1029++$ pseg $%([%knot p=@ta] [%typed at=span name=term aura=@ta])
10311030::
10321031+| %api
10331032::
@@ -1296,7 +1295,6 @@
12961295 (emit 1 %'=')
12971296 ?: =('`' a) (emit 1 %'`')
12981297 ?: =('*' a) (emit 1 %'*')
1299− ?: =('_' a) (emit 1 %'_')
13001298 ?: =('~' a)
13011299 ?: =('[' b) (emit 2 %'~[')
13021300 ?: =('&' b) (emit 2 %'~&')
@@ -1672,14 +1670,14 @@
16721670:: What may begin each place the parser reads (section 3, Errors):
16731671:: an expression a-z 0-9 " ( [ ~ % / ` | ^ ? !
16741672:: an operand a-z 0-9 " ( [ ~ % / ` | !
1675−:: a mold a-z A-Z @ * ! ? ~ % / ( [ $ _
1673+:: a mold a-z A-Z @ * ! ? ~ % / ( [ $
16761674:: a pattern a-z 0-9 " ~ % * [
16771675:: and what may go tight after an operand: . ( + = after a name, a
16781676:: closer ) ] }, or the : of a comment
16791677::
16801678++ expr-mask 0x57ff.ffff.4800.0000.83ff.8126.0000.0000
16811679++ operand-mask 0x57ff.ffff.0800.0000.03ff.8126.0000.0000
1682−++ mold-mask 0x47ff.fffe.8fff.ffff.8000.8532.0000.0000
1680+++ mold-mask 0x47ff.fffe.0fff.ffff.8000.8532.0000.0000
16831681++ bar-mask 0x1000.0000.0000.0000.0000.0000.0000.0000
16841682++ pattern-mask 0x47ff.fffe.0800.0000.03ff.0424.0000.0000
16851683++ after-mask 0x2000.0000.2000.0000.2400.4b00.0000.0000
@@ -2109,7 +2107,6 @@
21092107 ?- -.s
21102108 %knot (weld "/" (trip p.s))
21112109 %typed "/[{(trip name.s)}=@{(trip aura.s)}]"
2112− %inferred "/[{(trip name.s)}=_]"
21132110 ==
21142111::
21152112++ show-tvars
@@ -2321,7 +2318,6 @@
23212318 %const (nod "const" at.s (show-lit lit.s) ~)
23222319 %ref (nod "ref" at.s (show-names names.s) ~)
23232320 %tvar (nod "tvar" at.s (trip name.s) ~)
2324− %hole (nod "hole" at.s "" ~)
23252321 %path (nod "path" at.s (show-psegs segs.s) ~)
23262322 %apply (nod "apply" at.s (show-names ref.s) (turn args.s sexp-shape))
23272323 %cell (nod "cell" at.s "" (turn fields.s sexp-field))
@@ -3846,7 +3842,6 @@
38463842 %'*' [%& [%noun at.t ~] t.ts]
38473843 %'!!' [%& [%void at.t ~] t.ts]
38483844 %'?' [%& [%flag at.t ~] t.ts]
3849− %'_' [%& [%hole at.t ~] t.ts]
38503845 [%name *] [%& [%ref at.t ~[p.lex.t]] t.ts]
38513846 [%wing *] [%& [%ref at.t p.lex.t] t.ts]
38523847 [%tvar *] [%& [%tvar at.t p.lex.t] t.ts]
@@ -4063,7 +4058,7 @@
40634058 ?: &(?=(^ nex) tight.i.nex) (bad nex "a path segment")
40644059 (bad-space i.after nex "a path segment")
40654060 ::
4066− :: +read-pseg: a path mold's knot, [name=aura], or [name=_] with no
4061+ :: +read-pseg: a path mold's segment, a knot or [name=aura] with no
40674062 :: spaces, and where it ends
40684063 ::
40694064 ++ read-pseg
@@ -4080,16 +4075,13 @@
40804075 ?: |(?=(~ r2) !tight.i.r2) (bad-space i.r1 r2 "`=`")
40814076 ?. ?=([[* * %'='] *] r2) (bad-in r2 "`=`" tis-mask)
40824077 =/ r3=(list token) t.r2
4083− ?: |(?=(~ r3) !tight.i.r3) (bad-space i.r2 r3 "an aura or type hole")
4084− ?. ?=([[* * ?([%aura *] %'_')] *] r3) (bad-in r3 "an aura or type hole" (con pat-mask (bex 95)))
4078+ ?: |(?=(~ r3) !tight.i.r3) (bad-space i.r2 r3 "an aura")
4079+ ?. ?=([[* * [%aura *]] *] r3) (bad-in r3 "an aura" pat-mask)
40854080 =/ r4=(list token) t.r3
40864081 ?: |(?=(~ r4) !tight.i.r4) (bad-space i.r3 r4 "`]`")
40874082 ?. ?=([[* * %']'] *] r4) (bad-in r4 "`]`" ser-mask)
40884083 =/ at=span [beg.at.op end.at.i.r4]
4089− =/ seg=pseg
4090− ?: ?=(%'_' lex.i.r3) [%inferred at p.lex.i.r1 at.i.r3]
4091− [%typed at p.lex.i.r1 p.lex.i.r3]
4092− [%& [seg end.at.i.r4] t.r4]
4084+ [%& [[%typed at p.lex.i.r1 p.lex.i.r3] end.at.i.r4] t.r4]
40934085 --
40944086::
40954087+| %span-check
@@ -4473,7 +4465,6 @@
44734465 %const [%const at.s ~[%lit] %one ~]
44744466 %ref [%ref at.s ~[%name %wing] %one ~]
44754467 %tvar [%tvar at.s ~[%tvar] %one ~]
4476− %hole [%hole at.s ~[%'_'] %one ~]
44774468 %apply [%apply at.s ~[%'('] %shut (turn args.s outline-shape)]
44784469 %cell [%cell at.s ~[%'['] %shut (turn fields.s outline-sample)]
44794470 ::
@@ -4482,11 +4473,8 @@
44824473 %+ murn segs.s
44834474 |= g=pseg
44844475 ^- (unit outline)
4485− ?- -.g
4486− %knot ~
4487− %typed `[%typed at.g ~[%'['] %shut ~]
4488− %inferred `[%typed at.g ~[%'['] %shut ~[[%hole hole-at.g ~[%'_'] %one ~]]]
4489− ==
4476+ ?. ?=(%typed -.g) ~
4477+ `[%typed at.g ~[%'['] %shut ~]
44904478 [%path at.s ~[%'/'] %run ks]
44914479 ::
44924480 %union
@@ -4546,8 +4534,6 @@
45464534 [%path [1 9] [1 9] [1 21]]
45474535 [%face [1 7] [1 7] [1 21]]
45484536 ==
4549− :: an inferred path aura's hole spanning its = as well
4550− ['+$ x /a/[id=_]' ~[[%hole [1 13] [1 12] [1 14]]]]
45514537 :: an import's path cut short
45524538 ['/= c /ui/c' ~[[%jibb [1 1] [1 1] [1 11]]]]
45534539 :: brackets that close with the deeper lines, cut at their line's
@@ -4607,8 +4593,6 @@
46074593:: Atom constraints tied to an explicit capital or an inferred sample
46084594:: are generalized and printed. Other aura variables remain unsupported until
46094595:: their defaulting and inferred generalization are implemented.
4610−:: Restricted-number promotion considers written capitals only; if there
4611−:: are none, it skips the otherwise unnecessary environment traversal.
46124596:: Bare @ is a separate unrestricted atom type. A directional fit check
46134597:: permits concrete atoms to widen to it, never the reverse. A fit that
46144598:: needs a not-yet-implemented constraint remains unsupported. Named unions
@@ -4616,63 +4600,18 @@
46164600:: from their display name. Generic cases must be disjoint for all arguments.
46174601:: Unnamed union printing is informational; it is not Jibb syntax.
46184602::
4619−:: `proj` is a reserved, type-directed operation, not an ordinary gate.
4620−:: The supported fragment selects uniquely faced fields from a known record
4621−:: in source order (reordering is a doc question). It records the original
4622−:: call, source and target types, and source axes with its definition;
4623−:: A single selected field keeps its face and uses one source axis.
4624−:: Checked module interfaces retain that evidence and their source, including
4625−:: the private prelude dependency. A later lowerer must replace the call by
4626−:: an inline gate applied to the operand once; no lowering is implemented yet.
4627−:: Ordinary fits never insert a projection. Unknown or variable-origin record
4628−:: spines, nested projected fields and projections in
4629−:: recursive groups remain unsupported. Directional fits bound faced-spine
4630−:: proofs to fewer than 1,024 cells; the projection planner has a separate
4631−:: 4,096-step bound. These are inference limits, not language limits.
4632−::
4633−:: Supported API imports derive request-gate types atomically for multiple
4634−:: paths, including one typed segment or one diff fold per case. Their checked
4635−:: ordinary definitions, mark molds and supported poke constructor are also
4636−:: exported. A selected /sur mold is checked through its trusted reader result;
4637−:: unused cores and other bindings are not independently validated. APIs
4638−:: with /= imports, separate scry paths, multiple parameters or diffs, or a
4639−:: parameter together with a fold remain unsupported. The unchanged todo API
4640−:: fits this fragment, including named closed fold gates.
4641−::
4642−:: Each case's source-derived schema and canonical API identity travel in a
4643−:: dependency closure bound to the exact supplied bundle, prelude, scope and
4644−:: trusted reader results. Unknown cached entries are rebuilt. Request-bearing
4645−:: closures are limited to 256 source paths and requests. This is type
4646−:: inference only: no request lowering, runtime schema validator or proof that
4647−:: an arbitrary ask value is watchable is supplied.
4648−::
4649−:: A closed gate sample may omit one outer face from a known input slot when
4650−:: its product is identical. Distinct written names, nested value faces,
4651−:: ambiguous cell tails and raw-variable-origin fits retain their prior rules.
4652−::
4653−:: In one synthetic eval of a 48-module deep and 48-module wide request-free
4654−:: graph, baseline versus certificate inference took 21.53 s versus 23.10 s
4655−:: elapsed (21.10 s versus 22.34 s CPU), including startup. The deep cache's
4656−:: jam grew from 2,402 to 4,209 bytes (+1,807 bytes). These single-run figures
4657−:: are not production memory or performance benchmarks.
4658−::
46594603+$ itype
46604604 $~ [%var 0]
46614605 $% [%var id=@ud]
46624606 [%avar id=@ud]
4663− [%rvar id=@ud]
46644607 [%nvar id=@ud]
4665− [%rnvar id=@ud]
46664608 [%atom aura=@ta]
46674609 [%any-atom ~]
46684610 [%flag ~]
4669− [%noun ~]
46704611 [%tag id=@ud literal=lit constructor=?]
46714612 [%const literal=lit]
46724613 [%collection name=term args=(list itype)]
46734614 [%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)]
46764615 [%union cases=(list itype) origin=(unit [at=path name=term]) label=(unit @t) args=(list itype)]
46774616 [%face name=term body=itype]
46784617 [%fn sample=itype product=itype]
@@ -4696,32 +4635,18 @@
46964635 %var
46974636 =/ found=(unit itype) (itype-lookup id.t sub)
46984637 ?~ found t
4699− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
47004638 $(t u.found)
47014639 %avar
47024640 =/ found=(unit itype) (itype-lookup id.t sub)
47034641 ?~ 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
47104642 $(t u.found)
47114643 %nvar
47124644 =/ found=(unit itype) (itype-lookup id.t sub)
47134645 ?~ 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
47204646 $(t u.found)
47214647 %tag
47224648 =/ found=(unit itype) (itype-lookup id.t sub)
47234649 ?~ found t
4724− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
47254650 $(t u.found)
47264651 ==
47274652::
@@ -4732,19 +4657,14 @@
47324657 ?- -.t
47334658 %var =(n id.t)
47344659 %avar =(n id.t)
4735− %rvar =(n id.t)
47364660 %nvar =(n id.t)
4737− %rnvar =(n id.t)
47384661 %atom |
47394662 %any-atom |
47404663 %flag |
4741− %noun |
47424664 %tag =(n id.t)
47434665 %const |
47444666 %union |((lien cases.t |=(c=itype (itype-occurs n c sub))) (lien args.t |=(c=itype (itype-occurs n c sub))))
47454667 %recursive |
4746− %jrec |
4747− %grec (lien args.t |=(c=itype (itype-occurs n c sub)))
47484668 %collection (lien args.t |=(c=itype (itype-occurs n c sub)))
47494669 %face $(t body.t)
47504670 %fn |($(t sample.t) $(t product.t))
@@ -4763,11 +4683,6 @@
47634683 =. a (itype-walk a sub)
47644684 =. b (itype-walk b sub)
47654685 ?: =(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 ~)
47714686 ?: &(?=(%recursive -.a) ?=(%recursive -.b))
47724687 ?:(&(=(module.a module.b) =(name.a name.b)) `sub ~)
47734688 ?: &(?=(%union -.a) ?=(%union -.b))
@@ -4784,32 +4699,6 @@
47844699 ?: ?=(%var -.b)
47854700 ?: (itype-occurs id.b a sub) ~
47864701 `[[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]
48134702 :: The narrower decimal constraint survives a match with an atom
48144703 :: variable; decimal syntax alone does not make it a loobean.
48154704 ?: &(?=(%nvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
@@ -4864,19 +4753,14 @@
48644753 ?- -.t
48654754 %var |
48664755 %avar |
4867− %rvar |
48684756 %nvar |
4869− %rnvar |
48704757 %atom |
48714758 %any-atom &
48724759 %flag |
4873− %noun |
48744760 %tag |
48754761 %const |
48764762 %union |((lien cases.t |=(c=itype (itype-has-any-atom c sub))) (lien args.t |=(c=itype (itype-has-any-atom c sub))))
48774763 %recursive |
4878− %jrec |
4879− %grec (lien args.t |=(c=itype (itype-has-any-atom c sub)))
48804764 %collection (lien args.t |=(c=itype (itype-has-any-atom c sub)))
48814765 %face $(t body.t)
48824766 %fn |($(t sample.t) $(t product.t))
@@ -4939,19 +4823,14 @@
49394823 ?- -.typ
49404824 %var |
49414825 %avar |
4942− %rvar |
49434826 %nvar |
4944− %rnvar |
49454827 %atom &
49464828 %any-atom &
49474829 %flag &
4948− %noun |
49494830 %tag &
49504831 %const &
49514832 %union |((lien cases.typ |=(c=itype (itype-has-fixed-atom c))) (lien args.typ |=(c=itype (itype-has-fixed-atom c))))
49524833 %recursive |
4953− %jrec |
4954− %grec (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
49554834 %collection (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
49564835 %face $(typ body.typ)
49574836 %fn |($(typ sample.typ) $(typ product.typ))
@@ -4980,7 +4859,6 @@
49804859 ^- ?
49814860 =. t (itype-walk t sub)
49824861 ?- -.t
4983− %grec (lien args.t |=(c=itype (itype-has-face c sub)))
49844862 %collection (lien args.t |=(c=itype (itype-has-face c sub)))
49854863 %face &
49864864 %cell |($(t hed.t) $(t tal.t))
@@ -4988,42 +4866,6 @@
49884866 * |
49894867 ==
49904868::
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−::
50274869++ itype-face-asym-collection-args
50284870 |= [as=(list itype) bs=(list itype) sub=isub]
50294871 ^- ?
@@ -5037,15 +4879,12 @@
50374879 ^- ?
50384880 =. a (itype-walk a sub)
50394881 =. 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)
50434882 ?: &(?=(%collection -.a) ?=(%collection -.b))
50444883 ?. =(name.a name.b) |
50454884 (itype-face-asym-collection-args args.a args.b sub)
50464885 ?: &(?=(%face -.a) ?=(%face -.b)) $(a body.a, b body.b)
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)))
4886+ ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%nvar -.b))
4887+ ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%nvar -.a))
50494888 ?: &(?=(%cell -.a) ?=(%cell -.b)) |($(a hed.a, b hed.b) $(a tal.a, b tal.b))
50504889 ?: &(?=(%fn -.a) ?=(%fn -.b)) |($(a sample.a, b sample.b) $(a product.a, b product.b))
50514890 |
@@ -5068,30 +4907,6 @@
50684907 [%cell $(actual hed.actual, expected hed.expected) $(actual tal.actual, expected tal.expected)]
50694908 expected
50704909::
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−::
50954910++ itype-output-may-be-cell
50964911 |= [t=itype sub=isub]
50974912 ^- ?
@@ -5101,9 +4916,6 @@
51014916 %cell &
51024917 %union &
51034918 %recursive &
5104− %jrec &
5105− %grec &
5106− %noun &
51074919 %collection &
51084920 %face $(t body.t)
51094921 %fn |($(t sample.t) $(t product.t))
@@ -5132,7 +4944,6 @@
51324944 ^- ?
51334945 ?- -.t
51344946 %tag &
5135− %grec (lien args.t |=(c=itype (itype-has-tag c)))
51364947 %collection (lien args.t |=(c=itype (itype-has-tag c)))
51374948 %face $(t body.t)
51384949 %fn |($(t sample.t) $(t product.t))
@@ -5146,7 +4957,6 @@
51464957 ^- ?
51474958 ?- -.t
51484959 %union &
5149− %grec (lien args.t |=(c=itype (itype-has-union c)))
51504960 %collection (lien args.t |=(c=itype (itype-has-union c)))
51514961 %face $(t body.t)
51524962 %fn |($(t sample.t) $(t product.t))
@@ -5165,7 +4975,6 @@
51654975 %union
51664976 ?: &(?=(~ label.t) ?=(^ args.t)) &
51674977 (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))))
51694978 %collection (lien args.t |=(c=itype (itype-has-hidden-generic c)))
51704979 %face $(t body.t)
51714980 %fn |($(t sample.t) $(t product.t))
@@ -5178,8 +4987,6 @@
51784987 ^- ?
51794988 ?- -.t
51804989 %recursive &
5181− %jrec &
5182− %grec &
51834990 %collection (lien args.t |=(c=itype (itype-has-recursive c)))
51844991 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-recursive c)))
51854992 %face $(t body.t)
@@ -5193,8 +5000,6 @@
51935000 ^- ?
51945001 ?- -.t
51955002 %recursive ?=(~ label.t)
5196− %jrec ?=(~ label.t)
5197− %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-recursive c))))
51985003 %collection (lien args.t |=(c=itype (itype-has-hidden-recursive c)))
51995004 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-recursive c)))
52005005 %face $(t body.t)
@@ -5222,99 +5027,34 @@
52225027 $(cases t.cases, good `trial)
52235028 ==
52245029::
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.
5030+:: A constructor needs a case with its tag at the head and a payload
5031+:: compatible with the expected gate sample. Other case forms do not
5032+:: identify a constructor.
52285033::
52295034++ itype-fit-ctor-cases
52305035 |= [tag=lit sample=itype cases=(list itype) sub=isub next=@ud]
52315036 ^- ifit
52325037 =/ found=(unit ifit) ~
5233− =/ pending=? |
52345038 |-
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 &)
5039+ ?~ cases ?~(found [%bad ~] u.found)
5040+ =/ c=itype (itype-walk i.cases sub)
52455041 ?. ?=(%cell -.c) $(cases t.cases)
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 &)
5042+ =/ head=itype (itype-walk hed.c sub)
52585043 ?. ?=(%const -.head) $(cases t.cases)
5044+ ?. =(%term form.literal.head) $(cases t.cases)
52595045 ?. =(val.literal.head val.tag) $(cases t.cases)
5260− :: Equal heads can have disjoint payloads. Test each from the original
5261− :: substitution; a unique success is usable only with no unknown rival.
5046+ ?^ found [%unknown ~]
52625047 =/ trial=ifit (itype-fit sample tal.c sub next)
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− ==
5048+ $(cases t.cases, found `trial)
52705049::
52715050++ itype-fit
52725051 |= [actual=itype expected=itype sub=isub next=@ud]
52735052 ^- 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))
52865053 =/ uncertain=?
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)))
5054+ |(?=(%var -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%var -.expected) ?=(%avar -.expected) ?=(%nvar -.expected))
52905055 =. actual (itype-walk actual sub)
52915056 =. expected (itype-walk expected sub)
52925057 ?: =(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 ~]
5296− :: Any value can be used where a noun is expected. An unresolved
5297− :: bare tag is fixed as a constant; a constructor still needs a gate.
5298− ?: ?=(%noun -.expected)
5299− ?: ?=(%tag -.actual)
5300− ?: constructor.actual [%unknown ~]
5301− [%ok [[id.actual expected] sub] next]
5302− [%ok sub next]
5303− :: An arbitrary noun is not known to fit a narrower type.
5304− ?: &(?=(%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 ~]
53185058 ?: &(?=(%recursive -.actual) ?=(%recursive -.expected))
53195059 ?:(&(=(module.actual module.expected) =(name.actual name.expected)) [%ok sub next] [%bad ~])
53205060 ?: &(|(?=(%recursive -.actual) ?=(%recursive -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
@@ -5326,21 +5066,8 @@
53265066 =/ unified=(unit isub) (itype-unify-args args.actual args.expected sub)
53275067 ?^ unified [%ok u.unified next]
53285068 [%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]
5338− :: A concrete union value in a tuple may acquire the expected field's
5339− :: face. A variable-bound union still needs face propagation support.
5340− ?: &(!uncertain ?=(%union -.actual) ?=(%face -.expected))
5341− $(expected body.expected)
53425069 ?: ?=(%union -.actual) [%unknown ~]
5343− ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))) [%unknown ~]
5070+ ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%nvar -.actual))) [%unknown ~]
53445071 ?: &(?=(%union -.expected) !?=(%var -.actual))
53455072 (itype-fit-cases actual cases.expected sub next)
53465073 ?: ?=(%tag -.actual)
@@ -5348,7 +5075,7 @@
53485075 =/ u=(unit isub) (itype-unify actual expected sub)
53495076 ?~ u [%bad ~]
53505077 [%ok u.u next]
5351− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5078+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
53525079 ?: ?=(%face -.expected) $(expected body.expected)
53535080 ?: constructor.actual
53545081 ?. ?=(%fn -.expected) [%bad ~]
@@ -5357,10 +5084,6 @@
53575084 =/ trial=ifit (itype-fit-ctor-cases literal.actual sample.expected cases sub next)
53585085 ?. ?=(%ok -.trial) trial
53595086 [%ok [[id.actual expected] sub.trial] next.trial]
5360− :: Zero may be the empty list. A nested cell fit lacks the context
5361− :: needed to resolve it here, so do not report a definite mismatch.
5362− ?: &(?=(%collection -.expected) =(%list name.expected) =(0 val.literal.actual))
5363− [%unknown ~]
53645087 ?: ?=(%const -.expected)
53655088 ?:(=(val.literal.actual val.literal.expected) [%ok [[id.actual expected] sub] next] [%bad ~])
53665089 ?: ?=(%atom -.expected)
@@ -5376,17 +5099,11 @@
53765099 =/ u=(unit isub) (itype-unify actual expected sub)
53775100 ?~ u [%bad ~]
53785101 [%ok u.u next]
5379− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5102+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
53805103 ?: ?=(%face -.expected) $(expected body.expected)
5381− ?: &(?=(%collection -.expected) =(%list name.expected) =(0 val.literal.actual))
5382− [%unknown ~]
53835104 ?: ?=(%const -.expected)
53845105 ?:(=(val.literal.actual val.literal.expected) [%ok sub next] [%bad ~])
53855106 ?: ?=(%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 ~]
53905107 ?: |(=(%tas aura.expected) =(%ta aura.expected)) [%ok sub next]
53915108 [%bad ~]
53925109 ?: ?=(%flag -.expected)
@@ -5394,14 +5111,8 @@
53945111 ?: ?=(%any-atom -.expected) [%ok sub next]
53955112 [%bad ~]
53965113 ?: &(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 |)
54035114 ?: ?=(%any-atom -.expected)
5404− ?: |(?=(%atom -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)) ?=(%flag -.actual)) [%ok sub next]
5115+ ?: |(?=(%atom -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%flag -.actual)) [%ok sub next]
54055116 ?: ?=(%var -.actual)
54065117 =/ unified=(unit isub) (itype-unify actual [%avar next] sub)
54075118 ?~ unified [%bad ~]
@@ -5412,16 +5123,16 @@
54125123 =/ unified=(unit isub) (itype-unify actual expected sub)
54135124 ?~ unified [%bad ~]
54145125 [%ok u.unified next]
5415− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5126+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
54165127 [%bad ~]
54175128 ?: &(?=(%atom -.actual) ?=(%atom -.expected))
54185129 ?: (aura-prefix aura.expected aura.actual) [%ok sub next]
54195130 ?: &((aura-prefix aura.actual aura.expected) uncertain) [%unknown ~]
54205131 [%bad ~]
54215132 ?: &(?=(%cell -.actual) ?=(%cell -.expected))
5422− =/ first=ifit $(actual hed.actual, expected hed.expected, skip-width |, spine-proof |)
5133+ =/ first=ifit $(actual hed.actual, expected hed.expected)
54235134 ?. ?=(%ok -.first) first
5424− $(actual tal.actual, expected tal.expected, sub sub.first, next next.first, skip-width spine-checked, spine-proof spine-checked)
5135+ $(actual tal.actual, expected tal.expected, sub sub.first, next next.first)
54255136 :: A field may add a face to an occurrence of the very same type
54265137 :: variable. Binding that variable to a face around itself would fail
54275138 :: the occurs check, but its underlying type has already matched.
@@ -5443,10 +5154,9 @@
54435154 [%ok u.unified next]
54445155 ?: &(?=(%face -.actual) ?=(%face -.expected))
54455156 ?. =(name.actual name.expected) [%bad ~]
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]
5157+ $(actual body.actual, expected body.expected)
5158+ ?: ?=(%face -.actual) $(actual body.actual)
5159+ ?: ?=(%face -.expected) $(expected body.expected)
54505160 ?: (itype-face-asym actual expected sub) [%unknown ~]
54515161 ?: |((itype-has-any-atom actual sub) (itype-has-any-atom expected sub))
54525162 [%unknown ~]
@@ -5516,194 +5226,22 @@
55165226 problems
55175227::
55185228:: The expression inference below is deliberately a fragment: bindings,
5519−:: simple gates, calls, fixed-aura literals, and some interpolated strings. The
5229+:: simple gates, unary calls, fixed-aura literals, and plain strings. The
55205230:: result for unsupported syntax is a diagnostic, never a checked module.
55215231::
55225232+$ ischeme [typ=itype vars=(list @ud)]
55235233+$ ienv (list [name=term scheme=ischeme])
55245234+$ imold-types (list [name=term template=ischeme])
5525−+$ iderived [name=term agent=term mark=term]
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)]
5235++$ ifile [values=ienv molds=imold-types at=path]
55375236+$ ijimports (list [face=term interface=ifile])
5538−+$ icap [name=@t id=@ud at=span]
5539−+$ icaps (list icap)
5237++$ icaps (list [name=@t id=@ud])
55405238+$ iparams (list [name=@t typ=itype])
55415239+$ imolds (list [name=term body=shape])
55425240:: A caller supplies the exact noun returned by +read-mold:jibb-import.
55435241:: This core has no Ford dependencies; unrecognized payloads fail closed.
55445242+$ iexternals (list [module=term name=term result=*])
55455243+$ imark-externals (list [mark=term result=*])
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)])]
5244++$ 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)]
57075245+$ idiag [msg=tape sites=(list [at=span note=tape])]
57085246+$ iresult (each [typ=itype state=istate] idiag)
57095247+$ isample-result (each [typ=itype env=ienv state=istate] tape)
@@ -5723,7 +5261,6 @@
57235261 |= [t=itype sub=isub]
57245262 ^- itype
57255263 =. t (itype-walk t sub)
5726− ?: ?=(%grec -.t) t(args (turn args.t |=(c=itype (itype-normalize c sub))))
57275264 ?: ?=(%collection -.t) [%collection name.t (turn args.t |=(c=itype (itype-normalize c sub)))]
57285265 ?: ?=(%union -.t)
57295266 [%union (turn cases.t |=(c=itype (itype-normalize c sub))) origin.t label.t (turn args.t |=(c=itype (itype-normalize c sub)))]
@@ -5740,8 +5277,6 @@
57405277:: generalize an aura from its sample, which requires constraint analysis
57415278:: beyond this fragment; leave those cases unresolved.
57425279::
5743−:: This helper only controls decimal defaulting in visible types. A noun
5744−:: may contain gates and is not proof of a gate-free value.
57455280++ itype-has-gate
57465281 |= t=itype
57475282 ^- ?
@@ -5749,8 +5284,6 @@
57495284 %fn &
57505285 %cell |($(t hed.t) $(t tal.t))
57515286 %recursive |
5752− %jrec |
5753− %grec &
57545287 %collection (lien args.t |=(c=itype (itype-has-gate c)))
57555288 %face $(t body.t)
57565289 %union (lien cases.t |=(c=itype (itype-has-gate c)))
@@ -5758,13 +5291,10 @@
57585291 %const |
57595292 %var |
57605293 %avar |
5761− %rvar |
57625294 %nvar |
5763− %rnvar |
57645295 %atom |
57655296 %any-atom |
57665297 %flag |
5767− %noun |
57685298 ==
57695299::
57705300++ default-decimals
@@ -5773,135 +5303,26 @@
57735303 ?: (itype-has-gate t) t
57745304 ?- -.t
57755305 %nvar [%atom %ud]
5776− %rnvar [%atom %ud]
5777− %grec t(args (turn args.t |=(c=itype (default-decimals c))))
57785306 %collection [%collection name.t (turn args.t |=(c=itype (default-decimals c)))]
57795307 %face [%face name.t $(t body.t)]
57805308 %cell [%cell $(t hed.t) $(t tal.t)]
57815309 * t
57825310 ==
57835311::
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−::
58865312++ itype-vars
58875313 |= t=itype
58885314 ^- (list @ud)
58895315 ?- -.t
58905316 %var ~[id.t]
58915317 %avar ~[id.t]
5892− %rvar ~[id.t]
58935318 %nvar ~[id.t]
5894− %rnvar ~[id.t]
58955319 %atom ~
58965320 %any-atom ~
58975321 %flag ~
5898− %noun ~
58995322 %tag ~
59005323 %const ~
59015324 %union (zing (turn (weld args.t cases.t) |=(c=itype (itype-vars c))))
59025325 %recursive ~
5903− %jrec ~
5904− %grec (zing (turn args.t |=(c=itype (itype-vars c))))
59055326 %collection (zing (turn args.t |=(c=itype (itype-vars c))))
59065327 %face $(t body.t)
59075328 %fn (weld $(t sample.t) $(t product.t))
@@ -5929,28 +5350,17 @@
59295350 =/ found=(unit itype) (itype-lookup id.t ren)
59305351 ?~ found t
59315352 u.found
5932− %rvar
5933− =/ found=(unit itype) (itype-lookup id.t ren)
5934− ?~ found t
5935− u.found
59365353 %nvar
59375354 =/ found=(unit itype) (itype-lookup id.t ren)
59385355 ?~ found t
59395356 u.found
5940− %rnvar
5941− =/ found=(unit itype) (itype-lookup id.t ren)
5942− ?~ found t
5943− u.found
59445357 %atom t
59455358 %any-atom t
59465359 %flag t
5947− %noun t
59485360 %tag t
59495361 %const t
59505362 %union [%union (turn cases.t |=(c=itype (itype-rename c ren))) origin.t label.t (turn args.t |=(c=itype (itype-rename c ren)))]
59515363 %recursive t
5952− %jrec t
5953− %grec t(args (turn args.t |=(c=itype (itype-rename c ren))))
59545364 %collection [%collection name.t (turn args.t |=(c=itype (itype-rename c ren)))]
59555365 %face [%face name.t $(t body.t)]
59565366 %fn [%fn $(t sample.t) $(t product.t)]
@@ -5966,48 +5376,19 @@
59665376 ?- -.t
59675377 %var |
59685378 %avar =(n id.t)
5969− %rvar =(n id.t)
59705379 %nvar =(n id.t)
5971− %rnvar =(n id.t)
59725380 %atom |
59735381 %any-atom |
59745382 %flag |
5975− %noun |
59765383 %tag |
59775384 %const |
59785385 %union |((lien cases.t |=(c=itype (itype-var-is-atom n c))) (lien args.t |=(c=itype (itype-var-is-atom n c))))
59795386 %recursive |
5980− %jrec |
5981− %grec (lien args.t |=(c=itype (itype-var-is-atom n c)))
59825387 %collection (lien args.t |=(c=itype (itype-var-is-atom n c)))
59835388 %face $(t body.t)
59845389 %fn |($(t sample.t) $(t product.t))
59855390 %cell |($(t hed.t) $(t tal.t))
59865391 ==
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− ==
60115392::
60125393:: Canonical numbering makes printed variables independent of the order
60135394:: the unifier happened to allocate intermediates.
@@ -6019,7 +5400,7 @@
60195400 =/ n=@ud 0
60205401 |-
60215402 ?~ vars (itype-rename t ren)
6022− =/ replacement=itype ?:((itype-var-is-restricted i.vars t) [%rvar n] ?:((itype-var-is-atom i.vars t) [%avar n] [%var n]))
5403+ =/ replacement=itype ?:((itype-var-is-atom i.vars t) [%avar n] [%var n])
60235404 $(vars t.vars, ren [[i.vars replacement] ren], n +(n))
60245405::
60255406++ instantiate-scheme
@@ -6030,11 +5411,11 @@
60305411 |-
60315412 ?~ vars [(itype-rename typ.scheme ren) state]
60325413 =/ replacement=itype
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]))
5414+ ?:((itype-var-is-atom i.vars typ.scheme) [%avar next.state] [%var next.state])
60345415 :: A generalized atom variable is a valid origin for re-generalizing
60355416 :: an alias, just as a sample binder is.
60365417 =/ st=istate state(next +(next.state))
6037− =? binders.st |(?=(%avar -.replacement) ?=(%rvar -.replacement)) [next.state binders.state]
5418+ =? binders.st ?=(%avar -.replacement) [next.state binders.state]
60385419 $(vars t.vars, ren [[i.vars replacement] ren], state st)
60395420::
60405421++ icap-lookup
@@ -6105,11 +5486,6 @@
61055486 ?. ?=([%ref @ @] node) ~
61065487 ?. &(=(module +<.node) =(name +>.node)) ~
61075488 `[[%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]
61135489 %face
61145490 ?. ?=([%face @ *] node) ~
61155491 ?. (jibb-face-name +<.node) ~
@@ -6148,70 +5524,12 @@
61485524 $(pats t.pats)
61495525::
61505526::
6151−::
6152−:: Repeated faces along an imported record spine fail closed. Hoon's type
6153−:: graph can erase unfaced nested-cell boundaries, so that alone does not
6154−:: prove the original source repeated a name within one record. A faced
6155−:: body and each union alternative have separate scopes. Check recursive
6156−:: roots before making them opaque; unused molds are never inspected.
6157−::
6158−++ imported-faces-valid
6159− |= node=*
6160− ^- ?
6161− ?@ node &
6162− ?+ -.node &
6163− %face ?:(?=([%face @ *] node) $(node +>.node) |)
6164− %cell ?:(?=([%cell * *] node) (imported-record-faces-valid node ~) |)
6165− %fork (imported-faces-valid-list +.node)
6166− %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)
6171− ==
6172−::
6173−++ imported-faces-valid-list
6174− |= nodes=*
6175− ^- ?
6176− ?@ nodes =(nodes 0)
6177− ?. (imported-faces-valid -.nodes) |
6178− $(nodes +.nodes)
6179−::
6180−++ imported-record-faces-valid
6181− |= [node=* names=(list @)]
6182− ^- ?
6183− ?: ?=([%cell * *] node)
6184− =/ head=* +<.node
6185− =/ rest=* +>.node
6186− ?: ?=([%face @ *] head)
6187− ?: (lien names |=(n=@ =(n +<.head))) |
6188− ?. (imported-faces-valid +>.head) |
6189− $(node rest, names [+<.head names])
6190− ?. (imported-faces-valid head) |
6191− $(node rest)
6192− ?: ?=([%face @ *] node)
6193− ?: (lien names |=(n=@ =(n +<.node))) |
6194− (imported-faces-valid +>.node)
6195− (imported-faces-valid node)
6196−::
61975527++ import-to-itype
61985528 |= node=*
61995529 ^- (unit itype)
62005530 ?@ node ~
62015531 ?+ -.node ~
6202− %noun ?:(=(node [%noun ~]) `[%noun ~] ~)
62035532 %atom
6204− :: A Hoon loobean singleton is one of the two Jibb loobeans.
6205− ?: ?=([%atom %f [~ @]] node)
6206− =/ value=@ +>+.node
6207− ?. |(=(value 0) =(value 1)) ~
6208− =/ printed=@t ?:(=(value 0) '%.y' '%.n')
6209− `[%const [%loobean %f value printed]]
6210− :: Hoon's null singleton is the same noun as Jibb's `~` mold.
6211− :: Other non-term singleton atoms remain unsupported here.
6212− ?: ?=([%atom %n [~ @]] node)
6213− ?. =(0 +>+.node) ~
6214− `[%const [%null %n 0 '~']]
62155533 ?: ?=([%atom %tas [~ @]] node)
62165534 =/ value=@ +>+.node
62175535 ?. |(=(value 0) (jibb-face-name value)) ~
@@ -6221,15 +5539,6 @@
62215539 =/ aura=@ta (@ta +<.node)
62225540 ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
62235541 `[%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)}")]
62335542 %apply
62345543 ?. ?=([%apply @ *] node) ~
62355544 =/ name=term (@tas +<.node)
@@ -6243,15 +5552,10 @@
62435552 ?. =(arity (lent u.args)) ~
62445553 `[%collection name u.args]
62455554 %fork
6246− :: Hoon's ordinary ? mold is the fork of its two %f singletons.
6247− =/ raw=* +.node
6248− ?: |(=(raw ~[[%atom %f `0] [%atom %f `1]]) =(raw ~[[%atom %f `1] [%atom %f `0]]))
6249− `[%flag ~]
6250− =/ cases=(unit (list itype)) (import-to-itypes raw)
5555+ =/ cases=(unit (list itype)) (import-to-itypes +.node)
62515556 ?~ cases ~
62525557 ?~ u.cases ~
62535558 ?~ t.u.cases ~
6254− ?: (import-has-loobean-singleton u.cases) ~
62555559 ?. (import-cases-disjoint u.cases) ~
62565560 `[%union u.cases ~ ~ ~]
62575561 %face
@@ -6270,20 +5574,6 @@
62705574 `[%cell u.left u.right]
62715575 ==
62725576::
6273−++ import-direct-loobean
6274− |= t=itype
6275− ^- ?
6276− ?: ?=(%face -.t) $(t body.t)
6277− ?: ?=(%union -.t) (import-has-loobean-singleton cases.t)
6278− ?=([%const [%loobean *]] t)
6279−::
6280−++ import-has-loobean-singleton
6281− |= cases=(list itype)
6282− ^- ?
6283− ?~ cases |
6284− ?: (import-direct-loobean i.cases) &
6285− $(cases t.cases)
6286−::
62875577++ import-to-itypes
62885578 |= nodes=*
62895579 ^- (unit (list itype))
@@ -6298,9 +5588,7 @@
62985588 |= typ=itype
62995589 ^- upat
63005590 ?- -.typ
6301− %noun [%all ~]
63025591 %atom [%atom ~]
6303− %flag [%or ~[[%atom `0] [%atom `1]]]
63045592 %const [%atom `val.literal.typ]
63055593 %face $(typ body.typ)
63065594 %cell [%cell $(typ hed.typ) $(typ tal.typ)]
@@ -6328,7 +5616,6 @@
63285616 ?@ result ~
63295617 ?. ?=(%& -.result) ~
63305618 =/ node=* +.result
6331− ?. (imported-faces-valid node) ~
63325619 ?@ node (import-to-itype node)
63335620 ?: ?=(%ref -.node) (import-to-itype node)
63345621 =/ pattern=(unit irec-pattern) (rec-pattern node module name)
@@ -6364,7 +5651,6 @@
63645651 =/ result=* result.i.found
63655652 ?@ result ~
63665653 ?. ?=(%& -.result) ~
6367− ?. (imported-faces-valid +.result) ~
63685654 (import-to-itype +.result)
63695655::
63705656++ find-jibb-interface
@@ -6395,85 +5681,25 @@
63955681 ?:(=(`origin origin.typ.template) `name.i.molds $(molds t.molds))
63965682 $(molds t.molds)
63975683::
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)
6411−++ prelude-union-alias
6412− |= [origin=[at=path name=term] args=(list itype) molds=imold-types]
6413− ^- (unit term)
6414− ?~ molds ~
6415− =/ template=ischeme template.i.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
6423− $(molds t.molds)
6424−::
6425−:: Names exported by the directly imported module are visible through its
6426−:: face; a matching prelude alias is also visible without a qualifier.
6427−::
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
5684+:: Only names exported by this directly imported module are visible through
5685+:: its face. Other origins retain identity but print as unnamed unions.
64455686::
64465687++ itype-in-import
6447− |= [t=itype iface=ifile face=term prelude=(unit ifile)]
5688+ |= [t=itype iface=ifile face=term]
64485689 ^- itype
64495690 ?- -.t
64505691 %union
64515692 =/ label=(unit @t)
64525693 ?~ origin.t ~
64535694 ?: =(at.u.origin.t /lib/jibb/prelude/jibb) `name.u.origin.t
6454− =/ public=(unit term)
6455− ?~ prelude ~
6456− (prelude-union-alias u.origin.t args.t molds.u.prelude)
6457− ?^ public `u.public
64585695 =/ alias=(unit term) ~
64595696 =? alias &(=(at.u.origin.t at.iface) ?=(^ (find-jibb-mold name.u.origin.t iface))) `name.u.origin.t
64605697 =? alias ?=(~ alias) (imported-union-alias u.origin.t molds.iface)
64615698 ?~ alias ~
64625699 `(crip "{(trip u.alias)}.{(trip face)}")
6463− [%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)))]
5700+ [%union (turn cases.t |=(c=itype (itype-in-import c iface face))) origin.t label (turn args.t |=(c=itype (itype-in-import c iface face)))]
64645701 %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)}"))
6476− %collection [%collection name.t (turn args.t |=(c=itype (itype-in-import c iface face prelude)))]
5702+ %collection [%collection name.t (turn args.t |=(c=itype (itype-in-import c iface face)))]
64775703 %face [%face name.t $(t body.t)]
64785704 %fn [%fn $(t sample.t) $(t product.t)]
64795705 %cell [%cell $(t hed.t) $(t tal.t)]
@@ -6546,66 +5772,9 @@
65465772 =/ rest=[params=iparams vars=(list @ud) next=@ud] $(names t.names, next +(next))
65475773 [[[i.names [%var next]] params.rest] [next vars.rest] next.rest]
65485774::
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−
65985775++ infer-mold-template
65995776 |= [sh=shape state=istate]
66005777 ^- (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]
66095778 ?: ?=(%generic -.sh)
66105779 ?~ vars.sh ~
66115780 ?. (distinct-params vars.sh) ~
@@ -6613,130 +5782,28 @@
66135782 =/ out=(unit [typ=itype state=istate])
66145783 (infer-simple-shape body.sh state(next next.fresh, params params.fresh, in-mold &))
66155784 ?~ out ~
6616− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
66175785 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.sh) ?=(~ origin.typ.u.out)) ~
66185786 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.sh))
66195787 typ.u.out(args (turn vars.fresh |=(n=@ud `itype`[%var n])))
66205788 =/ used=(list @ud) (itype-vars typ.u.out)
66215789 ?. (levy used |=(n=@ud (lien vars.fresh |=(p=@ud =(p n))))) ~
6622− `[[typ.u.out vars.fresh] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
5790+ `[[typ.u.out vars.fresh] state.u.out(params params.state, in-mold in-mold.state)]
66235791 =/ out=(unit [typ=itype state=istate])
66245792 (infer-simple-shape sh state(params ~, in-mold &))
66255793 ?~ out ~
6626− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
66275794 ?: ?=(^ (itype-vars typ.u.out)) ~
6628− `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
6629−::
6630−:: A direct imported reference may carry definite reader evidence. Only
6631−:: uniquely supplied, declared inputs are used; unsupported data stay generic.
6632−++ direct-import-invalid
6633− |= [sh=shape state=istate]
6634− ^- (unit idiag)
6635− ?. ?=(%ref -.sh) ~
6636− ?~ names.sh ~
6637− =/ n=term i.names.sh
6638− =/ raw=*
6639− ?~ t.names.sh
6640− ?. (unique-value-name n marks.state) ~
6641− ?: (lien surs.state |=(x=term =(x n))) ~
6642− ?: ?=(^ (find-jibb-interface n jimports.state)) ~
6643− ?: (lien globals.state |=(x=term =(x n))) ~
6644− ?: (lien reserved-molds.state |=(x=term =(x n))) ~
6645− ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) ~
6646− =/ found=imark-externals (skim mark-externals.state |=(e=[mark=term result=*] =(mark.e n)))
6647− ?~ found ~
6648− ?^ t.found ~
6649− result.i.found
6650− ?^ t.t.names.sh ~
6651− =/ mod=term i.t.names.sh
6652− ?: ?=(^ (find-jibb-interface mod jimports.state)) ~
6653− ?. (unique-value-name mod surs.state) ~
6654− ?: (lien marks.state |=(x=term =(x mod))) ~
6655− ?: (lien globals.state |=(x=term =(x mod))) ~
6656− ?: (lien reserved-molds.state |=(x=term =(x mod))) ~
6657− ?: (lien molds.state |=(m=[name=term body=shape] =(mod name.m))) ~
6658− =/ found=iexternals (skim externals.state |=(e=[module=term name=term result=*] &(=(module.e mod) =(name.e n))))
6659− ?~ found ~
6660− ?^ t.found ~
6661− result.i.found
6662− ?. ?=([%invalid ?(%aura %core %overlap) @] raw) ~
6663− `["{(trip +>.raw)}" ~[[at.sh "invalid imported mold"]]]
6664−::
6665−:: Replay only the shape branches whose evaluation order we can prove.
6666−:: Successful prefixes must be checked before descending to a failure.
6667−++ nested-import-invalid
6668− |= [sh=shape state=istate]
6669− ^- (unit idiag)
6670− ?: ?=(^ (infer-simple-shape sh state)) ~
6671− ?- -.sh
6672− %ref
6673− =/ direct=(unit idiag) (direct-import-invalid sh state)
6674− ?^ direct direct
6675− ?~ names.sh ~
6676− ?^ t.names.sh ~
6677− =/ n=term i.names.sh
6678− ?: (lien marks.state |=(x=term =(x n))) ~
6679− ?: (lien active.state |=(x=term =(x n))) ~
6680− =/ found=(unit shape) (find-simple-mold n molds.state)
6681− ?~ found ~
6682− $(sh u.found, state state(active [n active.state], in-mold &, params ~))
6683− %fn
6684− =/ first=(unit [typ=itype state=istate]) (infer-simple-shape sample.sh state)
6685− ?~ first $(sh sample.sh)
6686− $(sh product.sh, state state.u.first)
6687− %cell (nested-field-invalid fields.sh state)
6688− * ~
6689− ==
6690−::
6691−++ nested-field-invalid
6692− |= [fields=(list field) state=istate]
6693− ^- (unit idiag)
6694− ?~ fields ~
6695− =/ sh=shape
6696− ?- -.i.fields
6697− %bare shape.i.fields
6698− %face shape.i.fields
6699− %pun [%ref at.i.fields ~[name.i.fields]]
6700− ==
6701− =/ out=(unit [typ=itype state=istate]) (infer-simple-shape sh state)
6702− ?~ out (nested-import-invalid sh state)
6703− $(fields t.fields, state state.u.out)
6704−::
6705−++ sample-import-invalid
6706− |= [s=sample env=ienv state=istate]
6707− ^- (unit idiag)
6708− =/ result=isample-result (infer-sample s env state)
6709− ?: ?=(%& -.result) ~
6710− ?. =(p.result "sample mold is not supported by partial inference") ~
6711− ?- s
6712− [%face *] (nested-import-invalid shape.s state)
6713− [%bare *] (nested-import-invalid shape.s state)
6714− [%pun *] (nested-import-invalid [%ref at.s ~[name.s]] state)
6715− [%cell *] (nested-samples-invalid items.s env state)
6716− * ~
6717− ==
6718−::
6719−++ nested-samples-invalid
6720− |= [items=(list sample) env=ienv state=istate]
6721− ^- (unit idiag)
6722− ?~ items ~
6723− =/ head=isample-result (infer-sample i.items env state)
6724− ?: ?=(%| -.head) (sample-import-invalid i.items env state)
6725− $(items t.items, env env.p.head, state state.p.head)
5795+ `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state)]
67265796::
67275797++ infer-simple-shape
67285798 |= [sh=shape state=istate]
67295799 ^- (unit [typ=itype state=istate])
67305800 ?- -.sh
6731− %hole `[[%var next.state] state(next +(next.state), holes [[next.state at.sh] holes.state])]
67325801 %aura
67335802 ?: =(0 aura.sh) `[[%any-atom ~] state]
67345803 `[[%atom aura.sh] state]
67355804 %flag `[[%flag ~] state]
6736− %noun `[[%noun ~] state]
67375805 %const
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))) ~
5806+ ?. |(=(%term form.lit.sh) =(%null form.lit.sh)) ~
67405807 `[[%const lit.sh] state]
67415808 %union
67425809 =/ pairs=(list upair) (union-pairs cases.sh molds.state)
@@ -6761,7 +5828,7 @@
67615828 =/ found=(unit ischeme) (find-jibb-mold n u.iface)
67625829 ?~ found ~
67635830 ?^ vars.u.found ~
6764− `[(itype-in-import typ.u.found u.iface i.t.names.sh prelude.state) state]
5831+ `[(itype-in-import typ.u.found u.iface i.t.names.sh) state]
67655832 =/ found=(unit itype)
67665833 (find-imported-mold i.t.names.sh n externals.state surs.state)
67675834 ?~ found ~
@@ -6780,13 +5847,10 @@
67805847 ?~ prelude-entry ~
67815848 ?^ vars.u.prelude-entry ~
67825849 `[typ.u.prelude-entry state]
6783− =/ direct=(unit itype) (simple-source-recursive n u.found state)
6784− ?^ direct `[u.direct state]
67855850 =/ out=(unit [typ=itype state=istate])
67865851 $(sh u.found, state state(active [n active.state], in-mold &, params ~))
67875852 ?~ out ~
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)]
5853+ `[(label-direct-union typ.u.out u.found n state) state.u.out(active active.state, in-mold in-mold.state, params params.state)]
67905854 %apply
67915855 ?~ ref.sh ~
67925856 =/ args=(unit [types=(list itype) state=istate]) (infer-shape-args args.sh state)
@@ -6801,7 +5865,7 @@
68015865 ?~ vars.u.template ~
68025866 =/ applied=(unit itype) (template-apply u.template types.u.args)
68035867 ?~ applied ~
6804− `[(itype-in-import u.applied u.iface i.t.ref.sh prelude.state.u.args) state.u.args]
5868+ `[(itype-in-import u.applied u.iface i.t.ref.sh) state.u.args]
68055869 ?: (lien active.state.u.args |=(x=term =(x n))) ~
68065870 =/ found=(unit shape) (find-simple-mold n molds.state.u.args)
68075871 ?~ found
@@ -6814,27 +5878,24 @@
68145878 ?~ applied ~
68155879 `[u.applied state.u.args]
68165880 ?. ?=(%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]
68195881 ?. (distinct-params vars.u.found) ~
68205882 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
68215883 ?~ params ~
68225884 =/ out=(unit [typ=itype state=istate])
68235885 $(sh body.u.found, state state.u.args(active [n active.state.u.args], in-mold &, params u.params))
68245886 ?~ out ~
6825− ?^ (unresolved-hole holes.state.u.out holes.state.u.args state.u.out) ~
68265887 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.u.found) ?=(~ origin.typ.u.out)) ~
68275888 ?: &(?=(%union -.typ.u.out) ?=(%union -.body.u.found) !(lien top-molds.state.u.args |=(x=term =(x n)))) ~
68285889 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.u.found))
68295890 (label-direct-union typ.u.out(args types.u.args) u.found n 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)]
5891+ `[typ.u.out state.u.out(active active.state.u.args, in-mold in-mold.state.u.args, params params.state.u.args)]
68315892 %tvar
68325893 =/ param=(unit itype) (iparam-lookup name.sh params.state)
68335894 ?^ param `[u.param state]
68345895 ?: in-mold.state ~
68355896 =/ n=(unit @ud) (icap-lookup name.sh caps.state)
68365897 ?^ n `[[%var u.n] state]
6837− `[[%var next.state] state(next +(next.state), caps [[name.sh next.state at.sh] caps.state])]
5898+ `[[%var next.state] state(next +(next.state), caps [[name.sh next.state] caps.state])]
68385899 * ~
68395900 ==
68405901::
@@ -6867,12 +5928,12 @@
68675928 ^- isample-result
68685929 ?- -.s
68695930 %bind
6870− ?: |(=(name.s %proj) ?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
5931+ ?: |(?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
68715932 [%| "sample shadows a name"]
68725933 =/ t=itype [%var next.state]
68735934 [%& t [[name.s [t ~]] env] state(next +(next.state), binders [next.state binders.state])]
68745935 %face
6875− ?: |(=(name.s %proj) ?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
5936+ ?: |(?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
68765937 [%| "sample shadows a name"]
68775938 =/ t=(unit [typ=itype state=istate]) (infer-simple-shape shape.s state)
68785939 ?~ t [%| "sample mold is not supported by partial inference"]
@@ -6910,8 +5971,8 @@
69105971 [%& [%cell ht typ.p.tail] env.p.tail state.p.tail]
69115972::
69125973:: Local definitions generalize only variables outside their enclosing
6913−:: environment and explicit-capital scope. Recursive gate groups use
6914−:: monomorphic placeholders while their bodies are checked.
5974+:: environment and explicit-capital scope. Unresolved groups stay
5975+:: unsupported: this fragment does not infer recursive definitions.
69155976::
69165977+$ ilocal-result (each [env=ienv state=istate] idiag)
69175978++ free-env-vars
@@ -6940,7 +6001,6 @@
69406001 |-
69416002 ?~ ds &
69426003 ?: ?=(%mold -.i.ds) $(ds t.ds)
6943− ?: =(name.i.ds %proj) |
69446004 ?. (unique-value-name name.i.ds names) |
69456005 ?: ?=(^ (ienv-lookup name.i.ds env)) |
69466006 ?: (lien globals.state |=(n=term =(n name.i.ds))) |
@@ -6964,7 +6024,6 @@
69646024 |-
69656025 ?~ locals &
69666026 =/ n=term name.i.locals
6967− ?: =(n %proj) |
69686027 ?. (unique-value-name n names) |
69696028 ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) |
69706029 ?: (lien marks.state |=(m=term =(n m))) |
@@ -6982,145 +6041,6 @@
69826041 ?~ inferred |
69836042 $(locals t.locals)
69846043::
6985−:: Gather written capitals belonging to one ++. Nested local definitions
6986−:: establish their own scopes; inline gates remain in the enclosing scope.
6987−+$ icap-site [name=@t at=span]
6988−++ scope-shape
6989− |= s=shape
6990− ^- (list icap-site)
6991− ?- -.s
6992− %tvar ~[[name.s at.s]]
6993− %apply (zing (turn args.s scope-shape))
6994− %cell (zing (turn fields.s scope-field))
6995− %union (zing (turn cases.s scope-shape))
6996− %fn (weld (scope-shape sample.s) (scope-shape product.s))
6997− %generic
6998− =/ inside=(list icap-site) (scope-shape body.s)
6999− (skim inside |=(site=icap-site !(lien vars.s |=(v=@t =(v name.site)))))
7000− * ~
7001− ==
7002−::
7003−++ scope-field
7004− |= f=field
7005− ^- (list icap-site)
7006− ?- -.f
7007− %face (scope-shape shape.f)
7008− %bare (scope-shape shape.f)
7009− %pun ~
7010− ==
7011−::
7012−++ scope-sample
7013− |= s=sample
7014− ^- (list icap-site)
7015− ?- -.s
7016− %face (scope-shape shape.s)
7017− %bare (scope-shape shape.s)
7018− %cell (zing (turn items.s scope-sample))
7019− * ~
7020− ==
7021−::
7022−++ scope-pieces
7023− |= ps=(list piece)
7024− ^- (list icap-site)
7025− ?~ ps ~
7026− =/ first=(list icap-site)
7027− ?- -.i.ps
7028− %expr (scope-expr p.i.ps)
7029− %text ~
7030− ==
7031− (weld first $(ps t.ps))
7032−::
7033−++ scope-qsegs
7034− |= ps=(list qseg)
7035− ^- (list icap-site)
7036− ?~ ps ~
7037− =/ first=(list icap-site)
7038− ?- -.i.ps
7039− %expr (scope-expr p.i.ps)
7040− %knot ~
7041− ==
7042− (weld first $(ps t.ps))
7043−::
7044−++ scope-edits
7045− |= xs=(list edit)
7046− ^- (list icap-site)
7047− ?~ xs ~
7048− =/ first=(list icap-site) (scope-expr val.i.xs)
7049− (weld first $(xs t.xs))
7050−::
7051−++ scope-items
7052− |= xs=(list item)
7053− ^- (list icap-site)
7054− ?~ xs ~
7055− =/ first=(list icap-site) (scope-expr val.i.xs)
7056− (weld first $(xs t.xs))
7057−::
7058−++ scope-arms
7059− |= xs=(list arm)
7060− ^- (list icap-site)
7061− ?~ xs ~
7062− =/ first=(list icap-site) (scope-expr val.i.xs)
7063− (weld first $(xs t.xs))
7064−::
7065−++ scope-exprs
7066− |= xs=(list expr)
7067− ^- (list icap-site)
7068− ?~ xs ~
7069− =/ first=(list icap-site) (scope-expr i.xs)
7070− (weld first $(xs t.xs))
7071−::
7072−++ scope-expr
7073− |= e=expr
7074− ^- (list icap-site)
7075− ?- -.e
7076− %str (scope-pieces pieces.e)
7077− %qath (scope-qsegs segs.e)
7078− %change (scope-edits edits.e)
7079− %pair (scope-expr val.e)
7080− %unit (scope-expr val.e)
7081− %group (scope-expr inner.e)
7082− %list (scope-exprs items.e)
7083− %tuple (scope-items items.e)
7084− %gate
7085− =/ first=(list icap-site) (scope-sample sample.e)
7086− =/ last=(list icap-site) (scope-expr body.e)
7087− (weld first last)
7088− %gate-wide
7089− =/ first=(list icap-site) (scope-sample sample.e)
7090− =/ last=(list icap-site) (scope-expr body.e)
7091− (weld first last)
7092− %call
7093− =/ first=(list icap-site) (scope-expr head.e)
7094− =/ last=(list icap-site) (scope-exprs args.e)
7095− (weld first last)
7096− %cast
7097− =/ first=(list icap-site) (scope-shape shape.e)
7098− =/ last=(list icap-site) (scope-expr val.e)
7099− (weld first last)
7100− %trace
7101− =/ first=(list icap-site) (scope-expr val.e)
7102− =/ last=(list icap-site) (scope-expr then.e)
7103− (weld first last)
7104− %branch
7105− =/ first=(list icap-site) (scope-expr subject.e)
7106− =/ last=(list icap-site) (scope-arms arms.e)
7107− (weld first last)
7108− %body (scope-expr final.e)
7109− * ~
7110− ==
7111−::
7112−++ reserve-cap-sites
7113− |= [sites=(list icap-site) state=istate]
7114− ^- istate
7115− ?~ sites state
7116− ?: ?=(^ (icap-lookup name.i.sites caps.state)) $(sites t.sites)
7117− $(sites t.sites, state state(next +(next.state), caps [[name.i.sites next.state at.i.sites] caps.state]))
7118−::
7119−++ reserve-def-caps
7120− |= [e=expr state=istate]
7121− ^- istate
7122− (reserve-cap-sites (scope-expr e) state)
7123−::
71246044++ infer-local-defs
71256045 |= [ds=(list def) env=ienv state=istate]
71266046 ^- ilocal-result
@@ -7129,66 +6049,26 @@
71296049 |-
71306050 ?~ ds
71316051 ?~ remaining [%& env state]
7132− ?. progressed
7133− =/ pending=(list def) (flop remaining)
7134− =/ groups=icomponents (graph-components pending (global-value-names pending))
7135− =/ grouped=(unit [rest=(list def) env=ienv state=istate])
7136− (try-local-group pending groups env state)
7137− ?~ grouped [%| ["local definitions need unsupported inference" ~]]
7138− $(ds rest.u.grouped, remaining ~, env env.u.grouped, state state.u.grouped, progressed |)
6052+ ?. progressed [%| ["local definitions need unsupported inference" ~]]
71396053 $(ds (flop remaining), remaining ~, progressed |)
71406054 =/ d=def i.ds
71416055 ?> ?=(%value -.d)
7142− =/ local-state=istate (reserve-def-caps val.d state)
7143− =/ inferred=iresult (infer-fragment val.d env local-state)
7144− =/ retried=? ?=(%| -.inferred)
7145− =? inferred retried (infer-recursive-gate d env local-state)
6056+ =/ inferred=iresult (infer-fragment val.d env state)
71466057 ?: ?=(%| -.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]
7151− =/ merged=(unit [first=icap second=icap])
7152− (merged-capitals caps.state.p.inferred sub.state.p.inferred)
7153− ?^ merged
7154− [%| ["distinct type variables `{(trip name.first.u.merged)}` and `{(trip name.second.u.merged)}` must not be forced equal; use the same capital for a shared type" ~[[at.first.u.merged "first type variable"] [at.second.u.merged "second type variable"]]]]
7155− ?: (constrained-capitals caps.state.p.inferred sub.state.p.inferred)
7156− [%| ["explicit capital constraints are not supported by partial inference" ~]]
71576058 =/ typ=itype (itype-normalize typ.p.inferred sub.state.p.inferred)
71586059 ?: |((pending-tags tags.state.p.inferred sub.state.p.inferred) (itype-has-tag typ))
71596060 $(ds t.ds, remaining [d remaining])
71606061 ?: (unsupported-atom-vars typ caps.state.p.inferred binders.state.p.inferred sub.state.p.inferred)
71616062 $(ds t.ds, remaining [d remaining])
71626063 =/ free=(list @ud)
7163− (weld (free-env-vars env sub.state.p.inferred) (free-cap-vars caps.state sub.state.p.inferred))
6064+ (weld (free-env-vars env sub.state.p.inferred) (free-cap-vars caps.state.p.inferred sub.state.p.inferred))
71646065 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
71656066 =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
7166− $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred(caps caps.state, holes holes.state), progressed &)
7167−::
7168−:: Try complete cyclic local groups after individual definitions stall.
7169−:: Components with non-gates or unresolved constraints stay unavailable.
7170−::
7171−++ try-local-group
7172− |= [ds=(list def) groups=icomponents env=ienv state=istate]
7173− ^- (unit [rest=(list def) env=ienv state=istate])
7174− ?~ groups ~
7175− =/ names=(list term) i.groups
7176− ?. (gth (lent names) 1) $(groups t.groups)
7177− =/ members=(list def)
7178− (skim ds |=(d=def &(?=(%value -.d) (lien names |=(n=term =(n name.d))))))
7179− ?. =((lent members) (lent names)) $(groups t.groups)
7180− =/ result=ilocal-result (infer-gate-group members env state)
7181− ?: ?=(%| -.result) $(groups t.groups)
7182− =/ rest=(list def)
7183− (skim ds |=(d=def !(lien names |=(n=term =(n name.d)))))
7184− =/ more=(unit [rest=(list def) env=ienv state=istate])
7185− $(ds rest, groups t.groups, env env.p.result, state state.p.result)
7186− ?^ more more
7187− `[rest env.p.result state.p.result]
6067+ $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred, progressed &)
71886068::
71896069:: Read only fields of a known record. Unresolved field constraints and
7190−:: ambiguous repeated faces are outside this fragment. Imported record
7191−:: spines with repeated names are unavailable when used.
6070+:: ambiguous repeated faces are outside this fragment (doc question:
6071+:: whether duplicate imported Hoon faces are valid or select a field).
71926072::
71936073++ record-fields-named
71946074 |= [name=term t=itype sub=isub]
@@ -7207,33 +6087,21 @@
72076087 ^- iresult
72086088 =/ reverse=(list term) (flop names)
72096089 ?~ reverse [%| ["empty wing" ~]]
7210− =/ iface=(unit ifile) (find-jibb-interface i.reverse jimports.state)
6090+ =/ scheme=(unit ischeme) (ienv-lookup i.reverse env)
6091+ ?~ scheme [%| ["field access is not supported by partial inference" ~]]
6092+ =/ inst=[typ=itype state=istate] (instantiate-scheme u.scheme state)
72116093 =/ fields=(list term) t.reverse
7212− ?~ fields [%| ["field access is not supported by partial inference" ~]]
7213− =/ scheme=(unit ischeme)
7214− ?~ iface
7215− (ienv-lookup i.reverse env)
7216− (ienv-lookup i.fields values.u.iface)
7217− ?~ scheme
7218− ?^ iface [%| ["module member is not available to partial inference" ~]]
7219− [%| ["field access is not supported by partial inference" ~]]
7220− =/ inst=[typ=itype state=istate]
7221− ?~ iface (instantiate-scheme u.scheme state)
7222− =/ imported=ischeme u.scheme
7223− =. typ.imported (itype-in-import typ.imported u.iface i.reverse prelude.state)
7224− (instantiate-scheme imported state)
7225− =/ remaining=(list term) ?~(iface fields t.fields)
72266094 =/ typ=itype typ.inst
72276095 |-
7228− ?~ remaining [%& typ state.inst]
7229− =/ found=(list itype) (record-fields-named i.remaining typ sub.state.inst)
6096+ ?~ fields [%& typ state.inst]
6097+ =/ found=(list itype) (record-fields-named i.fields typ sub.state.inst)
72306098 ?~ found [%| ["field is not available to partial inference" ~]]
72316099 ?^ t.found [%| ["field name is ambiguous in partial inference" ~]]
7232− $(remaining t.remaining, typ i.found)
6100+ $(fields t.fields, typ i.found)
72336101::
7234−:: Propagate a known union or list through supported loobean, unit and list
7235−:: branches. Empty bodies and groups are transparent; bodies with definitions
7236−:: keep their normal scoping and wait for general bidirectional inference.
6102+:: Propagate a known union through supported loobean and unit branches. Empty bodies
6103+:: and groups are transparent; bodies with definitions keep their normal
6104+:: scoping and wait for general bidirectional inference.
72376105::
72386106++ context-union-branch
72396107 |= e=expr
@@ -7250,8 +6118,6 @@
72506118 ^- iresult
72516119 ?: ?=(%group -.e) $(e inner.e)
72526120 ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
7253− ?: &(?=(%collection -.expected) =(%list name.expected) (context-list-expression e))
7254− (infer-list-context e expected env state context)
72556121 ?: ?=(%branch -.e)
72566122 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
72576123 ?~ t.arms.e [%| ["branch pattern is not supported by partial inference" ~]]
@@ -7268,9 +6134,6 @@
72686134 [%| ["branch does not cover both loobeans" ~]]
72696135 =/ subject=iresult (infer-fragment subject.e env state)
72706136 ?: ?=(%| -.subject) subject
7271− =/ subject-type=itype (itype-normalize typ.p.subject sub.state.p.subject)
7272− ?: ?=(%union -.subject-type)
7273− [%| ["contextual union-pattern branch is not supported by partial inference" ~]]
72746137 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
72756138 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
72766139 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
@@ -7282,33 +6145,20 @@
72826145 ?: ?=(%| -.value) value
72836146 =/ fit=ifit (itype-fit typ.p.value expected sub.state.p.value next.state.p.value)
72846147 ?: ?=(%unknown -.fit)
7285− ?: &(?=(%collection -.expected) =(%list name.expected))
7286− [%| ["branch list constraint is not supported by partial inference" ~]]
7287− ?: ?=(%flag -.expected) [%| ["branch loobean constraint is not supported by partial inference" ~]]
72886148 [%| ["branch union constraint is not supported by partial inference" ~]]
72896149 ?: ?=(%bad -.fit)
7290− =/ missing=(unit idiag) (missing-union-tag e expected sub.state.p.value context)
7291− ?^ missing [%| u.missing]
7292− =/ nested=(unit idiag) (nested-missing-tag e typ.p.value expected sub.state.p.value next.state.p.value context)
7293− ?^ nested [%| u.nested]
7294− ?: &(?=(%collection -.expected) =(%list name.expected))
7295− [%| ["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"]]]]
72986150 [%| ["branch arm does not fit its expected union" ~[[context "expected union"] [(span-of e) "branch arm"]]]]
72996151 [%& expected state.p.value(sub sub.fit, next next.fit)]
73006152::
7301−:: A list expression needs a known list target and the validated prelude list.
7302−:: Literal items and unfaced two-item cons cells receive that target one by
7303−:: one; pending constraints elsewhere stay in the threaded state.
6153+:: A list literal needs a known list target and the validated prelude list.
6154+:: Its items receive that target one by one; pending constraints elsewhere
6155+:: stay in the threaded state. Other list syntax remains unsupported.
73046156::
7305−++ context-list-expression
6157+++ context-list-literal
73066158 |= e=expr
73076159 ^- ?
73086160 ?- -.e
73096161 %list &
7310− %tuple &
7311− %lit |(=(%null form.lit.e) &(=(%term form.lit.e) =(0 val.lit.e)))
73126162 %group $(e inner.e)
73136163 %body ?~(defs.e $(e final.e) |)
73146164 * |
@@ -7319,6 +6169,7 @@
73196169 ^- iresult
73206170 ?: ?=(%group -.e) $(e inner.e)
73216171 ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
6172+ ?> ?=(%list -.e)
73226173 ?~ prelude.state [%| ["list literal needs the standard prelude in partial inference" ~]]
73236174 ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
73246175 [%| ["list literal needs the standard prelude in partial inference" ~]]
@@ -7331,65 +6182,25 @@
73316182 ?. =(%list name.target) [%| ["list context is not supported by partial inference" ~]]
73326183 ?~ args.target [%| ["list context is not supported by partial inference" ~]]
73336184 ?^ t.args.target [%| ["list context is not supported by partial inference" ~]]
7334− ?: ?=(%lit -.e)
7335− ?. |(=(%null form.lit.e) &(=(%term form.lit.e) =(0 val.lit.e)))
7336− [%| ["list expression is not supported by partial inference" ~]]
7337− [%& target state]
7338− ?: ?=(%list -.e)
7339− =/ result=iresult (infer-list-items items.e i.args.target env state context)
7340− ?: ?=(%| -.result) result
7341− [%& target state.p.result]
7342− ?. ?=(%tuple -.e) [%| ["list expression is not supported by partial inference" ~]]
7343− ?~ items.e [%| ["cons shape is not supported by partial inference" ~]]
7344− ?~ t.items.e [%| ["cons shape is not supported by partial inference" ~]]
7345− ?^ t.t.items.e [%| ["cons shape is not supported by partial inference" ~]]
7346− ?^ face.i.items.e [%| ["faced cons is not supported by partial inference" ~]]
7347− ?^ face.i.t.items.e [%| ["faced cons is not supported by partial inference" ~]]
7348− =/ head=iresult (infer-list-items ~[val.i.items.e] i.args.target env state context)
7349− ?: ?=(%| -.head) head
7350− =/ target=itype (itype-walk target sub.state.p.head)
7351− =/ tail=iresult
7352− ?: (context-list-expression val.i.t.items.e)
7353− (infer-list-context val.i.t.items.e target env state.p.head context)
7354− (infer-fragment val.i.t.items.e env state.p.head)
7355− ?: ?=(%| -.tail) tail
7356− =/ fit=ifit (itype-fit typ.p.tail target sub.state.p.tail next.state.p.tail)
7357− ?: ?=(%unknown -.fit) [%| ["list tail constraint is not supported by partial inference" ~]]
7358− ?: ?=(%bad -.fit)
7359− [%| ["list tail does not fit its expected type" ~[[context (site-type-note "expected list" target sub.state.p.tail)] [(span-of val.i.t.items.e) (site-type-note "list tail" typ.p.tail sub.state.p.tail)]]]]
7360− [%& target state.p.tail(sub sub.fit, next next.fit)]
7361−::
7362−++ infer-open-list-items
7363− |= [items=(list expr) expected=itype env=ienv state=istate context=span]
7364− ^- iresult
7365− ?~ items [%& expected state]
7366− =/ target=itype (itype-walk expected sub.state)
7367− =/ value=iresult (infer-call-context-arg i.items target env state context)
7368− ?: ?=(%| -.value) value
7369− =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
7370− ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
7371− ?: ?=(%bad -.fit)
7372− ?: |((itype-family-related typ.p.value target sub.state.p.value) (itype-has-any-atom typ.p.value sub.state.p.value) (itype-has-any-atom target sub.state.p.value))
7373− [%| ["list item widening is not supported by partial inference" ~]]
7374− [%| ["list items do not have compatible types" ~[[context (site-type-note "expected item" target sub.state.p.value)] [(span-of i.items) (site-type-note "list item" typ.p.value sub.state.p.value)]]]]
7375− ?: (itype-has-tag (itype-normalize expected sub.fit))
7376− [%| ["list item needs context in partial inference" ~]]
7377− $(items t.items, state state.p.value(sub sub.fit, next next.fit))
6185+ =/ result=iresult (infer-list-items items.e i.args.target env state context)
6186+ ?: ?=(%| -.result) result
6187+ [%& target state.p.result]
73786188::
73796189++ infer-list-items
73806190 |= [items=(list expr) expected=itype env=ienv state=istate context=span]
73816191 ^- iresult
73826192 ?~ items [%& expected state]
73836193 =/ target=itype (itype-walk expected sub.state)
7384− =/ value=iresult (infer-call-context-arg i.items target env state context)
6194+ =/ value=iresult
6195+ ?: &(?=(%union -.target) (context-union-branch i.items))
6196+ (infer-union-context i.items target env state context)
6197+ ?: &(?=(%collection -.target) =(%list name.target) (context-list-literal i.items))
6198+ (infer-list-context i.items target env state context)
6199+ (infer-fragment i.items env state)
73856200 ?: ?=(%| -.value) value
73866201 =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
73876202 ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
73886203 ?: ?=(%bad -.fit)
7389− =/ missing=(unit idiag) (missing-union-tag i.items target sub.state.p.value context)
7390− ?^ missing [%| u.missing]
7391− =/ nested=(unit idiag) (nested-missing-tag i.items typ.p.value target sub.state.p.value next.state.p.value context)
7392− ?^ nested [%| u.nested]
73936204 [%| ["list item does not fit its expected type" ~[[context (site-type-note "expected item" target sub.state.p.value)] [(span-of i.items) (site-type-note "list item" typ.p.value sub.state.p.value)]]]]
73946205 $(items t.items, state state.p.value(sub sub.fit, next next.fit))
73956206::
@@ -7482,7 +6293,7 @@
74826293 [%| ["list branch pattern is not supported by partial inference" ~]]
74836294 =/ binder=(unit [head=term tail=term]) ?:(first-empty second-name first-name)
74846295 ?~ binder [%| ["list branch pattern is not supported by partial inference" ~]]
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)))))
6296+ ?: |(=(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)))))
74866297 [%| ["pattern binder shadows a name" ~]]
74876298 =/ extended=ienv [[head.u.binder [i.args.typ ~]] [tail.u.binder [typ ~]] env]
74886299 =/ left=iresult
@@ -7519,7 +6330,7 @@
75196330 [%| ["unit branch pattern is not supported by partial inference" ~]]
75206331 =/ binder=(unit term) ?:(first-empty second-name first-name)
75216332 ?~ binder [%| ["unit branch pattern is not supported by partial inference" ~]]
7522− ?: |(=(u.binder %proj) ?=(^ (ienv-lookup u.binder env)) (lien globals.state |=(n=term =(n u.binder))))
6333+ ?: |(?=(^ (ienv-lookup u.binder env)) (lien globals.state |=(n=term =(n u.binder))))
75236334 [%| ["pattern binder shadows a name" ~]]
75246335 =/ payload=(unit itype) (unit-union-payload typ)
75256336 ?~ payload [%| ["unit branch subject is not supported by partial inference" ~]]
@@ -7537,628 +6348,10 @@
75376348 ?~ joined [%| ["unit branch results need unsupported inference" ~]]
75386349 [%& typ.p.left state.p.right(sub u.joined)]
75396350::
7540−:: Infer pieces in order, retaining their substitutions and pending tags.
7541−:: A bare decimal literal has no outside type constraint, so it takes its
7542−:: normal @ud default here. Other open numeric and aura variables wait for
7543−:: deferred constraints, which this fragment does not implement yet.
7544−++ infer-string-pieces
7545− |= [ps=(list piece) env=ienv state=istate]
6351+++ infer-fragment
6352+ |= [e=expr env=ienv state=istate]
75466353 ^- iresult
7547− ?~ ps [%& [%atom %t] state]
7548− ?: ?=(%text -.i.ps) $(ps t.ps)
7549− =/ item=iresult (infer-fragment p.i.ps env state)
7550− ?: ?=(%| -.item) item
7551− =/ t=itype (itype-normalize typ.p.item sub.state.p.item)
7552− ?: |(?=(%atom -.t) ?=(%any-atom -.t))
7553− $(ps t.ps, state state.p.item)
7554− ?: &(|(?=(%nvar -.t) ?=(%rnvar -.t)) ?=(%lit -.p.i.ps) =(%number form.lit.p.i.ps))
7555− $(ps t.ps, state state.p.item)
7556− ?: &(?=(%collection -.t) =(%list name.t) =(~[[%atom 'tD']] args.t))
7557− $(ps t.ps, state state.p.item)
7558− ?: &(?=(%avar -.t) (atom-var-from-cap id.t caps.state.p.item sub.state.p.item))
7559− [%| ["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"]]]]
7562− ?: ?=(%cell -.t)
7563− [%| ["a cell in interpolation needs a printer" ~[[(span-of p.i.ps) "cell without a printer"]]]]
7564− [%| ["interpolation type needs unsupported inference" ~]]
7565−::
7566−:: Whole-case coverage for a known union. When a pattern may cover only
7567−:: part of a case, finite loobean refinements are tried below; other
7568−:: partial coverage stays unsupported until the general pattern matrix.
7569−+$ imatch ?(%full %none %unknown)
7570−++ union-pattern-items
7571− |= [ps=(list pattern) t=itype]
7572− ^- imatch
7573− ?~ ps %unknown
7574− ?~ t.ps (union-pattern i.ps t)
7575− =. t ?:(?=(%face -.t) body.t t)
7576− ?. ?=(%cell -.t)
7577− ?: |(?=(%atom -.t) ?=(%any-atom -.t) ?=(%flag -.t) ?=(%const -.t)) %none
7578− %unknown
7579− =/ a=imatch (union-pattern i.ps hed.t)
7580− =/ b=imatch $(ps t.ps, t tal.t)
7581− ?: |(=(%none a) =(%none b)) %none
7582− ?:(&(=(%full a) =(%full b)) %full %unknown)
7583−::
7584−++ union-pattern
7585− |= [p=pattern t=itype]
7586− ^- imatch
7587− =. t ?:(?=(%face -.t) body.t t)
7588− ?- -.p
7589− %any %full
7590− %bind %full
7591− %lit
7592− ?: ?=(%const -.t) ?:(=(val.literal.t val.lit.p) %full %none)
7593− ?: ?=(%cell -.t) %none
7594− ?: ?=(%flag -.t)
7595− ?:(|(=(0 val.lit.p) =(1 val.lit.p)) %unknown %none)
7596− %unknown
7597− %str ?:(?=(%cell -.t) %none %unknown)
7598− %cell (union-pattern-items items.p t)
7599− ==
7600−::
7601−++ union-pattern-has-bind
7602− |= p=pattern
7603− ^- ?
7604− ?: ?=(%bind -.p) &
7605− ?. ?=(%cell -.p) |
7606− (lien items.p union-pattern-has-bind)
7607−::
7608−++ union-pattern-bind-items
7609− |= [ps=(list pattern) t=itype env=ienv globals=(list term)]
7610− ^- (unit ienv)
7611− ?~ ps ~
7612− ?~ t.ps (union-pattern-bind i.ps t env globals)
7613− =. t ?:(?=(%face -.t) body.t t)
7614− ?. ?=(%cell -.t) ~
7615− =/ first=(unit ienv) (union-pattern-bind i.ps hed.t env globals)
7616− ?~ first ~
7617− $(ps t.ps, t tal.t, env u.first)
7618−::
7619−++ union-pattern-bind
7620− |= [p=pattern t=itype env=ienv globals=(list term)]
7621− ^- (unit ienv)
7622− =. t ?:(?=(%face -.t) body.t t)
7623− ?: ?=(%bind -.p)
7624− ?: |(=(name.p %proj) ?=(^ (ienv-lookup name.p env)) (lien globals |=(n=term =(n name.p)))) ~
7625− `[[name.p [t ~]] env]
7626− ?: ?=(%cell -.p) (union-pattern-bind-items items.p t env globals)
7627− `env
7628−::
7629−:: Split loobean fields into finite refinements for partial patterns.
7630−:: Keep original cases for binder types and preserve whole-case matching
7631−:: before trying refinements. Cap products at 64; unknown, empty or opaque
7632−:: shapes stay unsupported rather than implying complete pattern checking.
7633−+$ ifinite [origin=@ud base=itype part=itype]
7634−++ finite-product
7635− |= [hs=(list itype) ts=(list itype) out=(list itype)]
7636− ^- (list itype)
7637− ?~ hs out
7638− =/ rows=(list itype) (turn ts |=(t=itype [%cell i.hs t]))
7639− $(hs t.hs, out (weld rows out))
7640−::
7641−++ finite-type
7642− |= t=itype
7643− ^- (unit (list itype))
7644− ?- -.t
7645− %flag
7646− `~[[%const [%loobean %f 0 '%.y']] [%const [%loobean %f 1 '%.n']]]
7647− %face
7648− =/ body=(unit (list itype)) $(t body.t)
7649− ?~ body ~
7650− `(turn u.body |=(x=itype [%face name.t x]))
7651− %cell
7652− =/ hed=(unit (list itype)) $(t hed.t)
7653− ?~ hed ~
7654− =/ tal=(unit (list itype)) $(t tal.t)
7655− ?~ tal ~
7656− ?: (gth (mul (lent u.hed) (lent u.tal)) 64) ~
7657− `(finite-product u.hed u.tal ~)
7658− * `~[t]
7659− ==
7660−::
7661−++ finite-cases
7662− |= [xs=(list itype) out=(list ifinite) origin=@ud]
7663− ^- (unit (list ifinite))
7664− ?~ xs `out
7665− =/ parts=(unit (list itype)) (finite-type i.xs)
7666− ?~ parts ~
7667− ?: (gth (add (lent out) (lent u.parts)) 64) ~
7668− =/ rows=(list ifinite) (turn u.parts |=(t=itype [origin i.xs t]))
7669− $(xs t.xs, out (weld out rows), origin +(origin))
7670−::
7671−++ infer-known-union-whole
7672− |= [e=expr env=ienv subject=iresult]
7673− ^- (unit iresult)
7674− ?> ?=(%branch -.e)
7675− ?: ?=(%| -.subject) `subject
7676− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7677− ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
7678− =/ cases=(list itype) cases.typ
7679− =/ remaining=(list itype) cases
7680− =/ arms=(list arm) arms.e
7681− =/ st=istate state.p.subject
7682− =/ answer=(unit itype) ~
7683− |-
7684− ?~ arms
7685− ?^ remaining
7686− `[%| ["missing union case {(show-itype i.remaining sub.st)}" ~]]
7687− ?~ answer `[%| ["empty union branch is not supported by partial inference" ~]]
7688− `[%& u.answer st]
7689− =/ a=arm i.arms
7690− ?: (lien remaining |=(c=itype =(%unknown (union-pattern pat.a c))))
7691− ~
7692− =/ matching=(list itype) (skim remaining |=(c=itype =(%full (union-pattern pat.a c))))
7693− ?~ matching
7694− ?: (lien cases |=(c=itype =(%full (union-pattern pat.a c))))
7695− `[%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7696− `[%| ["union pattern is not supported by partial inference" ~]]
7697− ?: &(?=(^ t.matching) (union-pattern-has-bind pat.a))
7698− `[%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7699− =/ bound=(unit ienv) (union-pattern-bind pat.a i.matching env globals.st)
7700− ?~ bound `[%| ["pattern binder shadows a name" ~]]
7701− =/ body=iresult (infer-fragment val.a u.bound st)
7702− ?: ?=(%| -.body) `body
7703− =/ result=itype (itype-normalize typ.p.body sub.state.p.body)
7704− =/ mismatch=? ?~(answer | !=((itype-normalize u.answer sub.state.p.body) result))
7705− ?: mismatch `[%| ["union branch result matching needs unsupported inference" ~]]
7706− $(arms t.arms, remaining (skim remaining |=(c=itype !=(%full (union-pattern pat.a c)))), st state.p.body, answer `result)
7707−::
7708−++ infer-known-union-context-whole
7709− |= [e=expr expected=itype env=ienv subject=iresult context=span]
7710− ^- (unit iresult)
7711− ?> ?=(%branch -.e)
7712− ?: ?=(%| -.subject) `subject
7713− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7714− ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
7715− =/ cases=(list itype) cases.typ
7716− =/ remaining=(list itype) cases
7717− =/ arms=(list arm) arms.e
7718− =/ st=istate state.p.subject
7719− =/ answer=(unit itype) ~
7720− |-
7721− ?~ arms
7722− ?^ remaining
7723− `[%| ["missing union case {(show-itype i.remaining sub.st)}" ~]]
7724− ?~ answer `[%| ["empty union branch is not supported by partial inference" ~]]
7725− `[%& expected st]
7726− =/ a=arm i.arms
7727− ?: (lien remaining |=(c=itype =(%unknown (union-pattern pat.a c))))
7728− ~
7729− =/ matching=(list itype) (skim remaining |=(c=itype =(%full (union-pattern pat.a c))))
7730− ?~ matching
7731− ?: (lien cases |=(c=itype =(%full (union-pattern pat.a c))))
7732− `[%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7733− `[%| ["union pattern is not supported by partial inference" ~]]
7734− ?: &(?=(^ t.matching) (union-pattern-has-bind pat.a))
7735− `[%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7736− =/ bound=(unit ienv) (union-pattern-bind pat.a i.matching env globals.st)
7737− ?~ bound `[%| ["pattern binder shadows a name" ~]]
7738− =/ body=iresult (infer-call-context-arg val.a expected u.bound st context)
7739− ?: ?=(%| -.body) `body
7740− =/ fit=ifit (itype-fit typ.p.body expected sub.state.p.body next.state.p.body)
7741− ?: ?=(%unknown -.fit) `[%| ["union branch result constraint is not supported by partial inference" ~]]
7742− ?: ?=(%bad -.fit)
7743− =/ missing=(unit idiag) (missing-union-tag val.a expected sub.state.p.body context)
7744− ?^ missing `[%| u.missing]
7745− =/ nested=(unit idiag) (nested-missing-tag val.a typ.p.body expected sub.state.p.body next.state.p.body context)
7746− ?^ nested `[%| u.nested]
7747− `[%| ["union branch arm does not fit its expected type" ~[[context "expected type"] [(span-of val.a) "branch arm"]]]]
7748− ?: (itype-has-tag (itype-normalize expected sub.fit))
7749− `[%| ["union branch result needs context in partial inference" ~]]
7750− $(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)
7751−::
7752−++ infer-known-union-finite
7753− |= [e=expr env=ienv subject=iresult expected=(unit [typ=itype context=span])]
7754− ^- iresult
7755− ?> ?=(%branch -.e)
7756− ?: ?=(%| -.subject) subject
7757− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7758− ?. ?=(%union -.typ) [%| ["branch is not supported by partial inference" ~]]
7759− =/ expanded=(unit (list ifinite)) (finite-cases cases.typ ~ 0)
7760− ?~ expanded [%| ["union pattern expansion needs unsupported inference" ~]]
7761− =/ cases=(list ifinite) u.expanded
7762− =/ remaining=(list ifinite) cases
7763− =/ arms=(list arm) arms.e
7764− =/ st=istate state.p.subject
7765− =/ answer=(unit itype) ~
7766− |-
7767− ?~ arms
7768− ?^ remaining
7769− [%| ["missing union case {(show-itype part.i.remaining sub.st)}" ~]]
7770− ?~ answer [%| ["empty union branch is not supported by partial inference" ~]]
7771− ?~ expected [%& u.answer st]
7772− [%& typ.u.expected st]
7773− =/ a=arm i.arms
7774− ?: (lien remaining |=(c=ifinite =(%unknown (union-pattern pat.a part.c))))
7775− [%| ["partial union pattern is not supported by partial inference" ~]]
7776− =/ matching=(list ifinite) (skim remaining |=(c=ifinite =(%full (union-pattern pat.a part.c))))
7777− ?~ matching
7778− ?: (lien cases |=(c=ifinite =(%full (union-pattern pat.a part.c))))
7779− [%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7780− [%| ["union pattern is not supported by partial inference" ~]]
7781− ?: &((union-pattern-has-bind pat.a) (lien t.matching |=(c=ifinite !=(origin.c origin.i.matching))))
7782− [%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7783− =/ bound=(unit ienv) (union-pattern-bind pat.a base.i.matching env globals.st)
7784− ?~ bound [%| ["pattern binder shadows a name" ~]]
7785− =/ body=iresult
7786− ?~ expected (infer-fragment val.a u.bound st)
7787− (infer-call-context-arg val.a typ.u.expected u.bound st context.u.expected)
7788− ?: ?=(%| -.body) body
7789− ?^ expected
7790− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
7791− ?: ?=(%unknown -.fit) [%| ["union branch result constraint is not supported by partial inference" ~]]
7792− ?: ?=(%bad -.fit)
7793− =/ missing=(unit idiag) (missing-union-tag val.a typ.u.expected sub.state.p.body context.u.expected)
7794− ?^ missing [%| u.missing]
7795− =/ 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)
7796− ?^ nested [%| u.nested]
7797− [%| ["union branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.a) "branch arm"]]]]
7798− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
7799− [%| ["union branch result needs context in partial inference" ~]]
7800− $(arms t.arms, remaining (skim remaining |=(c=ifinite !=(%full (union-pattern pat.a part.c)))), st state.p.body(sub sub.fit, next next.fit), answer `typ.u.expected)
7801− =/ result=itype (itype-normalize typ.p.body sub.state.p.body)
7802− =/ mismatch=? ?~(answer | !=((itype-normalize u.answer sub.state.p.body) result))
7803− ?: mismatch [%| ["union branch result matching needs unsupported inference" ~]]
7804− $(arms t.arms, remaining (skim remaining |=(c=ifinite !=(%full (union-pattern pat.a part.c)))), st state.p.body, answer `result)
7805−::
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
7918− |= [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]
7929− ^- iresult
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 ~)
7934− u.whole
7935−::
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]
7944− ^- iresult
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])
7949− u.whole
7950−::
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−::
7991−++ known-union-subject
7992− |= [e=expr env=ienv state=istate]
7993− ^- (unit iresult)
7994− ?. (safe-union-subject e) ~
7995− =/ subject=iresult (infer-fragment e env state)
7996− ?: ?=(%| -.subject) ?:((union-subject-call e) `subject ~)
7997− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7998− ?. |(?=(%union -.typ) ?=(%jrec -.typ) &(?=(%grec -.typ) (grec-direct-context typ.p.subject sub.state.p.subject))) ~
7999− `subject
8000−::
8001−::
8002−:: Infer changes only against a fully known record spine. Retain the
8003−:: target type; unknown spines and repeated edits remain unsupported.
8004−++ change-spine-known
8005− |= [t=itype sub=isub]
8006− ^- ?
8007− =. t (itype-walk t sub)
8008− ?: ?=(%face -.t) &
8009− ?. ?=(%cell -.t) |
8010− =/ first=itype (itype-walk hed.t sub)
8011− ?. ?=(%face -.first) |
8012− $(t tal.t)
8013−::
8014−++ infer-change-edits
8015− |= [edits=(list edit) target=itype env=ienv state=istate seen=(list term)]
8016− ^- iresult
8017− ?~ edits [%& target state]
8018− =/ entry=edit i.edits
8019− ?: (lien seen |=(name=term =(name name.entry)))
8020− [%| ["repeated change fields are not supported by partial inference" ~]]
8021− ?. (change-spine-known target sub.state)
8022− [%| ["change target needs a known record in partial inference" ~]]
8023− =/ found=(list itype) (record-fields-named name.entry target sub.state)
8024− ?~ found
8025− [%| ["record has no field `{(trip name.entry)}`" ~[[at.entry "unknown field"]]]]
8026− ?^ t.found [%| ["change field is ambiguous in partial inference" ~]]
8027− =/ expected=itype i.found
8028− =/ value=iresult (infer-call-context-arg val.entry expected env state at.entry)
8029− ?: ?=(%| -.value) value
8030− =/ fit=ifit (itype-fit typ.p.value expected sub.state.p.value next.state.p.value)
8031− ?: ?=(%unknown -.fit) [%| ["change field constraint is not supported by partial inference" ~]]
8032− ?: ?=(%bad -.fit)
8033− [%| ["change field and replacement do not unify" ~[[at.entry (site-type-note "expected replacement" expected sub.state.p.value)] [(span-of val.entry) (site-type-note "replacement" typ.p.value sub.state.p.value)]]]]
8034− $(edits t.edits, state state.p.value(sub sub.fit, next next.fit), seen [name.entry seen])
8035−::
8036−:: Backtick constructs the canonical prelude unit, after checking its
8037−:: prepared template has the standard null and [~ u=A] cases.
8038−++ standard-unit-template
8039− |= [template=ischeme at=path]
8040− ^- ?
8041− ?. =(at /lib/jibb/prelude/jibb) |
8042− ?~ vars.template |
8043− ?^ t.vars.template |
8044− =/ v=@ud i.vars.template
8045− =/ nil=itype [%const [%null %n 0 '~']]
8046− =/ expected=itype
8047− [%union ~[nil [%cell nil [%face %u [%var v]]]] `[at %unit] `%unit ~[[%var v]]]
8048− =(typ.template expected)
8049−::
8050−:: A named missing-case diagnostic needs more than a failed fit: a case
8051−:: with that tag but the wrong payload is not a missing case. Unknown
8052−:: shapes and atom types that accept terms keep the proof conservative.
8053−+$ itag-presence ?(%yes %no %maybe)
8054−++ tag-presence-cases
8055− |= [cases=(list itype) value=@ sub=isub]
8056− ^- itag-presence
8057− ?~ cases %no
8058− =/ first=itag-presence (tag-presence i.cases value sub)
8059− ?: =(%yes first) %yes
8060− =/ rest=itag-presence $(cases t.cases)
8061− ?: =(%yes rest) %yes
8062− ?: |(=(%maybe first) =(%maybe rest)) %maybe
8063− %no
8064−::
8065−++ tag-presence
8066− |= [t=itype value=@ sub=isub]
8067− ^- itag-presence
8068− =. t (itype-walk t sub)
8069− ?- -.t
8070− %const ?:(=(value val.literal.t) %yes %no)
8071− %flag ?:(|(=(value 0) =(value 1)) %yes %no)
8072− %atom ?:(|(=(%tas aura.t) =(%ta aura.t)) %maybe %no)
8073− %face $(t body.t)
8074− %cell
8075− =/ first=itag-presence $(t hed.t)
8076− ?: =(%yes first) %yes
8077− =/ rest=itag-presence $(t tal.t)
8078− ?: =(%yes rest) %yes
8079− ?: |(=(%maybe first) =(%maybe rest)) %maybe
8080− %no
8081− %union (tag-presence-cases cases.t value sub)
8082− * %maybe
8083− ==
8084−::
8085−++ missing-union-tag
8086− |= [e=expr expected=itype sub=isub context=span]
8087− ^- (unit idiag)
8088− ?. ?=(%lit -.e) ~
8089− ?. =(%term form.lit.e) ~
8090− =. expected (itype-walk expected sub)
8091− |-
8092− ?: ?=(%face -.expected) $(expected (itype-walk body.expected sub))
8093− ?. ?=(%union -.expected) ~
8094− ?. =(%no (tag-presence-cases cases.expected val.lit.e sub)) ~
8095− =/ label=tape
8096− ?~ label.expected "union {(show-itype expected sub)}"
8097− (show-itype expected sub)
8098− `["{label} has no case `{(trip txt.lit.e)}`" ~[[context "expected union"] [(span-of e) "tag"]]]
8099−::
8100−:: Locate a missing tag inside a syntactic tuple only by replaying the
8101−:: directional fit in source order. Uncertain or earlier failures stop
8102−:: the walk, preserving the generic diagnostic rather than guessing.
8103−++ nested-missing-tag
8104− |= [e=expr actual=itype expected=itype sub=isub next=@ud context=span]
8105− ^- (unit idiag)
8106− =/ original=[left=itype right=itype] [actual expected]
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))) ~
8108− =/ fit=ifit (itype-fit actual expected sub next)
8109− ?. ?=(%bad -.fit) ~
8110− =. actual (itype-walk actual sub)
8111− =. expected (itype-walk expected sub)
8112− ?: &(?=(%face -.actual) ?=(%face -.expected))
8113− ?. =(name.actual name.expected) ~
8114− $(actual body.actual, expected body.expected)
8115− ?: ?=(%face -.actual) $(actual body.actual)
8116− ?: ?=(%face -.expected) $(expected body.expected)
8117− =/ direct=(unit idiag) (missing-union-tag e expected sub context)
8118− ?^ direct direct
8119− ?. ?=(%tuple -.e) ~
8120− (nested-missing-items items.e actual expected sub next context)
8121−::
8122−++ nested-missing-items
8123− |= [items=(list item) actual=itype expected=itype sub=isub next=@ud context=span]
8124− ^- (unit idiag)
8125− ?~ items ~
8126− ?~ t.items (nested-missing-tag val.i.items actual expected sub next context)
8127− =/ original=[left=itype right=itype] [actual expected]
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))) ~
8129− =. actual (itype-walk actual sub)
8130− =. expected (itype-walk expected sub)
8131− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8132− =/ first=ifit (itype-fit hed.actual hed.expected sub next)
8133− ?: ?=(%bad -.first)
8134− (nested-missing-tag val.i.items hed.actual hed.expected sub next context)
8135− ?. ?=(%ok -.first) ~
8136− $(items t.items, actual tal.actual, expected tal.expected, sub sub.first, next next.first)
8137−::
8138−:: A term-headed pair is the same noun as a two-item cell. Preserve the
8139−:: whole pair span for the synthetic head and the value's own span for
8140−:: the payload; unresolved term constraints follow ordinary cell inference.
8141−++ pair-as-cell
8142− |= e=expr
8143− ^- expr
8144− ?> ?=(%pair -.e)
8145− =/ head=expr [%lit at.e [%term %tas tag.e (crip ['%' (trip tag.e)])]]
8146− [%tuple at.e ~[[at.e ~ head] [(span-of val.e) ~ val.e]]]
8147−::
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−::
8157−++ infer-fragment
8158− |= [e=expr env=ienv state=istate]
8159− ^- iresult
8160− ?- -.e
8161− %pair $(e (pair-as-cell e))
6354+ ?- -.e
81626355 %lit
81636356 ?- form.lit.e
81646357 %number ?: =(%ud aura.lit.e)
@@ -8172,45 +6365,10 @@
81726365 %term [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
81736366 %null [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
81746367 ==
8175− %unit
8176− ?~ prelude.state [%| ["unit construction needs the standard prelude in partial inference" ~]]
8177− =/ standard=(unit ischeme) (find-jibb-mold %unit u.prelude.state)
8178− ?~ standard [%| ["unit construction needs the standard prelude in partial inference" ~]]
8179− ?. (standard-unit-template u.standard at.u.prelude.state)
8180− [%| ["unit construction needs the standard prelude in partial inference" ~]]
8181− =/ value=iresult $(e val.e)
8182− ?: ?=(%| -.value) value
8183− =/ result=(unit itype) (template-apply u.standard ~[typ.p.value])
8184− ?~ result [%| ["unit construction is not supported by partial inference" ~]]
8185− [%& u.result state.p.value]
8186− %list
8187− ?~ prelude.state [%| ["list literal needs the standard prelude in partial inference" ~]]
8188− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
8189− [%| ["list literal needs the standard prelude in partial inference" ~]]
8190− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude.state)
8191− ?~ standard [%| ["list literal needs the standard prelude in partial inference" ~]]
8192− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]])
8193− [%| ["list literal needs the standard prelude in partial inference" ~]]
8194− =/ element=itype [%var next.state]
8195− =/ result=iresult (infer-open-list-items items.e element env state(next +(next.state)) at.e)
8196− ?: ?=(%| -.result) result
8197− [%& [%collection %list ~[element]] state.p.result]
8198− %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)]
6368+ %str
6369+ =/ interpolated=? (lien pieces.e |=(p=piece ?=(%expr -.p)))
6370+ ?: interpolated [%| ["interpolation is not supported by partial inference" ~]]
6371+ [%& [%atom %t] state]
82146372 %wing
82156373 ?~ names.e [%| ["empty wing" ~]]
82166374 ?^ t.names.e
@@ -8219,7 +6377,7 @@
82196377 ?~ iface (infer-field-wing names.e env state)
82206378 =/ member=(unit ischeme) (ienv-lookup i.names.e values.u.iface)
82216379 ?~ member [%| ["module member is not available to partial inference" ~]]
8222− =. typ.u.member (itype-in-import typ.u.member u.iface i.t.names.e prelude.state)
6380+ =. typ.u.member (itype-in-import typ.u.member u.iface i.t.names.e)
82236381 =/ instance=[typ=itype state=istate] (instantiate-scheme u.member state)
82246382 [%& typ.instance state.instance]
82256383 =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
@@ -8232,11 +6390,6 @@
82326390 =/ instance=[typ=itype state=istate] (instantiate-scheme u.scheme state)
82336391 [%& typ.instance state.instance]
82346392 %group $(e inner.e)
8235− %change
8236− ?~ edits.e [%| ["a change takes at least one field" ~[[at.e "empty change"]]]]
8237− =/ target=iresult $(e [%wing at.e target.e])
8238− ?: ?=(%| -.target) target
8239− (infer-change-edits edits.e typ.p.target env state.p.target ~)
82406393 %ctor [%& [%tag next.state tag.e &] state(next +(next.state), tags [[next.state tag.e] tags.state])]
82416394 %trace
82426395 =/ traced=iresult $(e val.e)
@@ -8253,9 +6406,6 @@
82536406 [%| ["local molds shadow a name" ~]]
82546407 =/ local-state=istate
82556408 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"]]]]
82596409 ?. (local-molds-supported local-molds local-state)
82606410 [%| ["local molds need unsupported inference" ~]]
82616411 =/ values=(list def) (local-value-defs defs.e)
@@ -8266,32 +6416,20 @@
82666416 [%& typ.p.result state.p.result(globals globals.state, molds molds.state)]
82676417 %branch
82686418 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
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 ~)
8274− ?^ t.t.arms.e (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)
6419+ ?~ t.arms.e (infer-cell-branch e env state)
6420+ ?^ t.t.arms.e [%| ["branch is not supported by partial inference" ~]]
82796421 =/ x=arm i.arms.e
82806422 =/ y=arm i.t.arms.e
82816423 ?: |((unit-empty-pattern pat.x) (unit-empty-pattern pat.y))
82826424 (infer-unit-branch e env state ~)
8283− ?. ?=(%lit -.pat.x) (infer-known-union-branch e env state)
8284− ?. ?=(%lit -.pat.y) (infer-known-union-branch e env state)
6425+ ?. ?=(%lit -.pat.x) [%| ["branch pattern is not supported by partial inference" ~]]
6426+ ?. ?=(%lit -.pat.y) [%| ["branch pattern is not supported by partial inference" ~]]
82856427 ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y))
8286− (infer-known-union-branch e env state)
8287− ?: &(?=(^ known) ?=(%& -.u.known)) (infer-known-union-branch-subject e env u.known)
6428+ [%| ["branch pattern is not supported by partial inference" ~]]
82886429 ?: =(val.lit.pat.x val.lit.pat.y)
82896430 [%| ["branch does not cover both loobeans" ~]]
82906431 =/ subject=iresult $(e subject.e)
82916432 ?: ?=(%| -.subject) subject
8292− =/ subject-type=itype (itype-normalize typ.p.subject sub.state.p.subject)
8293− ?: ?=(%union -.subject-type)
8294− [%| ["union-pattern branch subject is not supported by partial inference" ~]]
82956433 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
82966434 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
82976435 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
@@ -8318,776 +6456,64 @@
83186456 [%& typ.p.left state.p.right(sub u.joined)]
83196457 %cast
83206458 =/ target=(unit [typ=itype state=istate]) (infer-simple-shape shape.e state)
8321− ?~ target
8322− =/ diag=(unit idiag) (nested-import-invalid shape.e state)
8323− ?^ diag [%| u.diag]
8324− [%| ["cast mold is not supported by partial inference" ~]]
6459+ ?~ target [%| ["cast mold is not supported by partial inference" ~]]
83256460 =/ value=iresult
8326− (infer-call-context-arg val.e typ.u.target env state.u.target at.shape.e)
6461+ ?: &(?=(%union -.typ.u.target) (context-union-branch val.e))
6462+ (infer-union-context val.e typ.u.target env state.u.target at.shape.e)
6463+ ?: &(?=(%collection -.typ.u.target) =(%list name.typ.u.target) (context-list-literal val.e))
6464+ (infer-list-context val.e typ.u.target env state.u.target at.shape.e)
6465+ $(e val.e, state state.u.target)
83276466 ?: ?=(%| -.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" ~]]
83316467 =/ fit=ifit (itype-fit typ.p.value typ.u.target sub.state.p.value next.state.p.value)
83326468 ?: ?=(%unknown -.fit) [%| ["cast constraint is not supported by partial inference" ~]]
83336469 ?: ?=(%bad -.fit)
8334− =/ missing=(unit idiag) (missing-union-tag val.e typ.u.target sub.state.p.value at.shape.e)
8335− ?^ missing [%| u.missing]
8336− =/ nested=(unit idiag) (nested-missing-tag val.e typ.p.value typ.u.target sub.state.p.value next.state.p.value at.shape.e)
8337− ?^ nested [%| u.nested]
83386470 [%| ["cast mold and expression type do not unify" ~[[at.shape.e (site-type-note "cast mold" typ.u.target sub.state.p.value)] [(span-of val.e) (site-type-note "expression" typ.p.value sub.state.p.value)]]]]
83396471 =/ merged=itype (itype-merge-faces typ.p.value typ.u.target sub.fit)
83406472 [%& merged state.p.value(sub sub.fit, next next.fit)]
83416473 %crash [%& [%var next.state] state(next +(next.state))]
83426474 %gate
83436475 =/ sam=isample-result (infer-sample sample.e env state)
8344− ?: ?=(%| -.sam)
8345− =/ diag=(unit idiag) (sample-import-invalid sample.e env state)
8346− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
8347− [%| [p.sam ~]]
6476+ ?: ?=(%| -.sam) [%| [p.sam ~]]
83486477 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
83496478 ?: ?=(%| -.body) body
83506479 [%& [%fn typ.p.sam typ.p.body] state.p.body]
83516480 %gate-wide
83526481 =/ sam=isample-result (infer-sample sample.e env state)
8353− ?: ?=(%| -.sam)
8354− =/ diag=(unit idiag) (sample-import-invalid sample.e env state)
8355− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
8356− [%| [p.sam ~]]
6482+ ?: ?=(%| -.sam) [%| [p.sam ~]]
83576483 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
83586484 ?: ?=(%| -.body) body
83596485 [%& [%fn typ.p.sam typ.p.body] state.p.body]
83606486 %call
83616487 ?~ args.e [%| ["call has no argument" ~]]
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))
6488+ ?^ t.args.e [%| ["multiple arguments are not supported by partial inference" ~]]
6489+ =/ head=iresult $(e head.e)
6490+ ?: ?=(%| -.head) head
6491+ =/ head-type=itype (itype-walk typ.p.head sub.state.p.head)
6492+ =/ arg=iresult
6493+ ?: &(?=(%fn -.head-type) ?=(%union -.sample.head-type) (context-union-branch i.args.e))
6494+ (infer-union-context i.args.e sample.head-type env state.p.head (span-of head.e))
6495+ ?: &(?=(%fn -.head-type) ?=(%collection -.sample.head-type) =(%list name.sample.head-type) (context-list-literal i.args.e))
6496+ (infer-list-context i.args.e sample.head-type env state.p.head (span-of head.e))
6497+ $(e i.args.e, state state.p.head)
6498+ ?: ?=(%| -.arg) arg
6499+ =/ st=istate state.p.arg
6500+ =/ ht=itype (itype-walk typ.p.head sub.st)
6501+ ?: ?=(%fn -.ht)
6502+ =/ fit=ifit (itype-fit typ.p.arg sample.ht sub.st next.st)
6503+ ?: ?=(%unknown -.fit) [%| ["call constraint is not supported by partial inference" ~]]
6504+ ?: ?=(%bad -.fit)
6505+ [%| ["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)]]]]
6506+ ?: &((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))
6507+ [%| ["call result face propagation is not supported by partial inference" ~]]
6508+ [%& product.ht st(sub sub.fit, next next.fit)]
6509+ =/ result=itype [%var next.st]
6510+ =/ uni=(unit isub) (itype-unify ht [%fn typ.p.arg result] sub.st)
6511+ ?~ uni
6512+ [%| ["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)]]]]
6513+ [%& result st(next +(next.st), sub u.uni)]
83656514 * [%| ["expression is not supported by partial inference" ~]]
83666515 ==
83676516::
8368−:: Locate a definite failing argument after the complete sample fit has
8369−:: failed. If an intermediate fit is uncertain, retain the whole argument
8370−:: span rather than assigning blame to a particular argument.
8371−::
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−::
8674−++ call-error-site
8675− |= [args=(list expr) actual=itype expected=itype sub=isub next=@ud]
8676− ^- (unit [at=span typ=itype])
8677− ?~ args ~
8678− =/ original=[left=itype right=itype] [actual expected]
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))) ~
8680− =. actual (itype-walk actual sub)
8681− =. expected (itype-walk expected sub)
8682− ?: &(?=(%face -.expected) !?=(%face -.actual))
8683− $(expected body.expected)
8684− ?~ t.args
8685− =/ fit=ifit (itype-fit actual expected sub next)
8686− ?. ?=(%bad -.fit) ~
8687− `[(span-of i.args) (itype-normalize actual sub)]
8688− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8689− =/ first=ifit (itype-fit hed.actual hed.expected sub next)
8690− ?: ?=(%bad -.first) `[(span-of i.args) (itype-normalize hed.actual sub)]
8691− ?: ?=(%unknown -.first) ~
8692− $(args t.args, actual tal.actual, expected tal.expected, sub sub.first, next next.first)
8693−::
8694−:: Context can help a call argument or cast value while the final fit
8695−:: checks the complete right-nested type, including any written faces.
8696−::
8697−:: Context can resolve the payload of a canonical prelude unit, but an
8698−:: unrelated union with a similar noun shape is not the same mold.
8699−++ infer-unit-context
8700− |= [e=expr expected=itype env=ienv state=istate context=span]
8701− ^- iresult
8702− ?> ?=(%unit -.e)
8703− ?> ?=(%union -.expected)
8704− ?~ prelude.state (infer-fragment e env state)
8705− =/ standard=(unit ischeme) (find-jibb-mold %unit u.prelude.state)
8706− ?~ standard (infer-fragment e env state)
8707− ?. (standard-unit-template u.standard at.u.prelude.state) (infer-fragment e env state)
8708− ?. =(origin.expected `[at.u.prelude.state %unit]) (infer-fragment e env state)
8709− ?~ args.expected (infer-fragment e env state)
8710− ?^ t.args.expected (infer-fragment e env state)
8711− =/ payload=itype i.args.expected
8712− =/ canonical=(unit itype) (template-apply u.standard ~[payload])
8713− ?~ canonical (infer-fragment e env state)
8714− ?> ?=(%union -.u.canonical)
8715− ?. =((itype-normalize expected(label ~) sub.state) (itype-normalize u.canonical(label ~) sub.state))
8716− (infer-fragment e env state)
8717− =/ value=iresult (infer-call-context-arg val.e payload env state context)
8718− ?: ?=(%| -.value) value
8719− =/ fit=ifit (itype-fit typ.p.value payload sub.state.p.value next.state.p.value)
8720− ?: ?=(%unknown -.fit) [%| ["unit payload constraint is not supported by partial inference" ~]]
8721− ?: ?=(%bad -.fit)
8722− =/ missing=(unit idiag) (missing-union-tag val.e payload sub.state.p.value context)
8723− ?^ missing [%| u.missing]
8724− =/ nested=(unit idiag) (nested-missing-tag val.e typ.p.value payload sub.state.p.value next.state.p.value context)
8725− ?^ nested [%| u.nested]
8726− [%| ["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)]]]]
8727− [%& expected state.p.value(sub sub.fit, next next.fit)]
8728−::
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]
8735− ^- iresult
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)
8770− |-
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.
8990− =/ singleton=(unit itype)
8991− ?. ?=(%lit -.e) ~
8992− ?. =(%loobean form.lit.e) ~
8993− ?. |(?=(%const -.target) &(?=(%union -.expected) (explicit-singleton-in-union expected val.lit.e))) ~
8994− `[%const lit.e]
8995− ?^ singleton [%& u.singleton state]
8996− =/ known=(unit iresult)
8997− ?: ?=(%branch -.e) (known-union-subject subject.e env state)
8998− ~
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)
9002− ?: &(?=(%union -.target) ?=(%unit -.e))
9003− (infer-unit-context e target env state context)
9004− ?: &(?=(%flag -.target) (context-union-branch e))
9005− (infer-union-context e target env state context)
9006− ?: &(?=(%union -.target) (context-union-branch e))
9007− (infer-union-context e target env state context)
9008− ?: &(?=(%collection -.target) =(%list name.target) (context-union-branch e))
9009− (infer-union-context e target env state context)
9010− ?: &(?=(%collection -.target) =(%list name.target) (context-list-expression e))
9011− (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)]
9040− ?: &(?=(%cell -.target) ?=(%tuple -.e))
9041− (infer-call-context-items items.e target env state context)
9042− (infer-fragment e env state)
9043−::
9044−:: 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−::
9053−++ infer-call-context-items
9054− |= [items=(list item) expected=itype env=ienv state=istate context=span]
9055− ^- iresult
9056− ?~ items [%| ["empty cell is not supported by partial inference" ~]]
9057− ?~ t.items
9058− =/ last=iresult (infer-call-context-arg val.i.items (projection-field-target expected) env state context)
9059− ?: ?=(%| -.last) last
9060− =/ typ=itype typ.p.last
9061− =. typ ?~(face.i.items typ [%face u.face.i.items typ])
9062− [%& typ state.p.last]
9063− =/ target=itype (itype-walk expected sub.state)
9064− |-
9065− ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
9066− ?. ?=(%cell -.target) (infer-simple-items items env state)
9067− =/ head=iresult (infer-call-context-arg val.i.items (projection-field-target hed.target) env state context)
9068− ?: ?=(%| -.head) head
9069− =/ typ=itype typ.p.head
9070− =. typ ?~(face.i.items typ [%face u.face.i.items typ])
9071− =/ tail=iresult (infer-call-context-items t.items tal.target env state.p.head context)
9072− ?: ?=(%| -.tail) tail
9073− [%& [%cell typ typ.p.tail] state.p.tail]
9074−::
9075−++ infer-call-context-args
9076− |= [args=(list expr) expected=itype env=ienv state=istate context=span]
9077− ^- iresult
9078− ?~ args [%| ["call has no argument" ~]]
9079− ?~ t.args (infer-call-context-arg i.args (projection-field-target expected) env state context)
9080− =/ target=itype (itype-walk expected sub.state)
9081− |-
9082− ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
9083− ?. ?=(%cell -.target)
9084− (infer-simple-items (turn args |=(a=expr [(span-of a) ~ a])) env state)
9085− =/ head=iresult (infer-call-context-arg i.args (projection-field-target hed.target) env state context)
9086− ?: ?=(%| -.head) head
9087− =/ tail=iresult (infer-call-context-args t.args tal.target env state.p.head context)
9088− ?: ?=(%| -.tail) tail
9089− [%& [%cell typ.p.head typ.p.tail] state.p.tail]
9090−::
90916517:: Tuple and record expressions preserve their explicitly written faces.
90926518::
90936519++ infer-simple-items
@@ -9103,55 +6529,11 @@
91036529 ?: ?=(%| -.tail) tail
91046530 [%& [%cell ht typ.p.tail] state.p.tail]
91056531::
9106−:: A single all-binder cell pattern covers a known cell spine; the final
9107−:: binder captures the remaining noun. Other pattern matrices stay partial.
9108−::
9109−:: Validate binders before reading the subject, preserving shadow-error
9110−:: precedence. The last binder receives the entire remaining tail.
9111−++ cell-pattern-names
9112− |= [pats=(list pattern) env=ienv globals=(list term) seen=(list term)]
9113− ^- (each (list term) @t)
9114− ?~ pats [%& ~]
9115− ?. ?=(%bind -.i.pats) [%| 'branch pattern is not supported by partial inference']
9116− =/ name=term name.i.pats
9117− ?: |(=(name %proj) ?=(^ (ienv-lookup name env)) (lien globals |=(n=term =(n name))) (lien seen |=(n=term =(n name))))
9118− [%| 'pattern shadows a name']
9119− =/ rest=(each (list term) @t) $(pats t.pats, seen [name seen])
9120− ?: ?=(%| -.rest) rest
9121− [%& [name p.rest]]
9122−::
9123−++ cell-pattern-types
9124− |= [names=(list term) env=ienv next=@ud]
9125− ^- [typ=itype env=ienv next=@ud]
9126− ?~ names !!
9127− =/ head=itype [%var next]
9128− =/ scope=ienv [[i.names [head ~]] env]
9129− ?~ t.names [head scope +(next)]
9130− =/ tail=[typ=itype env=ienv next=@ud] $(names t.names, env scope, next +(next))
9131− [[%cell head typ.tail] env.tail next.tail]
9132−::
9133−:: At every position that must be a cell, opaque or sum types may still
9134−:: contain cells. Do not report a definite mismatch without unfolding them.
9135−++ cell-pattern-spine-unknown
9136− |= [typ=itype names=(list term) sub=isub]
9137− ^- ?
9138− ?~ names |
9139− ?~ t.names |
9140− =. typ (itype-walk typ sub)
9141− ?: ?=(%cell -.typ) $(typ tal.typ, names t.names)
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)
6532+:: A single two-binder cell pattern covers every value of a cell type.
6533+:: No other pattern matrix is implemented here.
91526534::
91536535++ infer-cell-branch
9154− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
6536+ |= [e=expr env=ienv state=istate]
91556537 ^- iresult
91566538 ?> ?=(%branch -.e)
91576539 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
@@ -9160,31 +6542,25 @@
91606542 =/ pats=(list pattern) items.pat.arm
91616543 ?~ pats [%| ["branch pattern is not supported by partial inference" ~]]
91626544 ?~ t.pats [%| ["branch pattern is not supported by partial inference" ~]]
9163− =/ names=(each (list term) @t) (cell-pattern-names pats env globals.state ~)
9164− ?: ?=(%| -.names) [%| [(trip p.names) ~]]
6545+ ?^ t.t.pats [%| ["branch pattern is not supported by partial inference" ~]]
6546+ ?. ?=(%bind -.i.pats) [%| ["branch pattern is not supported by partial inference" ~]]
6547+ ?. ?=(%bind -.i.t.pats) [%| ["branch pattern is not supported by partial inference" ~]]
6548+ =/ one=term name.i.pats
6549+ =/ two=term name.i.t.pats
6550+ ?: |(=(one two) ?=(^ (ienv-lookup one env)) ?=(^ (ienv-lookup two env)) (lien globals.state |=(x=term |(=(x one) =(x two)))))
6551+ [%| ["pattern shadows a name" ~]]
91656552 =/ subject=iresult (infer-fragment subject.e env state)
91666553 ?: ?=(%| -.subject) subject
91676554 =/ st=istate state.p.subject
9168− =/ subject-type=itype (itype-normalize typ.p.subject sub.st)
9169− ?: (itype-has-recursive subject-type)
6555+ ?: (itype-has-recursive (itype-normalize typ.p.subject sub.st))
91706556 [%| ["recursive pattern is not supported by partial inference" ~]]
91716557 ?: (itype-has-face typ.p.subject sub.st)
91726558 [%| ["record patterns are not supported by partial inference" ~]]
9173− ?: (cell-pattern-spine-unknown subject-type p.names sub.st)
9174− [%| ["cell pattern subject is not supported by partial inference" ~]]
9175− =/ binders=[typ=itype env=ienv next=@ud] (cell-pattern-types p.names env next.st)
9176− =/ sub=(unit isub) (itype-unify typ.p.subject typ.binders sub.st)
6559+ =/ head=itype [%var next.st]
6560+ =/ tail=itype [%var +(next.st)]
6561+ =/ sub=(unit isub) (itype-unify typ.p.subject [%cell head tail] sub.st)
91776562 ?~ sub [%| ["cell pattern does not match the subject type" ~]]
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)]
6563+ (infer-fragment val.arm [[one [head ~]] [two [tail ~]] env] st(next (add 2 next.st), sub u.sub))
91886564::
91896565++ show-itype
91906566 |= [t=itype sub=isub]
@@ -9197,19 +6573,12 @@
91976573 %avar
91986574 ?: (lth id.t 26) [(add 65 id.t) ~]
91996575 "T{<id.t>}"
9200− %rvar
9201− ?: (lth id.t 26) [(add 65 id.t) ~]
9202− "T{<id.t>}"
92036576 %nvar
92046577 ?: (lth id.t 26) [(add 65 id.t) ~]
92056578 "T{<id.t>}"
9206− %rnvar
9207− ?: (lth id.t 26) [(add 65 id.t) ~]
9208− "T{<id.t>}"
92096579 %atom "@{(trip aura.t)}"
92106580 %any-atom "@"
92116581 %flag "?"
9212− %noun "*"
92136582 %tag (trip txt.literal.t)
92146583 %const (trip txt.literal.t)
92156584 %union
@@ -9217,8 +6586,6 @@
92176586 ?~ args.t (trip u.label.t)
92186587 "({(trip u.label.t)} {(show-itype-cases args.t sub)})"
92196588 %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)})")
92226589 %collection "({(trip name.t)} {(show-itype-cases args.t sub)})"
92236590 %face "[{(trip name.t)}={(show-itype-context body.t sub)}]"
92246591 %fn "$-({(show-itype-context sample.t sub)} {(show-itype-context product.t sub)})"
@@ -9254,20 +6621,15 @@
92546621 ^- ?
92556622 ?- -.typ
92566623 %nvar &
9257− %rnvar &
92586624 %var |
92596625 %avar |
9260− %rvar |
92616626 %atom |
92626627 %any-atom |
92636628 %flag |
9264− %noun |
92656629 %tag |
92666630 %const |
92676631 %union |((lien cases.typ |=(c=itype (itype-has-nvar c))) (lien args.typ |=(c=itype (itype-has-nvar c))))
92686632 %recursive |
9269− %jrec |
9270− %grec (lien args.typ |=(c=itype (itype-has-nvar c)))
92716633 %collection (lien args.typ |=(c=itype (itype-has-nvar c)))
92726634 %face $(typ body.typ)
92736635 %fn |($(typ sample.typ) $(typ product.typ))
@@ -9278,7 +6640,7 @@
92786640 |= [label=tape typ=itype sub=isub]
92796641 ^- tape
92806642 =/ normalized=itype (itype-normalize typ sub)
9281− ?: |(?=(%var -.normalized) ?=(%avar -.normalized) ?=(%rvar -.normalized) (itype-has-nvar normalized) (itype-has-tag normalized) (itype-has-union normalized)) label
6643+ ?: |(?=(%var -.normalized) ?=(%avar -.normalized) (itype-has-nvar normalized) (itype-has-tag normalized) (itype-has-union normalized)) label
92826644 ?: (itype-has-hidden-recursive normalized) label
92836645 =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
92846646 ?: (gth (lent vars) 26) label
@@ -9288,8 +6650,8 @@
92886650:: A capital in a written mold is generalized with its enclosing ++.
92896651:: Atom constraints may remain generic; until full rigidity checking
92906652:: is implemented, do not report a type if one became more specific.
9291−:: Distinct written capitals cannot be forced equal; use the same
9292−:: capital where a type must be shared (Decisions 2026-10-30).
6653+:: Whether distinct written capitals may become equal is a doc question;
6654+:: the partial checker leaves such inference unsupported for now.
92936655::
92946656++ cap-id-in
92956657 |= [n=@ud caps=icaps sub=isub]
@@ -9300,43 +6662,11 @@
93006662 ?+ -.resolved ~
93016663 %var `id.resolved
93026664 %avar `id.resolved
9303− %rvar `id.resolved
93046665 ==
93056666 ?~ ident $(caps t.caps)
93066667 ?: =(n u.ident) &
93076668 $(caps t.caps)
93086669::
9309−++ cap-with-id
9310− |= [n=@ud caps=icaps sub=isub]
9311− ^- (unit icap)
9312− ?~ caps ~
9313− =/ resolved=itype (itype-walk [%var id.i.caps] sub)
9314− =/ ident=(unit @ud)
9315− ?+ -.resolved ~
9316− %var `id.resolved
9317− %avar `id.resolved
9318− %rvar `id.resolved
9319− ==
9320− ?~ ident $(caps t.caps)
9321− ?: =(n u.ident) `i.caps
9322− $(caps t.caps)
9323−::
9324−++ merged-capitals
9325− |= [caps=icaps sub=isub]
9326− ^- (unit [first=icap second=icap])
9327− ?~ caps ~
9328− =/ resolved=itype (itype-walk [%var id.i.caps] sub)
9329− =/ ident=(unit @ud)
9330− ?+ -.resolved ~
9331− %var `id.resolved
9332− %avar `id.resolved
9333− %rvar `id.resolved
9334− ==
9335− ?~ ident $(caps t.caps)
9336− =/ found=(unit icap) (cap-with-id u.ident t.caps sub)
9337− ?^ found `[u.found i.caps]
9338− $(caps t.caps)
9339−::
93406670++ constrained-capitals
93416671 |= [caps=icaps sub=isub]
93426672 ^- ?
@@ -9346,7 +6676,6 @@
93466676 ?+ -.resolved ~
93476677 %var `id.resolved
93486678 %avar `id.resolved
9349− %rvar `id.resolved
93506679 ==
93516680 ?~ ident &
93526681 ?: (cap-id-in u.ident t.caps sub) &
@@ -9361,8 +6690,8 @@
93616690 ^- ?
93626691 ?~ caps |
93636692 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
9364− ?: |(?=(%avar -.resolved) ?=(%rvar -.resolved))
9365− ?: =(n +.resolved) &
6693+ ?: ?=(%avar -.resolved)
6694+ ?: =(n id.resolved) &
93666695 $(caps t.caps)
93676696 $(caps t.caps)
93686697::
@@ -9372,19 +6701,14 @@
93726701 ?- -.t
93736702 %var |
93746703 %avar =(n id.t)
9375− %rvar =(n id.t)
93766704 %nvar |
9377− %rnvar |
93786705 %atom |
93796706 %any-atom |
93806707 %flag |
9381− %noun |
93826708 %tag |
93836709 %const |
93846710 %union |((lien cases.t |=(c=itype (has-atom-var n c))) (lien args.t |=(c=itype (has-atom-var n c))))
93856711 %recursive |
9386− %jrec |
9387− %grec (lien args.t |=(c=itype (has-atom-var n c)))
93886712 %collection (lien args.t |=(c=itype (has-atom-var n c)))
93896713 %face $(t body.t)
93906714 %fn |($(t sample.t) $(t product.t))
@@ -9424,10 +6748,6 @@
94246748 =/ out=tape ""
94256749 |-
94266750 ?~ 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))
94316751 ?: (itype-var-is-atom i.vars t)
94326752 =/ sep=tape ?:(printed ", " " where ")
94336753 =/ clause=tape "{sep}{(show-itype [%avar i.vars] ~)} is an atom"
@@ -9436,9 +6756,9 @@
94366756::
94376757:: Build the supported part of the value environment in dependency order.
94386758:: Each pass adds successful definitions. Forward references become
9439−:: available on a later pass; unsupported syntax does not enter the
9440−:: environment. Generalized definitions are closed, so a use instantiates
9441−:: its variables afresh.
6759+:: available on a later pass; recursive groups and unsupported syntax do
6760+:: not enter the environment. Generalized definitions are closed, so a
6761+:: use instantiates its variables afresh.
94426762::
94436763++ global-value-names
94446764 |= ds=(list def)
@@ -9456,638 +6776,33 @@
94566776 ?~ t.hits &
94576777 |
94586778::
9459−:: A top-level gate may refer to itself through one monomorphic placeholder.
9460−:: Its declared sample is inferred first and preserves its field faces.
9461−:: Unify the completed body with that placeholder before generalization;
9462−:: reporting repeats the same check instead of instantiating the gate's
9463−:: generalized interface inside its own body. Mutual groups stay unsupported.
9464−::
9465−++ direct-self-call
9466− |= [e=expr name=term]
9467− ^- ?
9468− ?: ?=(%group -.e) $(e inner.e)
9469− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
9470− ?. ?=(%call -.e) |
9471− ?. ?=(%wing -.head.e) |
9472− =(names.head.e ~[name])
9473−::
9474−++ branch-base-arm
9475− |= [e=expr name=term]
9476− ^- (unit expr)
9477− ?: ?=(%group -.e) $(e inner.e)
9478− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
9479− ?. ?=(%branch -.e) ~
9480− ?~ arms.e ~
9481− ?~ t.arms.e ~
9482− ?^ t.t.arms.e ~
9483− =/ x=arm i.arms.e
9484− =/ y=arm i.t.arms.e
9485− ?. &(?=(%lit -.pat.x) ?=(%lit -.pat.y)) ~
9486− ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y)) ~
9487− ?: =(val.lit.pat.x val.lit.pat.y) ~
9488− =/ first=? (direct-self-call val.x name)
9489− =/ second=? (direct-self-call val.y name)
9490− ?: =(first second) ~
9491− `?:(first val.y val.x)
9492−::
9493−:: Infer the base arm independently, with the self binding removed. Only
9494−:: a closed type whose constraints resolved can seed the recursive result.
9495−:: The regular body inference then checks both arms with shared state.
9496−::
9497−++ recursive-branch-seed
9498− |= [d=def env=ienv state=istate]
9499− ^- (unit itype)
9500− ?. ?=(%value -.d) ~
9501− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) ~
9502− =/ gate=expr val.d
9503− =/ body=expr
9504− ?- -.gate
9505− %gate body.gate
9506− %gate-wide body.gate
9507− * !!
9508− ==
9509− =/ base=(unit expr) (branch-base-arm body name.d)
9510− ?~ base ~
9511− =/ outer=ienv (skim env |=(entry=[name=term scheme=ischeme] !=(name.entry name.d)))
9512− =/ sam=isample-result
9513− ?- -.gate
9514− %gate (infer-sample sample.gate outer state)
9515− %gate-wide (infer-sample sample.gate outer state)
9516− * !!
9517− ==
9518− ?: ?=(%| -.sam) ~
9519− =/ inferred=iresult (infer-fragment u.base env.p.sam state.p.sam)
9520− ?: ?=(%| -.inferred) ~
9521− ?: (pending-tags tags.state.p.inferred sub.state.p.inferred) ~
9522− ?: (constrained-capitals caps.state.p.inferred sub.state.p.inferred) ~
9523− =/ typ=itype (itype-normalize typ.p.inferred sub.state.p.inferred)
9524− ?: ?=(^ (itype-vars typ)) ~
9525− ?: (itype-has-tag typ) ~
9526− `typ
9527−::
9528−++ infer-recursive-gate
9529− |= [d=def env=ienv state=istate]
9530− ^- iresult
9531− =. gate-defs.state ~
9532− ?. ?=(%value -.d) [%| ["recursive definition is not a gate" ~]]
9533− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
9534− [%| ["recursive definition is not a gate" ~]]
9535− =/ result=(unit itype) (recursive-branch-seed d env state)
9536− =/ gate=expr val.d
9537− =/ sam=isample-result
9538− ?- -.gate
9539− %gate (infer-sample sample.gate env state)
9540− %gate-wide (infer-sample sample.gate env state)
9541− * !!
9542− ==
9543− ?: ?=(%| -.sam)
9544− =/ diag=(unit idiag)
9545− ?- -.gate
9546− %gate (sample-import-invalid sample.gate env state)
9547− %gate-wide (sample-import-invalid sample.gate env state)
9548− * ~
9549− ==
9550− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
9551− [%| [p.sam ~]]
9552− =/ id=@ud next.state.p.sam
9553− =/ product=itype ?~(result [%var id] u.result)
9554− =/ st=istate state.p.sam(next +(id))
9555− =/ seed=itype [%fn typ.p.sam product]
9556− =/ seeded=ienv [[name.d [seed ~]] env.p.sam]
9557− =/ body=expr
9558− ?- -.gate
9559− %gate body.gate
9560− %gate-wide body.gate
9561− * !!
9562− ==
9563− =/ out=iresult (infer-fragment body seeded st)
9564− ?: ?=(%| -.out) out
9565− =/ uni=(unit isub) (itype-unify product typ.p.out sub.state.p.out)
9566− ?~ uni [%| ["recursive gate constraint is not supported by partial inference" ~]]
9567− [%& [%fn typ.p.sam typ.p.out] state.p.out(sub u.uni)]
9568−::
9569−++ dependency-root
9570− |= names=(list term)
9571− ^- (list term)
9572− ?~ names ~
9573− ~[(rear names)]
9574−::
9575−++ dependency-exprs
9576− |= xs=(list expr)
9577− ^- (list term)
9578− ?~ xs ~
9579− =/ first=(list term) (dependency-expr i.xs)
9580− (weld first $(xs t.xs))
9581−::
9582−++ dependency-pieces
9583− |= xs=(list piece)
9584− ^- (list term)
9585− ?~ xs ~
9586− =/ first=(list term)
9587− ?- -.i.xs
9588− %expr (dependency-expr p.i.xs)
9589− %text ~
9590− ==
9591− (weld first $(xs t.xs))
9592−::
9593−++ dependency-qsegs
9594− |= xs=(list qseg)
9595− ^- (list term)
9596− ?~ xs ~
9597− =/ first=(list term)
9598− ?- -.i.xs
9599− %expr (dependency-expr p.i.xs)
9600− %knot ~
9601− ==
9602− (weld first $(xs t.xs))
9603−::
9604−++ dependency-items
9605− |= xs=(list item)
9606− ^- (list term)
9607− ?~ xs ~
9608− =/ first=(list term) (dependency-expr val.i.xs)
9609− (weld first $(xs t.xs))
9610−::
9611−++ dependency-edits
9612− |= xs=(list edit)
9613− ^- (list term)
9614− ?~ xs ~
9615− =/ first=(list term) (dependency-expr val.i.xs)
9616− (weld first $(xs t.xs))
9617−::
9618−++ dependency-arms
9619− |= xs=(list arm)
9620− ^- (list term)
9621− ?~ xs ~
9622− =/ first=(list term) (dependency-expr val.i.xs)
9623− (weld first $(xs t.xs))
9624−::
9625−++ dependency-defs
9626− |= xs=(list def)
9627− ^- (list term)
9628− ?~ xs ~
9629− =/ first=(list term)
9630− ?: ?=(%value -.i.xs) (dependency-expr val.i.xs)
9631− ~
9632− (weld first $(xs t.xs))
9633−::
9634−++ dependency-expr
9635− |= e=expr
9636− ^- (list term)
9637− ?- -.e
9638− %str (dependency-pieces pieces.e)
9639− %qath (dependency-qsegs segs.e)
9640− %wing (dependency-root names.e)
9641− %change
9642− =/ first=(list term) (dependency-root target.e)
9643− =/ last=(list term) (dependency-edits edits.e)
9644− (weld first last)
9645− %pair (dependency-expr val.e)
9646− %unit (dependency-expr val.e)
9647− %group (dependency-expr inner.e)
9648− %list (dependency-exprs items.e)
9649− %tuple (dependency-items items.e)
9650− %gate (dependency-expr body.e)
9651− %gate-wide (dependency-expr body.e)
9652− %call
9653− =/ first=(list term) (dependency-expr head.e)
9654− =/ last=(list term) (dependency-exprs args.e)
9655− (weld first last)
9656− %cast (dependency-expr val.e)
9657− %trace
9658− =/ first=(list term) (dependency-expr val.e)
9659− =/ last=(list term) (dependency-expr then.e)
9660− (weld first last)
9661− %branch
9662− =/ first=(list term) (dependency-expr subject.e)
9663− =/ last=(list term) (dependency-arms arms.e)
9664− (weld first last)
9665− %body
9666− =/ first=(list term) (dependency-defs defs.e)
9667− =/ last=(list term) (dependency-expr final.e)
9668− (weld first last)
9669− * ~
9670− ==
9671−::
9672−:: Infer a cyclic component with one monomorphic seed per gate. All members
9673−:: must succeed before any scheme is available; pending constraints and
9674−:: unresolved branch joins remain partial.
9675−+$ igate-entry [name=term typ=itype body=expr env=ienv caps=icaps]
9676−+$ igate-seeds (each [entries=(list igate-entry) state=istate] idiag)
9677−++ seed-gate-group
9678− |= [ds=(list def) env=ienv state=istate]
9679− ^- igate-seeds
9680− ?~ ds [%& [~ state]]
9681− =/ d=def i.ds
9682− ?. ?=(%value -.d) [%| ["recursive group contains a non-gate" ~]]
9683− =/ gate=expr val.d
9684− ?. |(?=(%gate -.gate) ?=(%gate-wide -.gate))
9685− [%| ["recursive group contains a non-gate" ~]]
9686− =/ initial=istate (reserve-def-caps gate state)
9687− =/ sam=isample-result
9688− ?- -.gate
9689− %gate (infer-sample sample.gate env initial)
9690− %gate-wide (infer-sample sample.gate env initial)
9691− * !!
9692− ==
9693− ?: ?=(%| -.sam) [%| [p.sam ~]]
9694− =/ body=expr
9695− ?- -.gate
9696− %gate body.gate
9697− %gate-wide body.gate
9698− * !!
9699− ==
9700− =/ seed=itype [%fn typ.p.sam [%var next.state.p.sam]]
9701− =/ entry=igate-entry [name.d seed body env.p.sam caps.state.p.sam]
9702− =/ after=istate state.p.sam(next +(next.state.p.sam), caps caps.state)
9703− =/ rest=igate-seeds $(ds t.ds, state after)
9704− ?: ?=(%| -.rest) rest
9705− [%& [[entry entries.p.rest] state.p.rest]]
9706−::
9707−++ group-seed-env
9708− |= [entries=(list igate-entry) env=ienv]
9709− ^- ienv
9710− ?~ entries env
9711− [[name.i.entries [typ.i.entries ~]] $(entries t.entries)]
9712−::
9713−++ infer-gate-group-bodies
9714− |= [entries=(list igate-entry) seeds=ienv state=istate]
9715− ^- igate-seeds
9716− ?~ entries [%& [~ state]]
9717− =/ entry=igate-entry i.entries
9718− ?> ?=(%fn -.typ.entry)
9719− =/ scope=ienv (weld seeds env.entry)
9720− =/ out=iresult (infer-fragment body.entry scope state(caps caps.entry))
9721− ?: ?=(%| -.out) out
9722− =/ uni=(unit isub) (itype-unify product.typ.entry typ.p.out sub.state.p.out)
9723− ?~ uni [%| ["recursive group constraint is not supported by partial inference" ~]]
9724− =. caps.entry caps.state.p.out
9725− =/ after=istate state.p.out(sub u.uni, caps caps.state)
9726− =/ rest=igate-seeds $(entries t.entries, state after)
9727− ?: ?=(%| -.rest) rest
9728− [%& [[entry entries.p.rest] state.p.rest]]
9729−::
9730−++ group-schemes
9731− |= [entries=(list igate-entry) env=ienv outer=istate state=istate]
9732− ^- (each ienv idiag)
9733− ?~ entries [%& ~]
9734− =/ entry=igate-entry i.entries
9735− =/ merged=(unit [first=icap second=icap]) (merged-capitals caps.entry sub.state)
9736− ?^ merged
9737− [%| ["distinct type variables must not be forced equal" ~[[at.first.u.merged "first type variable"] [at.second.u.merged "second type variable"]]]]
9738− ?: (constrained-capitals caps.entry sub.state)
9739− [%| ["explicit capital constraints are not supported by partial inference" ~]]
9740− =/ typ=itype (itype-normalize typ.entry sub.state)
9741− ?: (itype-has-nvar typ) [%| ["recursive group needs unsupported inference" ~]]
9742− ?: |((itype-has-tag typ) (itype-has-hidden-generic typ) (itype-has-hidden-recursive typ) (unsupported-atom-vars typ caps.entry binders.state sub.state))
9743− [%| ["recursive group needs unsupported inference" ~]]
9744− =/ free=(list @ud) (weld (free-env-vars env sub.state) (free-cap-vars caps.outer sub.state))
9745− =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
9746− =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
9747− ?: (gth (lent vars) 26) [%| ["recursive group needs too many type variables" ~]]
9748− =/ rest=(each ienv idiag) $(entries t.entries)
9749− ?: ?=(%| -.rest) rest
9750− [%& [[name.entry [typ vars]] p.rest]]
9751−::
9752−++ infer-gate-group
9753− |= [ds=(list def) env=ienv state=istate]
9754− ^- ilocal-result
9755− =/ names=(list term) (global-value-names ds)
9756− ?. (levy names |=(n=term (unique-value-name n names)))
9757− [%| ["recursive group contains duplicate names" ~]]
9758− ?: (lien names |=(n=term ?=(^ (ienv-lookup n env))))
9759− [%| ["recursive group shadows a name" ~]]
9760− =/ scoped=istate state(globals (weld names globals.state), gate-defs ~)
9761− =/ seeded=igate-seeds (seed-gate-group ds env scoped)
9762− ?: ?=(%| -.seeded) seeded
9763− =/ seeds=ienv (group-seed-env entries.p.seeded ~)
9764− =/ body=igate-seeds (infer-gate-group-bodies entries.p.seeded seeds state.p.seeded)
9765− ?: ?=(%| -.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" ~]]
9771− ?: (pending-tags tags.state.p.body sub.state.p.body)
9772− [%| ["recursive group has unresolved literal constraints" ~]]
9773− =/ schemes=(each ienv idiag) (group-schemes entries.p.body env state state.p.body)
9774− ?: ?=(%| -.schemes) schemes
9775− [%& [(weld p.schemes env) state.p.body(globals globals.state)]]
9776−::
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−::
97936779++ add-supported-defs
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 ~)
9797−::
9798−
9799−+$ iresolved [env=ienv grouped=(list term) artifacts=(list iwidth-definition)]
9800−+$ iadj (map term (list term))
9801−+$ ivisited (map term ?)
9802−+$ iwork (list [name=term done=?])
9803−+$ iwresult [seen=ivisited order=(list term)]
9804−+$ icresult [seen=ivisited component=(list term)]
9805−+$ icomponents (list (list term))
9806−++ graph-nameset
9807− |= [names=(list term) seen=ivisited]
9808− ^- ivisited
9809− ?~ names seen
9810− $(names t.names, seen (~(put by seen) i.names &))
9811−::
9812−++ graph-edges
9813− |= [name=term graph=iadj]
9814− ^- (list term)
9815− =/ found=(unit (list term)) (~(get by graph) name)
9816− ?~ found ~
9817− u.found
9818−::
9819−++ graph-make-forward
9820− |= [ds=(list def) names=ivisited graph=iadj]
9821− ^- iadj
9822− ?~ ds graph
9823− ?. ?=(%value -.i.ds) $(ds t.ds)
9824− =/ deps=(list term) (dependency-expr val.i.ds)
9825− =. deps (skim deps |=(n=term ?=(^ (~(get by names) n))))
9826− $(ds t.ds, graph (~(put by graph) name.i.ds deps))
9827−::
9828−++ graph-add-reverse
9829− |= [name=term edges=(list term) reverse=iadj]
9830− ^- iadj
9831− ?~ edges reverse
9832− =/ prior=(list term) (graph-edges i.edges reverse)
9833− $(edges t.edges, reverse (~(put by reverse) i.edges [name prior]))
9834−::
9835−++ graph-reverse
9836− |= [names=(list term) graph=iadj reverse=iadj]
9837− ^- iadj
9838− ?~ names reverse
9839− =. reverse (graph-add-reverse i.names (graph-edges i.names graph) reverse)
9840− $(names t.names)
9841−::
9842−++ graph-order
9843− |= [todo=iwork seen=ivisited order=(list term) graph=iadj]
9844− ^- iwresult
9845− ?~ todo [seen order]
9846− =/ event=[name=term done=?] i.todo
9847− ?: done.event $(todo t.todo, order [name.event order])
9848− ?: ?=(^ (~(get by seen) name.event)) $(todo t.todo)
9849− =. seen (~(put by seen) name.event &)
9850− =/ children=iwork (turn (graph-edges name.event graph) |=(n=term [n |]))
9851− $(todo (weld children [[name.event &] t.todo]))
9852−::
9853−++ graph-collect
9854− |= [todo=(list term) seen=ivisited component=(list term) graph=iadj]
9855− ^- icresult
9856− ?~ todo [seen component]
9857− ?: ?=(^ (~(get by seen) i.todo)) $(todo t.todo)
9858− =. seen (~(put by seen) i.todo &)
9859− $(todo (weld (graph-edges i.todo graph) t.todo), component [i.todo component])
9860−::
9861−++ graph-collect-all
9862− |= [order=(list term) seen=ivisited graph=iadj comps=icomponents]
9863− ^- icomponents
9864− ?~ order comps
9865− ?: ?=(^ (~(get by seen) i.order)) $(order t.order)
9866− =/ found=icresult (graph-collect ~[i.order] seen ~ graph)
9867− $(order t.order, seen seen.found, comps [component.found comps])
9868−::
9869−:: Two depth-first passes find components before group inference. Maps
9870−:: preserve the graph identity; duplicate global names fail closed.
9871−++ graph-components
9872− |= [ds=(list def) names=(list term)]
9873− ^- icomponents
9874− =/ nameset=ivisited ~
9875− =/ pending=(list term) names
9876− |-
9877− ?^ pending
9878− ?: ?=(^ (~(get by nameset) i.pending)) ~
9879− $(pending t.pending, nameset (~(put by nameset) i.pending &))
9880− =/ graph=iadj (graph-make-forward ds nameset ~)
9881− =/ reverse=iadj (graph-reverse names graph ~)
9882− =/ order=iwresult (graph-order (turn names |=(n=term [n |])) ~ ~ graph)
9883− (graph-collect-all order.order ~ reverse ~)
9884−::
9885−++ graph-cycle
9886− |= [component=(list term) graph=iadj]
9887− ^- ?
9888− ?~ component |
9889− ?^ t.component &
9890− (lien (graph-edges i.component graph) |=(x=term =(x i.component)))
9891−::
9892−++ add-groups
9893− |= [ds=(list def) components=icomponents graph=iadj env=ienv grouped=(list term) artifacts=(list iwidth-definition) state=istate]
9894− ^- iresolved
9895− ?~ components [env grouped artifacts]
9896− =/ component=(list term) i.components
9897− ?. (graph-cycle component graph) $(components t.components)
9898− ?: (lien component |=(n=term ?=(^ (ienv-lookup n env)))) $(components t.components)
9899− =/ members=(list def)
9900− %+ skim ds
9901− |= d=def
9902− &(?=(%value -.d) (lien component |=(n=term =(n name.d))))
9903− ?. =((lent members) (lent component)) $(components t.components)
9904− ?. (levy component |=(n=term (unique-value-name n globals.state))) $(components t.components)
9905− =/ result=ilocal-result (infer-gate-group members env state)
9906− ?: ?=(%| -.result) $(components t.components)
9907− $(components t.components, env env.p.result, grouped (weld component grouped))
9908−::
9909−++ resolve-groups
9910− |= [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)]
9911− ^- 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]
6780+ |= [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)]
6781+ ^- ienv
6782+ ?~ ds env
99196783 =/ d=def i.ds
99206784 ?: ?=(%mold -.d) $(ds t.ds)
99216785 ?. (unique-value-name name.d globals) $(ds t.ds)
99226786 ?^ (ienv-lookup name.d env) $(ds t.ds)
99236787 =/ 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)
6788+ =/ result=iresult (infer-fragment val.d env [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude])
99316789 ?: ?=(%| -.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)
99356790 ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
99366791 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
99376792 ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
99386793 ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
99396794 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
99406795 ?: (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
9952− =/ env=ienv ~
9953− =/ grouped=(list term) ~
9954− =/ artifacts=(list iwidth-definition) ~
9955− =/ names=(list term) (global-value-names ds)
9956− =/ nameset=ivisited (graph-nameset names ~)
9957− =/ graph=iadj (graph-make-forward ds nameset ~)
9958− =/ components=icomponents (graph-components ds names)
9959− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9960− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude)
9961− |-
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)
9967− ?: =(env env.out) out
9968− $(env env.out, grouped grouped.out, artifacts artifacts.out)
6796+ $(ds t.ds, env [[name.d [typ vars]] env])
99696797::
99706798++ resolve-supported-defs
99716799 |= [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)]
99726800 ^- ienv
9973− env:(resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude)
9974−::
9975−:: A diagnostic-only proof for a narrow syntactic value cycle. Every
9976−:: edge is an unqualified wing in a supported expression, and samples
9977−:: may not shadow global bindings. Unknown forms yield no conclusion.
9978−+$ icyclesite [name=term at=span]
9979−+$ icycle [name=term first=span next=span]
9980−++ cycle-sites-list
9981− |= [xs=(list expr) globals=(list term) locals=(list term)]
9982− ^- (unit (list icyclesite))
9983− ?~ xs `~
9984− =/ first=(unit (list icyclesite)) (cycle-sites i.xs globals locals)
9985− ?~ first ~
9986− =/ tail=(unit (list icyclesite)) $(xs t.xs)
9987− ?~ tail ~
9988− `(weld u.first u.tail)
9989−::
9990−++ cycle-sample-name
9991− |= [sam=sample globals=(list term) locals=(list term)]
9992− ^- (unit (unit term))
9993− ?- -.sam
9994− %bind
9995− ?: (lien (weld globals locals) |=(n=term =(n name.sam))) ~
9996− ``name.sam
9997− %face
9998− ?: (lien (weld globals locals) |=(n=term =(n name.sam))) ~
9999− ``name.sam
10000− %bare `~
10001− * ~
10002− ==
10003−::
10004−++ cycle-sites
10005− |= [e=expr globals=(list term) locals=(list term)]
10006− ^- (unit (list icyclesite))
10007− ?- -.e
10008− %wing
10009− ?. ?=([@ ~] names.e) ~
10010− `~[[i.names.e at.e]]
10011− %lit `~
10012− %str
10013− ?: (lien pieces.e |=(p=piece ?=(%expr -.p))) ~
10014− `~
10015− %group $(e inner.e)
10016− %body ?~(defs.e $(e final.e) ~)
10017− %cast $(e val.e)
10018− %gate
10019− =/ binder=(unit (unit term)) (cycle-sample-name sample.e globals locals)
10020− ?~ binder ~
10021− =/ nested=(list term) ?~(u.binder locals [u.u.binder locals])
10022− $(e body.e, locals nested)
10023− %gate-wide
10024− =/ binder=(unit (unit term)) (cycle-sample-name sample.e globals locals)
10025− ?~ binder ~
10026− =/ nested=(list term) ?~(u.binder locals [u.u.binder locals])
10027− $(e body.e, locals nested)
10028− %call
10029− =/ first=(unit (list icyclesite)) $(e head.e)
10030− ?~ first ~
10031− =/ tail=(unit (list icyclesite)) (cycle-sites-list args.e globals locals)
10032− ?~ tail ~
10033− `(weld u.first u.tail)
10034− * ~
10035− ==
10036−::
10037−++ cycle-definitely-atom
10038− |= e=expr
10039− ^- ?
10040− ?: ?=(%group -.e) $(e inner.e)
10041− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
10042− ?. ?=(%cast -.e) |
10043− |(?=(%aura -.shape.e) ?=(%flag -.shape.e))
10044−::
10045−++ cycle-proof-group
10046− |= [members=(list def) globals=(list term)]
10047− ^- ?
10048− ?~ members &
10049− ?. ?=(%value -.i.members) |
10050− ?. (unique-value-name name.i.members globals) |
10051− ?. ?=(^ (cycle-sites val.i.members globals ~)) |
10052− $(members t.members)
10053−::
10054−++ cycle-find-site
10055− |= [sites=(list icyclesite) component=(list term)]
10056− ^- (unit span)
10057− ?~ sites ~
10058− ?: (lien component |=(n=term =(n name.i.sites))) `at.i.sites
10059− $(sites t.sites)
10060−::
10061−++ cycle-group-errors
10062− |= [members=(list def) component=(list term) globals=(list term)]
10063− ^- (list icycle)
10064− ?~ members ~
10065− =/ d=def i.members
10066− ?> ?=(%value -.d)
10067− =/ tail=(list icycle) $(members t.members)
10068− ?. (cycle-definitely-atom val.d) tail
10069− =/ sites=(unit (list icyclesite)) (cycle-sites val.d globals ~)
10070− ?~ sites tail
10071− =/ found=(unit span) (cycle-find-site u.sites component)
10072− ?~ found tail
10073− [[name.d at.d u.found] tail]
10074−::
10075−++ definite-value-cycles
10076− |= [ds=(list def) globals=(list term)]
10077− ^- (list icycle)
10078− =/ names=(list term) (global-value-names ds)
10079− =/ graph=iadj (graph-make-forward ds (graph-nameset names ~) ~)
10080− =/ components=icomponents (graph-components ds names)
10081− =/ out=(list icycle) ~
6801+ =/ env=ienv ~
100826802 |-
10083− ?~ components out
10084− =/ component=(list term) i.components
10085− ?. (graph-cycle component graph) $(components t.components)
10086− =/ members=(list def)
10087− (skim ds |=(d=def &(?=(%value -.d) (lien component |=(n=term =(n name.d))))))
10088− ?. =((lent members) (lent component)) $(components t.components)
10089− ?. (cycle-proof-group members globals) $(components t.components)
10090− $(components t.components, out (weld (cycle-group-errors members component globals) out))
6803+ =/ next=ienv (add-supported-defs ds env molds globals externals surs mark-externals marks jimports reserved-molds at prelude)
6804+ ?: =(next env) env
6805+ $(env next)
100916806::
100926807+| %union-analysis
100936808::
@@ -10224,142 +6939,11 @@
102246939 [at.first at.second (union-relate a (project-union-mold second molds ~))]
102256940 (weld pairs $(cases t.cases))
102266941::
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)
103546942++ show-partial-mold
103556943 |= [file=path src=@t d=def molds=imolds]
103566944 ^- @t
103576945 ?> ?=(%mold -.d)
103586946 =/ 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])
103636947 =? sh ?=(%generic -.sh) body.sh
103646948 ?. ?=(%union -.sh) (crip "+$ {(trip name.d)}: not checked")
103656949 =/ pairs=(list upair) (union-pairs cases.sh molds)
@@ -10386,21 +6970,6 @@
103866970 (show-error src [file line.beg.at.site col.beg.at.site note.site])
103876971 (of-wain:format [summary excerpts])
103886972::
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−::
104046973:: +golden-types: a partial report; it does not claim the module checks
104056974::
104066975++ golden-types
@@ -10430,180 +6999,6 @@
104306999+$ jfile-result (each [iface=ifile cache=jcache] @t)
104317000+$ jimports-result (each [resolved=ijimports cache=jcache] @t)
104327001::
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− ==
106077002++ import-binding-names
106087003 |= imports=(list import)
106097004 ^- (list term)
@@ -10616,60 +7011,6 @@
106167011 ==
106177012 [n $(imports t.imports)]
106187013::
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−::
106737014++ module-scope-valid
106747015 |= [mod=module prelude-values=(list term) prelude-molds=(list term)]
106757016 ^- ?
@@ -10677,7 +7018,6 @@
106777018 =/ vals=(list term) (global-value-names defs.mod)
106787019 =/ molds=imolds (collect-simple-molds defs.mod)
106797020 =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10680− ?: (module-has-reserved-proj mod) |
106817021 ?. %+ levy imported
106827022 |= n=term
106837023 &((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))))
@@ -10685,22 +7025,6 @@
106857025 ?. (levy vals |=(n=term &((unique-value-name n vals) !(lien prelude-values |=(v=term =(n v)))))) |
106867026 (levy mold-names |=(n=term &((unique-value-name n mold-names) !(lien prelude-molds |=(m=term =(n m))))))
106877027::
10688−:: In an API file or before main's kind is known, a lone `+$ poke`
10689−:: may be a declaration rather than a mold that shadows the prelude. Do not call
10690−:: that one collision definite, and do not hide unrelated scope errors.
10691−++ pending-declared-poke
10692− |= [at=path mod=module prelude-values=(list term) prelude-molds=(list term)]
10693− ^- ?
10694− ?. (lien prelude-molds |=(n=term =(%poke n))) |
10695− ?. |(?=([%ui %api @ %jibb ~] at) (lien defs.mod |=(d=def &(?=(%value -.d) =(%main name.d))))) |
10696− =/ pokes=(list def)
10697− (skim defs.mod |=(d=def &(?=(%mold -.d) =(%poke name.d))))
10698− ?~ pokes |
10699− ?^ t.pokes |
10700− =/ remaining=(list def)
10701− (skim defs.mod |=(d=def !&(?=(%mold -.d) =(%poke name.d))))
10702− (module-scope-valid mod(defs remaining) prelude-values prelude-molds)
10703−::
107047028++ module-mold-types
107057029 |= [molds=imolds state=istate]
107067030 ^- (each imold-types @t)
@@ -10716,9 +7040,9 @@
107167040::
107177041:: Prepare a provisional interface from the trusted vendored source.
107187042:: Every declared name remains reserved, but only molds and values this
10719−:: fragment can infer are usable. Unsupported bodies are not validated.
10720−:: An optional internal source supplies the prelude's one supported import;
10721−:: clients cannot import that path directly. Named unions retain their origin.
7043+:: fragment can infer are usable. Unsupported bodies are not validated,
7044+:: and imports into the prelude are not supported yet. The fixed origin
7045+:: gives its named unions the same identity in every importing module.
107227046::
107237047:: Recognize only the complete standard prelude list shape. Its recursive
107247048:: tail uses the same parameter and the unqualified list name. The reader
@@ -10758,20 +7082,6 @@
107587082 ?. ?=(%tvar -.i.args.tail) |
107597083 =(var name.i.args.tail)
107607084::
10761−++ prelude-label
10762− |= [typ=itype name=term vars=(list @ud)]
10763− ^- itype
10764− ?: ?=(%jrec -.typ) typ(label `name)
10765− ?: ?=(%grec -.typ)
10766− ?. (identity-union-parameters vars args.typ) typ(label ~)
10767− typ(label `name)
10768− ?. ?=(%union -.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
10773− typ(label `name)
10774−::
107757085++ partial-prelude-molds
107767086 |= [molds=imolds state=istate]
107777087 ^- imold-types
@@ -10784,163 +7094,26 @@
107847094 (infer-mold-template body.m state(active [name.m active.state], in-mold &))
107857095 ?~ out $(molds t.molds)
107867096 =. typ.template.u.out (label-direct-union typ.template.u.out body.m name.m state)
10787− =. typ.template.u.out (prelude-label typ.template.u.out name.m vars.template.u.out)
107887097 [[name.m template.u.out] $(molds t.molds)]
107897098::
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−::
10881−++ partial-prelude-interface-with-internal
10882− |= [src=@t internal-source=(unit @t)]
7099+++ partial-prelude-interface
7100+ |= src=@t
108837101 ^- (unit ifile)
108847102 ?: =(0 src) ~
108857103 =/ at=path /lib/jibb/prelude/jibb
108867104 =/ parsed (parse at src)
108877105 ?: ?=(%| -.parsed) ~
10888− ?: (named-mold-has-hole defs.p.parsed) ~
10889− ?^ (duplicate-defs defs.p.parsed) ~
10890− =/ private=(unit ijimports)
10891− ?~ imports.p.parsed `~
10892− ?. ?=([[%jibb *] ~] imports.p.parsed) ~
10893− ?. =(path.i.imports.p.parsed /lib/jibb/internal) ~
10894− ?~ internal-source ~
10895− =/ built=(unit ifile) (infer-private-internal u.internal-source src)
10896− ?~ built ~
10897− `~[[face.i.imports.p.parsed u.built]]
10898− ?~ private ~
7106+ ?^ imports.p.parsed ~
108997107 ?~ defs.p.parsed ~
109007108 ?. (module-scope-valid p.parsed ~ ~) ~
109017109 =/ ds=(list def) defs.p.parsed
109027110 =/ molds=imolds (collect-simple-molds ds)
109037111 =/ names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10904− =/ globals=(list term) (weld (import-binding-names imports.p.parsed) (global-value-names ds))
10905− :: Remove raw list before inferring any template, so an altered list
10906− :: cannot leak through an alias. Its name remains reserved either way.
10907− =/ declared=? (lien names |=(name=term =(%list name)))
10908− =/ env-molds=imolds molds
10909− =? env-molds declared
10910− (skim molds |=(m=[name=term body=shape] !=(%list name.m)))
10911− =/ reserved=(list term) ?:(declared ~[%list] ~)
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 ~ ~ ~ ~ ~]
10922− :: An explicitly qualified re-export must resolve. Other unsupported
10923− :: prelude declarations remain reserved but absent from the interface.
10924− =/ required=imolds
10925− %+ skim molds
10926− |= m=[name=term body=shape]
10927− =/ sh=shape body.m
10928− ?. ?=(%ref -.sh) |
10929− ?~ names.sh |
10930− ?=(^ t.names.sh)
10931− ?. (levy required |=(m=[name=term body=shape] ?=(^ (find-jibb-mold name.m partial)))) ~
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 ~]
10939−::
10940−++ partial-prelude-interface
10941− |= src=@t
10942− ^- (unit ifile)
10943− (partial-prelude-interface-with-internal src ~)
7112+ =/ globals=(list term) (global-value-names ds)
7113+ =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ ~ ~ ~ ~ ~ | at names ~]
7114+ =/ mt=imold-types (partial-prelude-molds molds state)
7115+ =/ env=ienv (resolve-supported-defs ds molds globals ~ ~ ~ ~ ~ ~ at ~)
7116+ `[env mt at]
109447117::
109457118+$ iprelude [iface=ifile values=(list term) molds=(list term)]
109467119::
@@ -10955,17 +7128,6 @@
109557128 =/ ms=(list term) (turn (collect-simple-molds defs.p.parsed) |=(m=[name=term body=shape] name.m))
109567129 `[u.iface vals ms]
109577130::
10958−++ prepare-prelude-with-internal
10959− |= [src=@t internal-source=@t]
10960− ^- (unit iprelude)
10961− =/ iface=(unit ifile) (partial-prelude-interface-with-internal src `internal-source)
10962− ?~ iface ~
10963− =/ parsed (parse /lib/jibb/prelude/jibb src)
10964− ?: ?=(%| -.parsed) ~
10965− =/ vals=(list term) (global-value-names defs.p.parsed)
10966− =/ ms=(list term) (turn (collect-simple-molds defs.p.parsed) |=(m=[name=term body=shape] name.m))
10967− `[u.iface vals ms]
10968−::
109697131++ module-values-complete
109707132 |= [ds=(list def) env=ienv]
109717133 ^- ?
@@ -10986,76 +7148,12 @@
109867148 ?: =(at at.i.cache) `iface.i.cache
109877149 $(cache t.cache)
109887150::
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−::
110497151++ resolve-jibb-imports
110507152 |= [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)]
110517153 ^- jimports-result
110527154 ?~ imports [%& [~ cache]]
110537155 ?. ?=(%jibb -.i.imports) $(imports t.imports)
110547156 =/ at=path (weld path.i.imports `path`~[%jibb])
11055− ?: =(at /lib/jibb/internal/jibb)
11056− [%| 'the prelude internal module is private']
11057− ?: =(at /lib/jibb/primitives/jibb)
11058− [%| 'the prelude primitive interface is private']
110597157 ?: (lien active |=(p=path =(p at)))
110607158 [%| (crip "import cycle at {(spud at)}")]
110617159 =/ found=jbundle (skim modules |=(m=jsource =(at at.m)))
@@ -11063,882 +7161,39 @@
110637161 ?^ t.found [%| (crip "duplicate module sources: {(spud at)}")]
110647162 =/ cached=(unit ifile) (find-jibb-cache at cache)
110657163 =/ iface=jfile-result
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]]
7164+ ?^ cached [%& [u.cached cache]]
110767165 (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
110777166 ?: ?=(%| -.iface) [%| p.iface]
110787167 =/ rest=jimports-result $(imports t.imports, cache cache.p.iface)
110797168 ?: ?=(%| -.rest) rest
110807169 [%& [[[face.i.imports iface.p.iface] resolved.p.rest] cache.p.rest]]
110817170::
11082−:: Provisional declaration extraction only; this does not derive asks,
11083−:: validate imported types, or claim that an API module has checked.
11084−+$ iapi-path [at=span name=term segments=(list pseg) full=term diffs=(list term) scry=(unit (list pseg))]
11085−++ api-path-mark
11086− |= [sh=shape marks=(list term)]
11087− ^- (unit term)
11088− ?. ?=(%ref -.sh) ~
11089− ?. ?=([@ ~] names.sh) ~
11090− ?. (unique-value-name i.names.sh marks) ~
11091− `i.names.sh
11092−::
11093−++ api-path-diffs
11094− |= [shapes=(list shape) marks=(list term) used=(list term)]
11095− ^- (unit (list term))
11096− ?~ shapes `~
11097− =/ n=(unit term) (api-path-mark i.shapes marks)
11098− ?~ n ~
11099− ?: (lien used |=(x=term =(x u.n))) ~
11100− =/ rest=(unit (list term)) $(shapes t.shapes, used [u.n used])
11101− ?~ rest ~
11102− `[u.n u.rest]
11103−::
11104−++ api-path-payload
11105− |= [sh=shape marks=(list term)]
11106− ^- (unit [full=term diffs=(list term)])
11107− =/ direct=(unit term) (api-path-mark sh marks)
11108− ?^ direct `[u.direct ~]
11109− ?. ?=(%apply -.sh) ~
11110− ?. =(~[%facts] ref.sh) ~
11111− ?~ args.sh ~
11112− ?~ t.args.sh ~
11113− =/ full=(unit term) (api-path-mark i.args.sh marks)
11114− ?~ full ~
11115− =/ diffs=(unit (list term)) (api-path-diffs t.args.sh marks ~[u.full])
11116− ?~ diffs ~
11117− `[u.full u.diffs]
11118−::
11119−+$ iapi-parameter [name=term aura=@ta at=span]
11120−++ api-path-parameters
11121− |= [segments=(list pseg) seen=(list term)]
11122− ^- (unit (list iapi-parameter))
11123− ?~ segments `~
11124− ?: ?=(%knot -.i.segments) $(segments t.segments)
11125− =/ seg=pseg i.segments
11126− ?. ?=(%typed -.seg) ~
11127− ?: =(0 aura.seg) ~
11128− ?: (lien seen |=(n=term =(n name.seg))) ~
11129− =/ rest=(unit (list iapi-parameter)) $(segments t.segments, seen [name.seg seen])
11130− ?~ rest ~
11131− `[[name.seg aura.seg at.seg] u.rest]
11132−::
11133−++ api-scry-parameters-compatible
11134− |= [scry=(list iapi-parameter) watch=(list iapi-parameter)]
11135− ^- ?
11136− ?~ scry &
11137− ?. (lien watch |=(p=iapi-parameter &(=(name.p name.i.scry) =(aura.p aura.i.scry)))) |
11138− $(scry t.scry)
11139−::
11140−++ api-path-one
11141− |= [sh=shape marks=(list term)]
11142− ^- (unit iapi-path)
11143− ?. ?=(%cell -.sh) ~
11144− =/ fs=(list field) fields.sh
11145− ?~ fs ~
11146− ?~ t.fs ~
11147− ?~ t.t.fs ~
11148− ?: (gth (lent fs) 4) ~
11149− ?. ?=(%bare -.i.fs) ~
11150− =/ tag=shape shape.i.fs
11151− ?. ?=(%const -.tag) ~
11152− ?. =(%term form.lit.tag) ~
11153− =/ name=term val.lit.tag
11154− ?. (jibb-face-name name) ~
11155− ?. ?=(%bare -.i.t.fs) ~
11156− =/ path-shape=shape shape.i.t.fs
11157− ?. ?=(%path -.path-shape) ~
11158− ?. ?=(%bare -.i.t.t.fs) ~
11159− =/ payload=(unit [full=term diffs=(list term)]) (api-path-payload shape.i.t.t.fs marks)
11160− ?~ payload ~
11161− =/ scry=(unit (unit (list pseg)))
11162− ?~ t.t.t.fs `~
11163− =/ entry=field i.t.t.t.fs
11164− ?. ?=(%face -.entry) ~
11165− ?. =(%scry name.entry) ~
11166− ?. ?=(%path -.shape.entry) ~
11167− ``segs.shape.entry
11168− ?~ scry ~
11169− =/ params=(unit (list iapi-parameter)) (api-path-parameters segs.path-shape ~)
11170− ?~ params ~
11171− ?^ u.scry
11172− =/ scry-params=(unit (list iapi-parameter)) (api-path-parameters u.u.scry ~)
11173− ?~ scry-params ~
11174− ?. (api-scry-parameters-compatible u.scry-params u.params) ~
11175− `[at.sh name segs.path-shape full.u.payload diffs.u.payload u.scry]
11176− `[at.sh name segs.path-shape full.u.payload diffs.u.payload u.scry]
11177−::
11178−++ api-path-many
11179− |= [shapes=(list shape) marks=(list term) seen=(list term)]
11180− ^- (unit (list iapi-path))
11181− ?~ shapes `~
11182− =/ one=(unit iapi-path) (api-path-one i.shapes marks)
11183− ?~ one ~
11184− ?: (lien seen |=(n=term =(n name.u.one))) ~
11185− =/ rest=(unit (list iapi-path)) $(shapes t.shapes, seen [name.u.one seen])
11186− ?~ rest ~
11187− `[u.one u.rest]
11188−::
11189−++ api-path-declaration
11190− |= [sh=shape marks=(list term)]
11191− ^- (unit (list iapi-path))
11192− ?: ?=(%union -.sh) (api-path-many cases.sh marks ~)
11193− (api-path-many ~[sh] marks ~)
11194−::
11195−:: Derived gates share the value namespace. /% marks name molds; /- and
11196−:: /= also introduce faces that cannot be shadowed by a derived value.
11197−++ api-import-faces
11198− |= imports=(list import)
11199− ^- (list term)
11200− ?~ imports ~
11201− ?- -.i.imports
11202− %mark $(imports t.imports)
11203− %sur [name.i.imports $(imports t.imports)]
11204− %jibb [face.i.imports $(imports t.imports)]
11205− ==
11206−::
11207−++ api-derived-names-valid
11208− |= [paths=(list iapi-path) poke-names=(list term) mod=module prelude-values=(list term)]
11209− ^- ?
11210− =/ path-names=(list term) (turn paths |=(p=iapi-path name.p))
11211− =/ derived=(list term) (weld path-names poke-names)
11212− ?: (lien derived |=(n=term =(n %proj))) |
11213− =/ outer=(list term) (weld prelude-values (weld (global-value-names defs.mod) (api-import-faces imports.mod)))
11214− (levy derived |=(n=term &((unique-value-name n derived) !(lien outer |=(x=term =(n x))))))
11215−::
11216−:: Analysis only. Successful external entries must be unchanged results
11217−:: produced for the declared marks; no request interface is produced.
11218−+$ iapi-mark-type [name=term typ=itype]
11219−+$ iapi-path-typed [path=iapi-path full=itype diffs=(list iapi-mark-type)]
11220−++ api-diff-types
11221− |= [names=(list term) externals=imark-externals declared=(list term)]
11222− ^- (unit (list iapi-mark-type))
11223− ?~ names `~
11224− =/ typ=(unit itype) (find-imported-mark i.names externals declared)
11225− ?~ typ ~
11226− =/ tail=(unit (list iapi-mark-type)) $(names t.names)
11227− ?~ tail ~
11228− `[[i.names u.typ] u.tail]
11229−::
11230−++ api-path-types
11231− |= [paths=(list iapi-path) externals=imark-externals declared=(list term)]
11232− ^- (unit (list iapi-path-typed))
11233− ?~ paths `~
11234− =/ full=(unit itype) (find-imported-mark full.i.paths externals declared)
11235− ?~ full ~
11236− =/ diffs=(unit (list iapi-mark-type)) (api-diff-types diffs.i.paths externals declared)
11237− ?~ diffs ~
11238− =/ tail=(unit (list iapi-path-typed)) $(paths t.paths)
11239− ?~ tail ~
11240− `[[i.paths u.full u.diffs] u.tail]
11241−::
11242−++ api-poke-mark-names
11243− |= [pokes=(list def) declared=(list term)]
11244− ^- (unit (list term))
11245− ?~ pokes `~
11246− ?^ t.pokes ~
11247− =/ d=def i.pokes
11248− ?. ?=(%mold -.d) ~
11249− =/ sh=shape shape.d
11250− ?: ?=(%union -.sh) (api-path-diffs cases.sh declared ~)
11251− =/ name=(unit term) (api-path-mark sh declared)
11252− ?~ name ~
11253− `~[u.name]
11254−::
11255−++ api-path-analysis
11256− |= [mod=module externals=imark-externals prelude-values=(list term) prelude-molds=(list term)]
11257− ^- (unit (list iapi-path-typed))
11258− ?: (lien defs.mod def-has-hole) ~
11259− ?^ (duplicate-defs defs.mod) ~
11260− =/ ds=(list def) defs.mod
11261− =/ declarations=(list def)
11262− (skim ds |=(d=def &(?=(%mold -.d) =(%paths name.d))))
11263− ?. ?=([* ~] declarations) ~
11264− =/ pokes=(list def)
11265− (skim ds |=(d=def &(?=(%mold -.d) =(%poke name.d))))
11266− ?: (gth (lent pokes) 1) ~
11267− =/ ordinary=(list def)
11268− (skim ds |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
11269− ?. (module-scope-valid mod(defs ordinary) prelude-values prelude-molds) ~
11270− =/ declared=(list term) (collect-mark-imports imports.mod)
11271− =/ poke-names=(unit (list term)) (api-poke-mark-names pokes declared)
11272− ?~ poke-names ~
11273− =/ decl=def i.declarations
11274− ?> ?=(%mold -.decl)
11275− =/ paths=(unit (list iapi-path)) (api-path-declaration shape.decl declared)
11276− ?~ paths ~
11277− ?. (api-derived-names-valid u.paths u.poke-names mod prelude-values) ~
11278− (api-path-types u.paths externals declared)
11279−::
11280−:: Source/graph entry for path analysis only. The returned paths retain
11281−:: reader-derived mark types and import resolution has checked reachable
11282−:: Jibb dependencies. This is not an API interface or a module check.
11283−++ api-path-analysis-source
11284− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
11285− ^- (each (list iapi-path-typed) @t)
11286− ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path analysis requires /ui/api/<agent>.jibb']
11287− =/ parsed (parse file src)
11288− ?: ?=(%| -.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']
11292− =/ prelude=(unit ifile) `iface.u.prepared
11293− =/ deps=jimports-result
11294− (resolve-jibb-imports imports.p.parsed externals marks modules ~[file] values.u.prepared molds.u.prepared ~ prelude)
11295− ?: ?=(%| -.deps) [%| p.deps]
11296− =/ paths=(unit (list iapi-path-typed))
11297− (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
11298− ?~ paths [%| 'API path declaration needs unsupported analysis']
11299− [%& u.paths]
11300−::
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−::
11641−++ api-mark-exports
11642− |= [marks=(list term) all=(list term) externals=imark-externals]
11643− ^- imold-types
11644− ?~ marks ~
11645− =/ t=(unit itype) (find-imported-mark i.marks externals all)
11646− ?~ t $(marks t.marks)
11647− [[i.marks [u.t ~]] $(marks t.marks)]
11648−::
11649−:: Experimental direct poke-only API. Unsupported API declarations fail
11650−:: as a whole; supplied mark reader results retain their existing boundary.
11651−++ api-poke-interface
11652− |= [at=path mod=module mark-externals=imark-externals prelude-values=(list term) prelude-molds=(list term) prelude=(unit ifile)]
11653− ^- (unit ifile)
11654− ?: (lien defs.mod def-has-hole) ~
11655− ?. ?=([%ui %api @ %jibb ~] at) ~
11656− ?^ (duplicate-defs defs.mod) ~
11657− ?~ prelude ~
11658− ?. =(at.u.prelude /lib/jibb/prelude/jibb) ~
11659− =/ poke=(unit ischeme) (find-jibb-mold %poke u.prelude)
11660− ?~ poke ~
11661− ?. ?=(%union -.typ.u.poke) ~
11662− ?^ vars.u.poke ~
11663− =/ compatible=?
11664− %+ lien cases.typ.u.poke
11665− |= c=itype
11666− ?=([%cell [%const [%term %tas %agent *]] [%cell [%face %agent [%atom %tas]] [%cell [%face %mark [%atom %tas]] [%face %payload [%noun ~]]]]] c)
11667− ?. compatible ~
11668− ?. (module-scope-valid mod(defs ~) prelude-values prelude-molds) ~
11669− ?. (levy imports.mod |=(i=import ?=(%mark -.i))) ~
11670− =/ marks=(list term) (collect-mark-imports imports.mod)
11671− ?. ?=([@ ~] marks) ~
11672− =/ ds=(list def) defs.mod
11673− ?. ?=([[%mold *] ~] ds) ~
11674− ?. =(%poke name.i.ds) ~
11675− =/ sh=shape shape.i.ds
11676− ?. ?=([%ref *] sh) ~
11677− ?. ?=([@ ~] names.sh) ~
11678− =/ n=term i.names.sh
11679− ?. (unique-value-name n marks) ~
11680− ?: |((lien prelude-values |=(x=term =(n x))) (lien prelude-molds |=(x=term =(n x)))) ~
11681− =/ mark=(unit itype) (find-imported-mark n mark-externals marks)
11682− ?~ mark ~
11683− =/ sc=ischeme [[%fn u.mark typ.u.poke] ~]
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]]
11811−::
118127171++ infer-jibb-file
118137172 |= [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)]
118147173 ^- jfile-result
7174+ ?: ?=([%ui %api *] at) [%| (crip "API module needs unsupported inference: {(spud at)}")]
118157175 =/ parsed (parse at src)
118167176 ?: ?=(%| -.parsed) [%| (crip "module source does not parse: {(spud at)}")]
118177177 =/ mod=module p.parsed
11818− =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
11819− ?^ duplicate [%| (show-duplicate-fields at src u.duplicate)]
11820− ?: ?=([%ui %api *] at)
11821− =/ iface=(unit ifile) (api-poke-interface at mod mark-externals prelude-values prelude-molds prelude)
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]]]
11842− ?. (module-scope-valid mod prelude-values prelude-molds)
11843− ?: (pending-declared-poke at mod prelude-values prelude-molds)
11844− [%| (crip "module kind or scope needs unsupported inference: {(spud at)}")]
11845− [%| (crip "module has conflicting names: {(spud at)}")]
7178+ ?. (module-scope-valid mod prelude-values prelude-molds) [%| (crip "module has conflicting names: {(spud at)}")]
118467179 =/ vals=(list term) (global-value-names defs.mod)
118477180 ?: (lien vals |=(n=term =(n %main)))
118487181 [%| (crip "module kind needs unsupported inference: {(spud at)}")]
118497182 =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
118507183 ?: ?=(%| -.js) [%| p.js]
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
7184+ =/ molds=imolds (collect-simple-molds defs.mod)
118557185 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
118567186 =/ surs=(list term) (collect-sur-imports imports.mod)
118577187 =/ marks=(list term) (collect-mark-imports imports.mod)
118587188 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
118597189 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
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
7190+ =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude]
118747191 =/ mts=(each imold-types @t) (module-mold-types molds state)
118757192 ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
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
7193+ =/ env=ienv (resolve-supported-defs defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
118817194 ?. (module-values-complete defs.mod env)
118827195 [%| (crip "module definitions need unsupported inference: {(spud at)}")]
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]]
7196+ [%& [[env p.mts at] [[at [env p.mts at]] cache.p.js]]]
119427197::
119437198:: +golden-types-with-modules fails closed for imports without prelude
119447199:: scope. +golden-types-with-prelude resolves supported library graphs;
@@ -11949,8 +7204,6 @@
119497204 ^- @t
119507205 =/ parsed (parse file src)
119517206 ?: ?=(%| -.parsed) (show-error src p.parsed)
11952− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11953− ?^ duplicate (duplicate-fields-report file src u.duplicate)
119547207 ?: (lien imports.p.parsed |=(i=import ?=(%jibb -.i)))
119557208 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
119567209 (golden-types-with-marks file src externals mark-externals)
@@ -11965,8 +7218,6 @@
119657218 ^- @t
119667219 =/ parsed (parse file src)
119677220 ?: ?=(%| -.parsed) (show-error src p.parsed)
11968− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11969− ?^ duplicate (duplicate-fields-report file src u.duplicate)
119707221 ?: =(0 prelude-source) 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
119717222 =/ prelude (parse /lib/jibb/prelude/jibb prelude-source)
119727223 ?: ?=(%| -.prelude) 'partial inference; module not checked\0aprelude source does not parse; module import inference unsupported'
@@ -11974,26 +7225,16 @@
119747225 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
119757226 (golden-types-with-prepared-prelude file src externals mark-externals modules prepared)
119767227::
11977−++ golden-types-with-prelude-and-internal
11978− |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prelude-source=@t internal-source=@t]
11979− ^- @t
11980− =/ prepared=(unit iprelude) (prepare-prelude-with-internal prelude-source internal-source)
11981− (golden-types-with-prepared-prelude file src externals mark-externals modules prepared)
11982−::
119837228++ golden-types-with-prepared-prelude
119847229 |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prepared=(unit iprelude)]
119857230 ^- @t
119867231 =/ parsed (parse file src)
119877232 ?: ?=(%| -.parsed) (show-error src p.parsed)
11988− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11989− ?^ duplicate (duplicate-fields-report file src u.duplicate)
119907233 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
119917234 =/ prelude-values=(list term) values.u.prepared
119927235 =/ prelude-molds=(list term) molds.u.prepared
119937236 =/ iface=(unit ifile) `iface.u.prepared
119947237 ?. (module-scope-valid p.parsed prelude-values prelude-molds)
11995− ?: (pending-declared-poke file p.parsed prelude-values prelude-molds)
11996− 'partial inference; module not checked\0amodule kind or scope needs unsupported inference'
119977238 'partial inference; module not checked\0amodule has conflicting names'
119987239 =/ js=jimports-result
119997240 (resolve-jibb-imports imports.p.parsed externals mark-externals modules ~[file] prelude-values prelude-molds ~ iface)
@@ -12006,23 +7247,6 @@
120067247:: entries, as [mark result] with the result from +read-mark:jibb-import.
120077248:: Unknown, duplicated, failed and undeclared entries never resolve a mold.
120087249::
12009−:: Callers pass unchanged structured reader results; graph validation
12010−:: remains in the existing bridge, and failures stay available lazily.
12011−++ reader-result-for-checker
12012− |= result=*
12013− ^- *
12014− ?: ?=([%ok *] result) [%& +.result]
12015− result
12016−::
12017−++ golden-types-with-reader-diagnostics
12018− |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
12019− ^- @t
12020− =/ ex=iexternals
12021− (turn externals |=(e=[module=term name=term result=*] [module.e name.e (reader-result-for-checker result.e)]))
12022− =/ mx=imark-externals
12023− (turn mark-externals |=(e=[mark=term result=*] [mark.e (reader-result-for-checker result.e)]))
12024− (golden-types-with-marks file src ex mx)
12025−::
120267250++ golden-types-with-marks
120277251 |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
120287252 ^- @t
@@ -12034,20 +7258,12 @@
120347258 =. reserved-molds (weld reserved-molds (turn jimports |=(j=[face=term interface=ifile] face.j)))
120357259 =/ parsed (parse file src)
120367260 ?: ?=(%| -.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'
120417261 =/ ds=(list def) defs.p.parsed
120427262 =/ molds=imolds (collect-simple-molds ds)
120437263 =/ globals=(list term) (weld prelude-values (weld (turn jimports |=(j=[face=term interface=ifile] face.j)) (global-value-names ds)))
120447264 =/ surs=(list term) (collect-sur-imports imports.p.parsed)
120457265 =/ marks=(list term) (collect-mark-imports imports.p.parsed)
12046− =/ resolution=iresolved (resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds file prelude)
12047− =/ cycles=(list icycle) (definite-value-cycles ds globals)
12048− =/ 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)
7266+ =/ env=ienv (resolve-supported-defs ds molds globals externals surs mark-externals marks jimports reserved-molds file prelude)
120517267 =/ lines=(list @t) ~
120527268 |-
120537269 ?~ ds (of-wain:format ['partial inference; module not checked' (flop lines)])
@@ -12056,38 +7272,10 @@
120567272 $(ds t.ds, lines [(show-partial-mold file src d molds) lines])
120577273 ?. (unique-value-name name.d globals)
120587274 $(ds t.ds, lines [(crip "++ {(trip name.d)}: name already in scope") lines])
12059− =/ cycle=(list icycle) (skim cycles |=(c=icycle =(name.c name.d)))
12060− ?^ cycle
12061− =/ diag=idiag ["non-gate value depends on itself through a cycle" ~[[first.i.cycle "value in cycle"] [next.i.cycle "dependency in cycle"]]]
12062− $(ds t.ds, lines [(show-inference-diagnostic file src name.d diag) lines])
12063− ?: (lien grouped.resolution |=(n=term =(n name.d)))
12064− =/ found=(unit ischeme) (ienv-lookup name.d env)
12065− ?~ found $(ds t.ds, lines [(crip "++ {(trip name.d)}: recursive group unavailable") lines])
12066− =/ typ=itype (canonical-itype typ.u.found vars.u.found)
12067− =/ line=@t (crip "++ {(trip name.d)}: {(show-itype typ ~)}{(show-atom-constraint typ)}")
12068− $(ds t.ds, lines [line lines])
120697275 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
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
12073− =. initial (reserve-def-caps val.d initial)
12074− =/ result=iresult
12075− ?: |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
12076− (infer-recursive-gate d env initial)
12077− (infer-fragment val.d env initial)
7276+ =/ result=iresult (infer-fragment val.d env [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude])
120787277 ?: ?=(%| -.result)
120797278 $(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])
12085− =/ merged=(unit [first=icap second=icap])
12086− (merged-capitals caps.state.p.result sub.state.p.result)
12087− ?^ merged
12088− =/ diag=idiag
12089− ["distinct type variables `{(trip name.first.u.merged)}` and `{(trip name.second.u.merged)}` must not be forced equal; use the same capital for a shared type" ~[[at.first.u.merged "first type variable"] [at.second.u.merged "second type variable"]]]
12090− $(ds t.ds, lines [(show-inference-diagnostic file src name.d diag) lines])
120917279 ?: (constrained-capitals caps.state.p.result sub.state.p.result)
120927280 $(ds t.ds, lines [(crip "++ {(trip name.d)}: explicit capital constraints are not supported by partial inference") lines])
120937281 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
@@ -12104,126 +7292,7 @@
121047292 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
121057293 ?: (gth (lent vars) 26)
121067294 $(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])
121097295 =/ printable=itype (canonical-itype typ vars)
121107296 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
121117297 $(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−
122297298--