@@ -874,7 +874,7 @@
874 %'~[' %'|=(' %'$-(' :: openers
874 %'~[' %'|=(' %'$-(' :: openers
875 %'%/' %'/' :: paths
875 %'%/' %'/' :: paths
876 %'+' %'`' %'=' :: pair, unit, face
876 %'+' %'`' %'=' :: pair, unit, face
877− %'*' %'?' %'_' :: noun, loobean, type hole
877+ %'*' %'?' :: noun, loobean mold
878 %'++' %'+$' %'|=' %'|$' :: runes
878 %'++' %'+$' %'|=' %'|$' :: runes
879 %'^-' %'~&' %'?-' %'!!' :: runes
879 %'^-' %'~&' %'?-' %'!!' :: runes
880 %'/-' %'/%' %'/=' :: imports
880 %'/-' %'/%' %'/=' :: imports
@@ -1016,7 +1016,6 @@
1016 [%const at=span =lit] :: ~ %add %.y
1016 [%const at=span =lit] :: ~ %add %.y
1017 [%ref at=span names=(list term)] :: state item.todo
1017 [%ref at=span names=(list term)] :: state item.todo
1018 [%tvar at=span name=@t] :: M
1018 [%tvar at=span name=@t] :: M
1019− [%hole at=span ~] :: _
1020 [%path at=span segs=(list pseg)] :: / /todos /todo/[id=@ud]
1019 [%path at=span segs=(list pseg)] :: / /todos /todo/[id=@ud]
1021 [%apply at=span ref=(list term) args=(list shape)] :: (list @t)
1020 [%apply at=span ref=(list term) args=(list shape)] :: (list @t)
1022 [%cell at=span fields=(list field)] :: [text=@t done=?]
1021 [%cell at=span fields=(list field)] :: [text=@t done=?]
@@ -1025,9 +1024,9 @@
1025 [%generic at=span vars=(list @t) body=shape] :: +$ name |$ [M] …
1024 [%generic at=span vars=(list @t) body=shape] :: +$ name |$ [M] …
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]
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])
@@ -1296,7 +1295,6 @@
1296 (emit 1 %'=')
1295 (emit 1 %'=')
1297 ?: =('`' a) (emit 1 %'`')
1296 ?: =('`' a) (emit 1 %'`')
1298 ?: =('*' a) (emit 1 %'*')
1297 ?: =('*' a) (emit 1 %'*')
1299− ?: =('_' a) (emit 1 %'_')
1300 ?: =('~' a)
1298 ?: =('~' a)
1301 ?: =('[' b) (emit 2 %'~[')
1299 ?: =('[' b) (emit 2 %'~[')
1302 ?: =('&' b) (emit 2 %'~&')
1300 ?: =('&' b) (emit 2 %'~&')
@@ -1672,14 +1670,14 @@
1672:: What may begin each place the parser reads (section 3, Errors):
1670:: What may begin each place the parser reads (section 3, Errors):
1673:: an expression a-z 0-9 " ( [ ~ % / ` | ^ ? !
1671:: an expression a-z 0-9 " ( [ ~ % / ` | ^ ? !
1674:: an operand a-z 0-9 " ( [ ~ % / ` | !
1672:: an operand a-z 0-9 " ( [ ~ % / ` | !
1675−:: a mold a-z A-Z @ * ! ? ~ % / ( [ $ _
1673+:: a mold a-z A-Z @ * ! ? ~ % / ( [ $
1676:: a pattern a-z 0-9 " ~ % * [
1674:: a pattern a-z 0-9 " ~ % * [
1677:: and what may go tight after an operand: . ( + = after a name, a
1675:: and what may go tight after an operand: . ( + = after a name, a
1678:: closer ) ] }, or the : of a comment
1676:: closer ) ] }, or the : of a comment
1680++ expr-mask 0x57ff.ffff.4800.0000.83ff.8126.0000.0000
1678++ expr-mask 0x57ff.ffff.4800.0000.83ff.8126.0000.0000
1681++ operand-mask 0x57ff.ffff.0800.0000.03ff.8126.0000.0000
1679++ 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
1683++ bar-mask 0x1000.0000.0000.0000.0000.0000.0000.0000
1681++ bar-mask 0x1000.0000.0000.0000.0000.0000.0000.0000
1684++ pattern-mask 0x47ff.fffe.0800.0000.03ff.0424.0000.0000
1682++ pattern-mask 0x47ff.fffe.0800.0000.03ff.0424.0000.0000
1685++ after-mask 0x2000.0000.2000.0000.2400.4b00.0000.0000
1683++ after-mask 0x2000.0000.2000.0000.2400.4b00.0000.0000
@@ -2109,7 +2107,6 @@
2110 %knot (weld "/" (trip p.s))
2108 %knot (weld "/" (trip p.s))
2111 %typed "/[{(trip name.s)}=@{(trip aura.s)}]"
2109 %typed "/[{(trip name.s)}=@{(trip aura.s)}]"
2112− %inferred "/[{(trip name.s)}=_]"
2115++ show-tvars
2112++ show-tvars
@@ -2321,7 +2318,6 @@
2321 %const (nod "const" at.s (show-lit lit.s) ~)
2318 %const (nod "const" at.s (show-lit lit.s) ~)
2322 %ref (nod "ref" at.s (show-names names.s) ~)
2319 %ref (nod "ref" at.s (show-names names.s) ~)
2323 %tvar (nod "tvar" at.s (trip name.s) ~)
2320 %tvar (nod "tvar" at.s (trip name.s) ~)
2324− %hole (nod "hole" at.s "" ~)
2325 %path (nod "path" at.s (show-psegs segs.s) ~)
2321 %path (nod "path" at.s (show-psegs segs.s) ~)
2326 %apply (nod "apply" at.s (show-names ref.s) (turn args.s sexp-shape))
2322 %apply (nod "apply" at.s (show-names ref.s) (turn args.s sexp-shape))
2327 %cell (nod "cell" at.s "" (turn fields.s sexp-field))
2323 %cell (nod "cell" at.s "" (turn fields.s sexp-field))
@@ -3846,7 +3842,6 @@
3846 %'*' [%& [%noun at.t ~] t.ts]
3842 %'*' [%& [%noun at.t ~] t.ts]
3847 %'!!' [%& [%void at.t ~] t.ts]
3843 %'!!' [%& [%void at.t ~] t.ts]
3848 %'?' [%& [%flag at.t ~] t.ts]
3844 %'?' [%& [%flag at.t ~] t.ts]
3849− %'_' [%& [%hole at.t ~] t.ts]
3850 [%name *] [%& [%ref at.t ~[p.lex.t]] t.ts]
3845 [%name *] [%& [%ref at.t ~[p.lex.t]] t.ts]
3851 [%wing *] [%& [%ref at.t p.lex.t] t.ts]
3846 [%wing *] [%& [%ref at.t p.lex.t] t.ts]
3852 [%tvar *] [%& [%tvar at.t p.lex.t] t.ts]
3847 [%tvar *] [%& [%tvar at.t p.lex.t] t.ts]
@@ -4063,7 +4058,7 @@
4063 ?: &(?=(^ nex) tight.i.nex) (bad nex "a path segment")
4058 ?: &(?=(^ nex) tight.i.nex) (bad nex "a path segment")
4064 (bad-space i.after nex "a path segment")
4059 (bad-space i.after nex "a path segment")
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
4067 :: spaces, and where it ends
4062 :: spaces, and where it ends
4069 ++ read-pseg
4064 ++ read-pseg
@@ -4080,16 +4075,13 @@
4080 ?: |(?=(~ r2) !tight.i.r2) (bad-space i.r1 r2 "`=`")
4075 ?: |(?=(~ r2) !tight.i.r2) (bad-space i.r1 r2 "`=`")
4081 ?. ?=([[* * %'='] *] r2) (bad-in r2 "`=`" tis-mask)
4076 ?. ?=([[* * %'='] *] r2) (bad-in r2 "`=`" tis-mask)
4082 =/ r3=(list token) t.r2
4077 =/ r3=(list token) t.r2
4083− ?: |(?=(~ r3) !tight.i.r3) (bad-space i.r2 r3 "an aura or type hole")
4078+ ?: |(?=(~ r3) !tight.i.r3) (bad-space i.r2 r3 "an aura")
4084− ?. ?=([[* * ?([%aura *] %'_')] *] r3) (bad-in r3 "an aura or type hole" (con pat-mask (bex 95)))
4079+ ?. ?=([[* * [%aura *]] *] r3) (bad-in r3 "an aura" pat-mask)
4085 =/ r4=(list token) t.r3
4080 =/ r4=(list token) t.r3
4086 ?: |(?=(~ r4) !tight.i.r4) (bad-space i.r3 r4 "`]`")
4081 ?: |(?=(~ r4) !tight.i.r4) (bad-space i.r3 r4 "`]`")
4087 ?. ?=([[* * %']'] *] r4) (bad-in r4 "`]`" ser-mask)
4082 ?. ?=([[* * %']'] *] r4) (bad-in r4 "`]`" ser-mask)
4088 =/ at=span [beg.at.op end.at.i.r4]
4083 =/ at=span [beg.at.op end.at.i.r4]
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]
4095+| %span-check
4087+| %span-check
@@ -4473,7 +4465,6 @@
4473 %const [%const at.s ~[%lit] %one ~]
4465 %const [%const at.s ~[%lit] %one ~]
4474 %ref [%ref at.s ~[%name %wing] %one ~]
4466 %ref [%ref at.s ~[%name %wing] %one ~]
4475 %tvar [%tvar at.s ~[%tvar] %one ~]
4467 %tvar [%tvar at.s ~[%tvar] %one ~]
4476− %hole [%hole at.s ~[%'_'] %one ~]
4477 %apply [%apply at.s ~[%'('] %shut (turn args.s outline-shape)]
4468 %apply [%apply at.s ~[%'('] %shut (turn args.s outline-shape)]
4478 %cell [%cell at.s ~[%'['] %shut (turn fields.s outline-sample)]
4469 %cell [%cell at.s ~[%'['] %shut (turn fields.s outline-sample)]
@@ -4482,11 +4473,8 @@
4482 %+ murn segs.s
4473 %+ murn segs.s
4483 |= g=pseg
4474 |= g=pseg
4484 ^- (unit outline)
4475 ^- (unit outline)
4487− %typed `[%typed at.g ~[%'['] %shut ~]
4476+ ?. ?=(%typed -.g) ~
4488− %inferred `[%typed at.g ~[%'['] %shut ~[[%hole hole-at.g ~[%'_'] %one ~]]]
4477+ `[%typed at.g ~[%'['] %shut ~]
4490 [%path at.s ~[%'/'] %run ks]
4478 [%path at.s ~[%'/'] %run ks]
@@ -4546,8 +4534,6 @@
4546 [%path [1 9] [1 9] [1 21]]
4534 [%path [1 9] [1 9] [1 21]]
4547 [%face [1 7] [1 7] [1 21]]
4535 [%face [1 7] [1 7] [1 21]]
4549− :: an inferred path aura's hole spanning its = as well
4550− ['+$ x /a/[id=_]' ~[[%hole [1 13] [1 12] [1 14]]]]
4551 :: an import's path cut short
4537 :: an import's path cut short
4552 ['/= c /ui/c' ~[[%jibb [1 1] [1 1] [1 11]]]]
4538 ['/= c /ui/c' ~[[%jibb [1 1] [1 1] [1 11]]]]
4553 :: brackets that close with the deeper lines, cut at their line's
4539 :: brackets that close with the deeper lines, cut at their line's
@@ -4607,8 +4593,6 @@
4607:: Atom constraints tied to an explicit capital or an inferred sample
4593:: Atom constraints tied to an explicit capital or an inferred sample
4608:: are generalized and printed. Other aura variables remain unsupported until
4594:: are generalized and printed. Other aura variables remain unsupported until
4609:: their defaulting and inferred generalization are implemented.
4595:: 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.
4612:: Bare @ is a separate unrestricted atom type. A directional fit check
4596:: Bare @ is a separate unrestricted atom type. A directional fit check
4613:: permits concrete atoms to widen to it, never the reverse. A fit that
4597:: permits concrete atoms to widen to it, never the reverse. A fit that
4614:: needs a not-yet-implemented constraint remains unsupported. Named unions
4598:: needs a not-yet-implemented constraint remains unsupported. Named unions
@@ -4616,63 +4600,18 @@
4616:: from their display name. Generic cases must be disjoint for all arguments.
4600:: from their display name. Generic cases must be disjoint for all arguments.
4617:: Unnamed union printing is informational; it is not Jibb syntax.
4601:: Unnamed union printing is informational; it is not Jibb syntax.
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.
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.
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.
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.
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.
4660 $~ [%var 0]
4604 $~ [%var 0]
4661 $% [%var id=@ud]
4605 $% [%var id=@ud]
4662 [%avar id=@ud]
4606 [%avar id=@ud]
4664 [%nvar id=@ud]
4607 [%nvar id=@ud]
4666 [%atom aura=@ta]
4608 [%atom aura=@ta]
4667 [%any-atom ~]
4609 [%any-atom ~]
4668 [%flag ~]
4610 [%flag ~]
4670 [%tag id=@ud literal=lit constructor=?]
4611 [%tag id=@ud literal=lit constructor=?]
4671 [%const literal=lit]
4612 [%const literal=lit]
4672 [%collection name=term args=(list itype)]
4613 [%collection name=term args=(list itype)]
4673 [%recursive module=term name=term label=(unit @t)]
4614 [%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)]
4676 [%union cases=(list itype) origin=(unit [at=path name=term]) label=(unit @t) args=(list itype)]
4615 [%union cases=(list itype) origin=(unit [at=path name=term]) label=(unit @t) args=(list itype)]
4677 [%face name=term body=itype]
4616 [%face name=term body=itype]
4678 [%fn sample=itype product=itype]
4617 [%fn sample=itype product=itype]
@@ -4696,32 +4635,18 @@
4697 =/ found=(unit itype) (itype-lookup id.t sub)
4636 =/ found=(unit itype) (itype-lookup id.t sub)
4698 ?~ found t
4637 ?~ found t
4699− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4700 $(t u.found)
4638 $(t u.found)
4702 =/ found=(unit itype) (itype-lookup id.t sub)
4640 =/ found=(unit itype) (itype-lookup id.t sub)
4703 ?~ found t
4641 ?~ found t
4704− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4707− =/ found=(unit itype) (itype-lookup id.t sub)
4709− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4710 $(t u.found)
4642 $(t u.found)
4712 =/ found=(unit itype) (itype-lookup id.t sub)
4644 =/ found=(unit itype) (itype-lookup id.t sub)
4713 ?~ found t
4645 ?~ found t
4714− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4717− =/ found=(unit itype) (itype-lookup id.t sub)
4719− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4720 $(t u.found)
4646 $(t u.found)
4722 =/ found=(unit itype) (itype-lookup id.t sub)
4648 =/ found=(unit itype) (itype-lookup id.t sub)
4723 ?~ found t
4649 ?~ found t
4724− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4725 $(t u.found)
4650 $(t u.found)
@@ -4732,19 +4657,14 @@
4733 %var =(n id.t)
4658 %var =(n id.t)
4734 %avar =(n id.t)
4659 %avar =(n id.t)
4736 %nvar =(n id.t)
4660 %nvar =(n id.t)
4739 %any-atom |
4662 %any-atom |
4742 %tag =(n id.t)
4664 %tag =(n id.t)
4743 %const |
4665 %const |
4744 %union |((lien cases.t |=(c=itype (itype-occurs n c sub))) (lien args.t |=(c=itype (itype-occurs n c sub))))
4666 %union |((lien cases.t |=(c=itype (itype-occurs n c sub))) (lien args.t |=(c=itype (itype-occurs n c sub))))
4745 %recursive |
4667 %recursive |
4747− %grec (lien args.t |=(c=itype (itype-occurs n c sub)))
4748 %collection (lien args.t |=(c=itype (itype-occurs n c sub)))
4668 %collection (lien args.t |=(c=itype (itype-occurs n c sub)))
4749 %face $(t body.t)
4669 %face $(t body.t)
4750 %fn |($(t sample.t) $(t product.t))
4670 %fn |($(t sample.t) $(t product.t))
@@ -4763,11 +4683,6 @@
4763 =. a (itype-walk a sub)
4683 =. a (itype-walk a sub)
4764 =. b (itype-walk b sub)
4684 =. b (itype-walk b sub)
4765 ?: =(a b) `sub
4685 ?: =(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 ~)
4771 ?: &(?=(%recursive -.a) ?=(%recursive -.b))
4686 ?: &(?=(%recursive -.a) ?=(%recursive -.b))
4772 ?:(&(=(module.a module.b) =(name.a name.b)) `sub ~)
4687 ?:(&(=(module.a module.b) =(name.a name.b)) `sub ~)
4773 ?: &(?=(%union -.a) ?=(%union -.b))
4688 ?: &(?=(%union -.a) ?=(%union -.b))
@@ -4784,32 +4699,6 @@
4784 ?: ?=(%var -.b)
4699 ?: ?=(%var -.b)
4785 ?: (itype-occurs id.b a sub) ~
4700 ?: (itype-occurs id.b a sub) ~
4786 `[[id.b a] sub]
4701 `[[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]
4800− ?. |(?=(%rnvar -.b) ?=(%atom -.b)) ~
4805− ?: &(?=(%avar -.a) ?=(%rvar -.b)) `[[id.a b] sub]
4806− ?: &(?=(%rvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4808− ?. |(?=(%rvar -.b) ?=(%atom -.b)) ~
4813 :: The narrower decimal constraint survives a match with an atom
4702 :: The narrower decimal constraint survives a match with an atom
4814 :: variable; decimal syntax alone does not make it a loobean.
4703 :: variable; decimal syntax alone does not make it a loobean.
4815 ?: &(?=(%nvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4704 ?: &(?=(%nvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
@@ -4864,19 +4753,14 @@
4871 %any-atom &
4758 %any-atom &
4875 %const |
4761 %const |
4876 %union |((lien cases.t |=(c=itype (itype-has-any-atom c sub))) (lien args.t |=(c=itype (itype-has-any-atom c sub))))
4762 %union |((lien cases.t |=(c=itype (itype-has-any-atom c sub))) (lien args.t |=(c=itype (itype-has-any-atom c sub))))
4877 %recursive |
4763 %recursive |
4879− %grec (lien args.t |=(c=itype (itype-has-any-atom c sub)))
4880 %collection (lien args.t |=(c=itype (itype-has-any-atom c sub)))
4764 %collection (lien args.t |=(c=itype (itype-has-any-atom c sub)))
4881 %face $(t body.t)
4765 %face $(t body.t)
4882 %fn |($(t sample.t) $(t product.t))
4766 %fn |($(t sample.t) $(t product.t))
@@ -4939,19 +4823,14 @@
4939 ?- -.typ
4823 ?- -.typ
4946 %any-atom &
4828 %any-atom &
4950 %const &
4831 %const &
4951 %union |((lien cases.typ |=(c=itype (itype-has-fixed-atom c))) (lien args.typ |=(c=itype (itype-has-fixed-atom c))))
4832 %union |((lien cases.typ |=(c=itype (itype-has-fixed-atom c))) (lien args.typ |=(c=itype (itype-has-fixed-atom c))))
4952 %recursive |
4833 %recursive |
4954− %grec (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
4955 %collection (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
4834 %collection (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
4956 %face $(typ body.typ)
4835 %face $(typ body.typ)
4957 %fn |($(typ sample.typ) $(typ product.typ))
4836 %fn |($(typ sample.typ) $(typ product.typ))
@@ -4980,7 +4859,6 @@
4981 =. t (itype-walk t sub)
4860 =. t (itype-walk t sub)
4983− %grec (lien args.t |=(c=itype (itype-has-face c sub)))
4984 %collection (lien args.t |=(c=itype (itype-has-face c sub)))
4862 %collection (lien args.t |=(c=itype (itype-has-face c sub)))
4986 %cell |($(t hed.t) $(t tal.t))
4864 %cell |($(t hed.t) $(t tal.t))
@@ -4988,42 +4866,6 @@
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]
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]
5007− ?. &(?=(%cell -.a) ?=(%cell -.b)) |
5008− ?. (itype-closed-slot-match hed.a hed.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]
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 ~))
5027++ itype-face-asym-collection-args
4869++ itype-face-asym-collection-args
5028 |= [as=(list itype) bs=(list itype) sub=isub]
4870 |= [as=(list itype) bs=(list itype) sub=isub]
@@ -5037,15 +4879,12 @@
5038 =. a (itype-walk a sub)
4880 =. a (itype-walk a sub)
5039 =. b (itype-walk b sub)
4881 =. 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)
5043 ?: &(?=(%collection -.a) ?=(%collection -.b))
4882 ?: &(?=(%collection -.a) ?=(%collection -.b))
5044 ?. =(name.a name.b) |
4883 ?. =(name.a name.b) |
5045 (itype-face-asym-collection-args args.a args.b sub)
4884 (itype-face-asym-collection-args args.a args.b sub)
5046 ?: &(?=(%face -.a) ?=(%face -.b)) $(a body.a, b body.b)
4885 ?: &(?=(%face -.a) ?=(%face -.b)) $(a body.a, b body.b)
5047− ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%rvar -.b) |(?=(%nvar -.b) ?=(%rnvar -.b)))
4886+ ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%nvar -.b))
5048− ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%rvar -.a) |(?=(%nvar -.a) ?=(%rnvar -.a)))
4887+ ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%nvar -.a))
5049 ?: &(?=(%cell -.a) ?=(%cell -.b)) |($(a hed.a, b hed.b) $(a tal.a, b tal.b))
4888 ?: &(?=(%cell -.a) ?=(%cell -.b)) |($(a hed.a, b hed.b) $(a tal.a, b tal.b))
5050 ?: &(?=(%fn -.a) ?=(%fn -.b)) |($(a sample.a, b sample.b) $(a product.a, b product.b))
4889 ?: &(?=(%fn -.a) ?=(%fn -.b)) |($(a sample.a, b sample.b) $(a product.a, b product.b))
@@ -5068,30 +4907,6 @@
5068 [%cell $(actual hed.actual, expected hed.expected) $(actual tal.actual, expected tal.expected)]
4907 [%cell $(actual hed.actual, expected hed.expected) $(actual tal.actual, expected tal.expected)]
5069 expected
4908 expected
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]
5078− ?: &(?=(%fn -.actual) ?=(%fn -.expected) (itype-closed-gates-match actual expected)) |
5079− (itype-face-asym actual expected sub)
5081−++ itype-positional-face-asym
5082− |= [args=(list expr) actual=itype expected=itype sub=isub]
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)
5095++ itype-output-may-be-cell
4910++ itype-output-may-be-cell
5096 |= [t=itype sub=isub]
4911 |= [t=itype sub=isub]
@@ -5101,9 +4916,6 @@
5102 %union &
4917 %union &
5103 %recursive &
4918 %recursive &
5107 %collection &
4919 %collection &
5108 %face $(t body.t)
4920 %face $(t body.t)
5109 %fn |($(t sample.t) $(t product.t))
4921 %fn |($(t sample.t) $(t product.t))
@@ -5132,7 +4944,6 @@
5135− %grec (lien args.t |=(c=itype (itype-has-tag c)))
5136 %collection (lien args.t |=(c=itype (itype-has-tag c)))
4947 %collection (lien args.t |=(c=itype (itype-has-tag c)))
5137 %face $(t body.t)
4948 %face $(t body.t)
5138 %fn |($(t sample.t) $(t product.t))
4949 %fn |($(t sample.t) $(t product.t))
@@ -5146,7 +4957,6 @@
5148 %union &
4959 %union &
5149− %grec (lien args.t |=(c=itype (itype-has-union c)))
5150 %collection (lien args.t |=(c=itype (itype-has-union c)))
4960 %collection (lien args.t |=(c=itype (itype-has-union c)))
5151 %face $(t body.t)
4961 %face $(t body.t)
5152 %fn |($(t sample.t) $(t product.t))
4962 %fn |($(t sample.t) $(t product.t))
@@ -5165,7 +4975,6 @@
5166 ?: &(?=(~ label.t) ?=(^ args.t)) &
4976 ?: &(?=(~ label.t) ?=(^ args.t)) &
5167 (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-generic c)))
4977 (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))))
5169 %collection (lien args.t |=(c=itype (itype-has-hidden-generic c)))
4978 %collection (lien args.t |=(c=itype (itype-has-hidden-generic c)))
5170 %face $(t body.t)
4979 %face $(t body.t)
5171 %fn |($(t sample.t) $(t product.t))
4980 %fn |($(t sample.t) $(t product.t))
@@ -5178,8 +4987,6 @@
5180 %recursive &
4989 %recursive &
5183 %collection (lien args.t |=(c=itype (itype-has-recursive c)))
4990 %collection (lien args.t |=(c=itype (itype-has-recursive c)))
5184 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-recursive c)))
4991 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-recursive c)))
5185 %face $(t body.t)
4992 %face $(t body.t)
@@ -5193,8 +5000,6 @@
5195 %recursive ?=(~ label.t)
5002 %recursive ?=(~ label.t)
5196− %jrec ?=(~ label.t)
5197− %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-recursive c))))
5198 %collection (lien args.t |=(c=itype (itype-has-hidden-recursive c)))
5003 %collection (lien args.t |=(c=itype (itype-has-hidden-recursive c)))
5199 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-recursive c)))
5004 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-recursive c)))
5200 %face $(t body.t)
5005 %face $(t body.t)
@@ -5222,99 +5027,34 @@
5222 $(cases t.cases, good `trial)
5027 $(cases t.cases, good `trial)
5225−:: A constructor needs a case whose head has the same literal noun as its
5030+:: A constructor needs a case with its tag at the head and a payload
5226−:: tag. An unresolved or opaque case may reveal one later, so it cannot
5031+:: compatible with the expected gate sample. Other case forms do not
5227−:: prove a mismatch or a unique match. A broad atom mold is not a case.
5032+:: identify a constructor.
5229++ itype-fit-ctor-cases
5034++ itype-fit-ctor-cases
5230 |= [tag=lit sample=itype cases=(list itype) sub=isub next=@ud]
5035 |= [tag=lit sample=itype cases=(list itype) sub=isub next=@ud]
5232 =/ found=(unit ifit) ~
5037 =/ found=(unit ifit) ~
5236− ?: pending [%unknown ~]
5237− ?~ found [%bad ~]
5039+ ?~ cases ?~(found [%bad ~] u.found)
5239− =/ raw=itype i.cases
5241− $(cases t.cases, pending &)
5242− =/ c=itype (itype-walk raw sub)
5040+ =/ c=itype (itype-walk i.cases sub)
5243− ?: ?=(?(%var %tag %recursive %jrec %grec %union %face) -.c)
5244− $(cases t.cases, pending &)
5245 ?. ?=(%cell -.c) $(cases t.cases)
5041 ?. ?=(%cell -.c) $(cases t.cases)
5246− =/ raw-head=itype hed.c
5042+ =/ head=itype (itype-walk hed.c sub)
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)
5255− $(cases t.cases, pending &)
5256− ?: ?=(?(%var %tag %recursive %jrec %grec %union) -.head)
5257− $(cases t.cases, pending &)
5258 ?. ?=(%const -.head) $(cases t.cases)
5043 ?. ?=(%const -.head) $(cases t.cases)
5044+ ?. =(%term form.literal.head) $(cases t.cases)
5259 ?. =(val.literal.head val.tag) $(cases t.cases)
5045 ?. =(val.literal.head val.tag) $(cases t.cases)
5260− :: Equal heads can have disjoint payloads. Test each from the original
5046+ ?^ found [%unknown ~]
5261− :: substitution; a unique success is usable only with no unknown rival.
5262 =/ trial=ifit (itype-fit sample tal.c sub next)
5047 =/ trial=ifit (itype-fit sample tal.c sub next)
5264− %bad $(cases t.cases)
5265− %unknown $(cases t.cases, pending &)
5267− ?^ found [%unknown ~]
5268− $(cases t.cases, found `trial)
5048+ $(cases t.cases, found `trial)
5271++ itype-fit
5050++ itype-fit
5272 |= [actual=itype expected=itype sub=isub next=@ud]
5051 |= [actual=itype expected=itype sub=isub next=@ud]
5274− (itype-fit-inner actual expected sub next | |)
5276− |= [actual=itype expected=itype sub=isub next=@ud skip-width=? spine-proof=?]
5278− ?: &(!skip-width ?=(%cell -.actual) ?=(%cell -.expected) |((width-spine-exhausted actual 1.024) (width-spine-exhausted expected 1.024)))
5280− =/ known=(unit [source=iwfields target=iwfields])
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))
5286 =/ uncertain=?
5053 =/ uncertain=?
5287− |(?=(%var -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)) ?=(%var -.expected) ?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected)))
5054+ |(?=(%var -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%var -.expected) ?=(%avar -.expected) ?=(%nvar -.expected))
5289− |(?=(%var -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))
5290 =. actual (itype-walk actual sub)
5055 =. actual (itype-walk actual sub)
5291 =. expected (itype-walk expected sub)
5056 =. expected (itype-walk expected sub)
5292 ?: =(actual expected) [%ok sub next]
5057 ?: =(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]
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 ~]
5318 ?: &(?=(%recursive -.actual) ?=(%recursive -.expected))
5058 ?: &(?=(%recursive -.actual) ?=(%recursive -.expected))
5319 ?:(&(=(module.actual module.expected) =(name.actual name.expected)) [%ok sub next] [%bad ~])
5059 ?:(&(=(module.actual module.expected) =(name.actual name.expected)) [%ok sub next] [%bad ~])
5320 ?: &(|(?=(%recursive -.actual) ?=(%recursive -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
5060 ?: &(|(?=(%recursive -.actual) ?=(%recursive -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
@@ -5326,21 +5066,8 @@
5326 =/ unified=(unit isub) (itype-unify-args args.actual args.expected sub)
5066 =/ unified=(unit isub) (itype-unify-args args.actual args.expected sub)
5327 ?^ unified [%ok u.unified next]
5067 ?^ unified [%ok u.unified next]
5328 [%unknown ~]
5068 [%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)
5342 ?: ?=(%union -.actual) [%unknown ~]
5069 ?: ?=(%union -.actual) [%unknown ~]
5343− ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))) [%unknown ~]
5070+ ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%nvar -.actual))) [%unknown ~]
5344 ?: &(?=(%union -.expected) !?=(%var -.actual))
5071 ?: &(?=(%union -.expected) !?=(%var -.actual))
5345 (itype-fit-cases actual cases.expected sub next)
5072 (itype-fit-cases actual cases.expected sub next)
5346 ?: ?=(%tag -.actual)
5073 ?: ?=(%tag -.actual)
@@ -5348,7 +5075,7 @@
5348 =/ u=(unit isub) (itype-unify actual expected sub)
5075 =/ u=(unit isub) (itype-unify actual expected sub)
5349 ?~ u [%bad ~]
5076 ?~ u [%bad ~]
5350 [%ok u.u next]
5077 [%ok u.u next]
5351− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5078+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5352 ?: ?=(%face -.expected) $(expected body.expected)
5079 ?: ?=(%face -.expected) $(expected body.expected)
5353 ?: constructor.actual
5080 ?: constructor.actual
5354 ?. ?=(%fn -.expected) [%bad ~]
5081 ?. ?=(%fn -.expected) [%bad ~]
@@ -5357,10 +5084,6 @@
5357 =/ trial=ifit (itype-fit-ctor-cases literal.actual sample.expected cases sub next)
5084 =/ trial=ifit (itype-fit-ctor-cases literal.actual sample.expected cases sub next)
5358 ?. ?=(%ok -.trial) trial
5085 ?. ?=(%ok -.trial) trial
5359 [%ok [[id.actual expected] sub.trial] next.trial]
5086 [%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))
5364 ?: ?=(%const -.expected)
5087 ?: ?=(%const -.expected)
5365 ?:(=(val.literal.actual val.literal.expected) [%ok [[id.actual expected] sub] next] [%bad ~])
5088 ?:(=(val.literal.actual val.literal.expected) [%ok [[id.actual expected] sub] next] [%bad ~])
5366 ?: ?=(%atom -.expected)
5089 ?: ?=(%atom -.expected)
@@ -5376,17 +5099,11 @@
5376 =/ u=(unit isub) (itype-unify actual expected sub)
5099 =/ u=(unit isub) (itype-unify actual expected sub)
5377 ?~ u [%bad ~]
5100 ?~ u [%bad ~]
5378 [%ok u.u next]
5101 [%ok u.u next]
5379− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5102+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5380 ?: ?=(%face -.expected) $(expected body.expected)
5103 ?: ?=(%face -.expected) $(expected body.expected)
5381− ?: &(?=(%collection -.expected) =(%list name.expected) =(0 val.literal.actual))
5383 ?: ?=(%const -.expected)
5104 ?: ?=(%const -.expected)
5384 ?:(=(val.literal.actual val.literal.expected) [%ok sub next] [%bad ~])
5105 ?:(=(val.literal.actual val.literal.expected) [%ok sub next] [%bad ~])
5385 ?: ?=(%atom -.expected)
5106 ?: ?=(%atom -.expected)
5386− :: A loobean singleton must not silently widen into another aura.
5387− ?: =(%loobean form.literal.actual)
5388− ?: =(%f aura.expected) [%unknown ~]
5390 ?: |(=(%tas aura.expected) =(%ta aura.expected)) [%ok sub next]
5107 ?: |(=(%tas aura.expected) =(%ta aura.expected)) [%ok sub next]
5391 [%bad ~]
5108 [%bad ~]
5392 ?: ?=(%flag -.expected)
5109 ?: ?=(%flag -.expected)
@@ -5394,14 +5111,8 @@
5394 ?: ?=(%any-atom -.expected) [%ok sub next]
5111 ?: ?=(%any-atom -.expected) [%ok sub next]
5395 [%bad ~]
5112 [%bad ~]
5396 ?: &(uncertain (itype-face-asym actual expected sub)) [%unknown ~]
5113 ?: &(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 |)
5403 ?: ?=(%any-atom -.expected)
5114 ?: ?=(%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]
5405 ?: ?=(%var -.actual)
5116 ?: ?=(%var -.actual)
5406 =/ unified=(unit isub) (itype-unify actual [%avar next] sub)
5117 =/ unified=(unit isub) (itype-unify actual [%avar next] sub)
5407 ?~ unified [%bad ~]
5118 ?~ unified [%bad ~]
@@ -5412,16 +5123,16 @@
5412 =/ unified=(unit isub) (itype-unify actual expected sub)
5123 =/ unified=(unit isub) (itype-unify actual expected sub)
5413 ?~ unified [%bad ~]
5124 ?~ unified [%bad ~]
5414 [%ok u.unified next]
5125 [%ok u.unified next]
5415− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5126+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5416 [%bad ~]
5127 [%bad ~]
5417 ?: &(?=(%atom -.actual) ?=(%atom -.expected))
5128 ?: &(?=(%atom -.actual) ?=(%atom -.expected))
5418 ?: (aura-prefix aura.expected aura.actual) [%ok sub next]
5129 ?: (aura-prefix aura.expected aura.actual) [%ok sub next]
5419 ?: &((aura-prefix aura.actual aura.expected) uncertain) [%unknown ~]
5130 ?: &((aura-prefix aura.actual aura.expected) uncertain) [%unknown ~]
5420 [%bad ~]
5131 [%bad ~]
5421 ?: &(?=(%cell -.actual) ?=(%cell -.expected))
5132 ?: &(?=(%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)
5423 ?. ?=(%ok -.first) first
5134 ?. ?=(%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)
5425 :: A field may add a face to an occurrence of the very same type
5136 :: A field may add a face to an occurrence of the very same type
5426 :: variable. Binding that variable to a face around itself would fail
5137 :: variable. Binding that variable to a face around itself would fail
5427 :: the occurs check, but its underlying type has already matched.
5138 :: the occurs check, but its underlying type has already matched.
@@ -5443,10 +5154,9 @@
5443 [%ok u.unified next]
5154 [%ok u.unified next]
5444 ?: &(?=(%face -.actual) ?=(%face -.expected))
5155 ?: &(?=(%face -.actual) ?=(%face -.expected))
5445 ?. =(name.actual name.expected) [%bad ~]
5156 ?. =(name.actual name.expected) [%bad ~]
5446− $(actual body.actual, expected body.expected, skip-width |, spine-proof |)
5157+ $(actual body.actual, expected body.expected)
5447− ?: ?=(%face -.actual) $(actual body.actual, skip-width |, spine-proof |)
5158+ ?: ?=(%face -.actual) $(actual body.actual)
5448− ?: ?=(%face -.expected) $(expected body.expected, skip-width |, spine-proof |)
5159+ ?: ?=(%face -.expected) $(expected body.expected)
5449− ?: &(!uncertain (itype-closed-gates-match actual expected)) [%ok sub next]
5450 ?: (itype-face-asym actual expected sub) [%unknown ~]
5160 ?: (itype-face-asym actual expected sub) [%unknown ~]
5451 ?: |((itype-has-any-atom actual sub) (itype-has-any-atom expected sub))
5161 ?: |((itype-has-any-atom actual sub) (itype-has-any-atom expected sub))
5452 [%unknown ~]
5162 [%unknown ~]
@@ -5516,194 +5226,22 @@
5516 problems
5226 problems
5518:: The expression inference below is deliberately a fragment: bindings,
5228:: 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
5520:: result for unsupported syntax is a diagnostic, never a checked module.
5230:: result for unsupported syntax is a diagnostic, never a checked module.
5522+$ ischeme [typ=itype vars=(list @ud)]
5232+$ ischeme [typ=itype vars=(list @ud)]
5523+$ ienv (list [name=term scheme=ischeme])
5233+$ ienv (list [name=term scheme=ischeme])
5524+$ imold-types (list [name=term template=ischeme])
5234+$ imold-types (list [name=term template=ischeme])
5525−+$ iderived [name=term agent=term mark=term]
5235++$ ifile [values=ienv molds=imold-types at=path]
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.
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)]
5537+$ ijimports (list [face=term interface=ifile])
5236+$ ijimports (list [face=term interface=ifile])
5538−+$ icap [name=@t id=@ud at=span]
5237++$ icaps (list [name=@t id=@ud])
5539−+$ icaps (list icap)
5540+$ iparams (list [name=@t typ=itype])
5238+$ iparams (list [name=@t typ=itype])
5541+$ imolds (list [name=term body=shape])
5239+$ imolds (list [name=term body=shape])
5542:: A caller supplies the exact noun returned by +read-mold:jibb-import.
5240:: A caller supplies the exact noun returned by +read-mold:jibb-import.
5543:: This core has no Ford dependencies; unrecognized payloads fail closed.
5241:: This core has no Ford dependencies; unrecognized payloads fail closed.
5544+$ iexternals (list [module=term name=term result=*])
5242+$ iexternals (list [module=term name=term result=*])
5545+$ imark-externals (list [mark=term result=*])
5243+$ 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)]
5559− |= [typ=itype sub=isub axis=@ud fuel=@ud]
5561− =/ order=(list iwfield) ~
5562− =/ index=(map term iwfield) *(map term iwfield)
5565− ?: |(?=(%var -.typ) ?=(%avar -.typ) ?=(%rvar -.typ) ?=(%nvar -.typ) ?=(%rnvar -.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))
5578− |= [source=(list iwfield) target=(list iwfield)]
5582− ?: =(name.i.source name.i.target) $(source t.source, target t.target)
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)
5590− =/ fit=ifit (itype-fit typ.u.found typ.i.target sub next)
5592− =/ rest=(unit iwidth-result) $(target t.target, sub sub.fit, next next.fit)
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]
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)
5610− `[u.source u.target]
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)
5620− ?. (gth (lent order.u.source) (lent order.u.target)) ~
5621− `[u.source u.target]
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)
5630− ?: (lth (lent order.u.source) (lent order.u.target)) ~
5631− `[u.source u.target]
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)
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.
5646− $% [%field name=term]
5652−+$ igate-free [verdict=?(%yes %no %unknown) inhabited=? left=@ud path=(unit (list igf-segment))]
5654− |= [types=(list itype) fuel=@ud path=(list igf-segment) index=@ud]
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 ~]
5666− |= [typ=itype fuel=@ud path=(list igf-segment)]
5668− ?: =(0 fuel) [%unknown | 0 ~]
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])
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 ~]
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])
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 ~]
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)]
5707+$ idiag [msg=tape sites=(list [at=span note=tape])]
5245+$ idiag [msg=tape sites=(list [at=span note=tape])]
5708+$ iresult (each [typ=itype state=istate] idiag)
5246+$ iresult (each [typ=itype state=istate] idiag)
5709+$ isample-result (each [typ=itype env=ienv state=istate] tape)
5247+$ isample-result (each [typ=itype env=ienv state=istate] tape)
@@ -5723,7 +5261,6 @@
5723 |= [t=itype sub=isub]
5261 |= [t=itype sub=isub]
5724 ^- itype
5262 ^- itype
5725 =. t (itype-walk t sub)
5263 =. t (itype-walk t sub)
5726− ?: ?=(%grec -.t) t(args (turn args.t |=(c=itype (itype-normalize c sub))))
5727 ?: ?=(%collection -.t) [%collection name.t (turn args.t |=(c=itype (itype-normalize c sub)))]
5264 ?: ?=(%collection -.t) [%collection name.t (turn args.t |=(c=itype (itype-normalize c sub)))]
5728 ?: ?=(%union -.t)
5265 ?: ?=(%union -.t)
5729 [%union (turn cases.t |=(c=itype (itype-normalize c sub))) origin.t label.t (turn args.t |=(c=itype (itype-normalize c sub)))]
5266 [%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 @@
5740:: generalize an aura from its sample, which requires constraint analysis
5277:: generalize an aura from its sample, which requires constraint analysis
5741:: beyond this fragment; leave those cases unresolved.
5278:: beyond this fragment; leave those cases unresolved.
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.
5745++ itype-has-gate
5280++ itype-has-gate
5746 |= t=itype
5281 |= t=itype
@@ -5749,8 +5284,6 @@
5750 %cell |($(t hed.t) $(t tal.t))
5285 %cell |($(t hed.t) $(t tal.t))
5751 %recursive |
5286 %recursive |
5754 %collection (lien args.t |=(c=itype (itype-has-gate c)))
5287 %collection (lien args.t |=(c=itype (itype-has-gate c)))
5755 %face $(t body.t)
5288 %face $(t body.t)
5756 %union (lien cases.t |=(c=itype (itype-has-gate c)))
5289 %union (lien cases.t |=(c=itype (itype-has-gate c)))
@@ -5758,13 +5291,10 @@
5758 %const |
5291 %const |
5765 %any-atom |
5296 %any-atom |
5770++ default-decimals
5300++ default-decimals
@@ -5773,135 +5303,26 @@
5773 ?: (itype-has-gate t) t
5303 ?: (itype-has-gate t) t
5775 %nvar [%atom %ud]
5305 %nvar [%atom %ud]
5777− %grec t(args (turn args.t |=(c=itype (default-decimals c))))
5778 %collection [%collection name.t (turn args.t |=(c=itype (default-decimals c)))]
5306 %collection [%collection name.t (turn args.t |=(c=itype (default-decimals c)))]
5779 %face [%face name.t $(t body.t)]
5307 %face [%face name.t $(t body.t)]
5780 %cell [%cell $(t hed.t) $(t tal.t)]
5308 %cell [%cell $(t hed.t) $(t tal.t)]
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.
5800−++ hole-same-variable
5801− |= [a=itype b=itype]
5803− =/ x=(unit @ud) (hole-variable-id a)
5805− =/ y=(unit @ud) (hole-variable-id b)
5809− |= [t=itype state=istate]
5811− =. t (itype-walk t sub.state)
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))))
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)))
5822− %fn &($(t sample.t) $(t product.t))
5823− %cell &($(t hed.t) $(t tal.t))
5826−++ promote-restricted-numbers
5827− |= [state=istate env=ienv]
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)
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]))
5840−++ default-hole-numbers
5841− |= [all=(list ihole) prior=(list ihole) state=istate env=ienv permit=?]
5843− :: Do not default a named capital or a variable captured from env.
5845− ?: =(all prior) 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])
5853−:: Only obligations created inside this definition belong to it.
5855− |= [all=(list ihole) prior=(list ihole)]
5859− [i.all $(all t.all)]
5861− |= [t=itype state=istate]
5863− =. t (itype-walk t sub.state)
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)))
5870− %fn |($(t sample.t) $(t product.t))
5871− %cell |($(t hed.t) $(t tal.t))
5876− |= [all=(list ihole) prior=(list ihole) state=istate]
5878− =/ work=(list ihole) (flop (holes-created all prior))
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"]]]
5886++ itype-vars
5312++ itype-vars
5887 |= t=itype
5313 |= t=itype
5888 ^- (list @ud)
5314 ^- (list @ud)
5890 %var ~[id.t]
5316 %var ~[id.t]
5891 %avar ~[id.t]
5317 %avar ~[id.t]
5893 %nvar ~[id.t]
5318 %nvar ~[id.t]
5896 %any-atom ~
5320 %any-atom ~
5900 %const ~
5323 %const ~
5901 %union (zing (turn (weld args.t cases.t) |=(c=itype (itype-vars c))))
5324 %union (zing (turn (weld args.t cases.t) |=(c=itype (itype-vars c))))
5902 %recursive ~
5325 %recursive ~
5904− %grec (zing (turn args.t |=(c=itype (itype-vars c))))
5905 %collection (zing (turn args.t |=(c=itype (itype-vars c))))
5326 %collection (zing (turn args.t |=(c=itype (itype-vars c))))
5906 %face $(t body.t)
5327 %face $(t body.t)
5907 %fn (weld $(t sample.t) $(t product.t))
5328 %fn (weld $(t sample.t) $(t product.t))
@@ -5929,28 +5350,17 @@
5929 =/ found=(unit itype) (itype-lookup id.t ren)
5350 =/ found=(unit itype) (itype-lookup id.t ren)
5930 ?~ found t
5351 ?~ found t
5933− =/ found=(unit itype) (itype-lookup id.t ren)
5937 =/ found=(unit itype) (itype-lookup id.t ren)
5354 =/ found=(unit itype) (itype-lookup id.t ren)
5938 ?~ found t
5355 ?~ found t
5941− =/ found=(unit itype) (itype-lookup id.t ren)
5945 %any-atom t
5358 %any-atom t
5949 %const t
5361 %const t
5950 %union [%union (turn cases.t |=(c=itype (itype-rename c ren))) origin.t label.t (turn args.t |=(c=itype (itype-rename c ren)))]
5362 %union [%union (turn cases.t |=(c=itype (itype-rename c ren))) origin.t label.t (turn args.t |=(c=itype (itype-rename c ren)))]
5951 %recursive t
5363 %recursive t
5953− %grec t(args (turn args.t |=(c=itype (itype-rename c ren))))
5954 %collection [%collection name.t (turn args.t |=(c=itype (itype-rename c ren)))]
5364 %collection [%collection name.t (turn args.t |=(c=itype (itype-rename c ren)))]
5955 %face [%face name.t $(t body.t)]
5365 %face [%face name.t $(t body.t)]
5956 %fn [%fn $(t sample.t) $(t product.t)]
5366 %fn [%fn $(t sample.t) $(t product.t)]
@@ -5966,48 +5376,19 @@
5968 %avar =(n id.t)
5378 %avar =(n id.t)
5970 %nvar =(n id.t)
5379 %nvar =(n id.t)
5973 %any-atom |
5381 %any-atom |
5977 %const |
5384 %const |
5978 %union |((lien cases.t |=(c=itype (itype-var-is-atom n c))) (lien args.t |=(c=itype (itype-var-is-atom n c))))
5385 %union |((lien cases.t |=(c=itype (itype-var-is-atom n c))) (lien args.t |=(c=itype (itype-var-is-atom n c))))
5979 %recursive |
5386 %recursive |
5981− %grec (lien args.t |=(c=itype (itype-var-is-atom n c)))
5982 %collection (lien args.t |=(c=itype (itype-var-is-atom n c)))
5387 %collection (lien args.t |=(c=itype (itype-var-is-atom n c)))
5983 %face $(t body.t)
5388 %face $(t body.t)
5984 %fn |($(t sample.t) $(t product.t))
5389 %fn |($(t sample.t) $(t product.t))
5985 %cell |($(t hed.t) $(t tal.t))
5390 %cell |($(t hed.t) $(t tal.t))
5987−++ itype-var-is-restricted
6002− %union |((lien cases.t |=(c=itype (itype-var-is-restricted n c))) (lien args.t |=(c=itype (itype-var-is-restricted n c))))
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)))
6008− %fn |($(t sample.t) $(t product.t))
6009− %cell |($(t hed.t) $(t tal.t))
6012:: Canonical numbering makes printed variables independent of the order
5393:: Canonical numbering makes printed variables independent of the order
6013:: the unifier happened to allocate intermediates.
5394:: the unifier happened to allocate intermediates.
@@ -6019,7 +5400,7 @@
6019 =/ n=@ud 0
5400 =/ n=@ud 0
6021 ?~ vars (itype-rename t ren)
5402 ?~ 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])
6023 $(vars t.vars, ren [[i.vars replacement] ren], n +(n))
5404 $(vars t.vars, ren [[i.vars replacement] ren], n +(n))
6025++ instantiate-scheme
5406++ instantiate-scheme
@@ -6030,11 +5411,11 @@
6031 ?~ vars [(itype-rename typ.scheme ren) state]
5412 ?~ vars [(itype-rename typ.scheme ren) state]
6032 =/ replacement=itype
5413 =/ 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])
6034 :: A generalized atom variable is a valid origin for re-generalizing
5415 :: A generalized atom variable is a valid origin for re-generalizing
6035 :: an alias, just as a sample binder is.
5416 :: an alias, just as a sample binder is.
6036 =/ st=istate state(next +(next.state))
5417 =/ 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]
6038 $(vars t.vars, ren [[i.vars replacement] ren], state st)
5419 $(vars t.vars, ren [[i.vars replacement] ren], state st)
6040++ icap-lookup
5421++ icap-lookup
@@ -6105,11 +5486,6 @@
6105 ?. ?=([%ref @ @] node) ~
5486 ?. ?=([%ref @ @] node) ~
6106 ?. &(=(module +<.node) =(name +>.node)) ~
5487 ?. &(=(module +<.node) =(name +>.node)) ~
6107 `[[%unknown ~] &]
5488 `[[%unknown ~] &]
6109− ?. ?=([%apply %list [* ~]] node) ~
6110− =/ item $(node -.+>.node)
6112− `[[%or ~[[%atom `0] [%cell pat.u.item [%unknown ~]]]] has.u.item]
6114 ?. ?=([%face @ *] node) ~
5490 ?. ?=([%face @ *] node) ~
6115 ?. (jibb-face-name +<.node) ~
5491 ?. (jibb-face-name +<.node) ~
@@ -6148,70 +5524,12 @@
6148 $(pats t.pats)
5524 $(pats t.pats)
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.
6158−++ imported-faces-valid
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) |)
6168− ?. ?=([%named @ @ *] node) |
6169− =/ n=[%named module=@ name=@ body=*] ;;([%named module=@ name=@ body=*] node)
6170− (imported-faces-valid body.n)
6173−++ imported-faces-valid-list
6176− ?@ nodes =(nodes 0)
6177− ?. (imported-faces-valid -.nodes) |
6180−++ imported-record-faces-valid
6181− |= [node=* names=(list @)]
6183− ?: ?=([%cell * *] 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) |
6192− ?: ?=([%face @ *] node)
6193− ?: (lien names |=(n=@ =(n +<.node))) |
6194− (imported-faces-valid +>.node)
6195− (imported-faces-valid node)
6197++ import-to-itype
5527++ import-to-itype
6198 |= node=*
5528 |= node=*
6199 ^- (unit itype)
5529 ^- (unit itype)
6200 ?@ node ~
5530 ?@ node ~
6201 ?+ -.node ~
5531 ?+ -.node ~
6202− %noun ?:(=(node [%noun ~]) `[%noun ~] ~)
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)
6214− `[%const [%null %n 0 '~']]
6215 ?: ?=([%atom %tas [~ @]] node)
5533 ?: ?=([%atom %tas [~ @]] node)
6216 =/ value=@ +>+.node
5534 =/ value=@ +>+.node
6217 ?. |(=(value 0) (jibb-face-name value)) ~
5535 ?. |(=(value 0) (jibb-face-name value)) ~
@@ -6221,15 +5539,6 @@
6221 =/ aura=@ta (@ta +<.node)
5539 =/ aura=@ta (@ta +<.node)
6222 ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
5540 ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
6223 `[%atom aura]
5541 `[%atom aura]
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))
6232− `[%recursive (@tas module.n) (@tas name.n) `(crip "{(trip name.n)}.{(trip module.n)}")]
6234 ?. ?=([%apply @ *] node) ~
5543 ?. ?=([%apply @ *] node) ~
6235 =/ name=term (@tas +<.node)
5544 =/ name=term (@tas +<.node)
@@ -6243,15 +5552,10 @@
6243 ?. =(arity (lent u.args)) ~
5552 ?. =(arity (lent u.args)) ~
6244 `[%collection name u.args]
5553 `[%collection name u.args]
6246− :: Hoon's ordinary ? mold is the fork of its two %f singletons.
6248− ?: |(=(raw ~[[%atom %f `0] [%atom %f `1]]) =(raw ~[[%atom %f `1] [%atom %f `0]]))
6250− =/ cases=(unit (list itype)) (import-to-itypes raw)
5555+ =/ cases=(unit (list itype)) (import-to-itypes +.node)
6251 ?~ cases ~
5556 ?~ cases ~
6252 ?~ u.cases ~
5557 ?~ u.cases ~
6253 ?~ t.u.cases ~
5558 ?~ t.u.cases ~
6254− ?: (import-has-loobean-singleton u.cases) ~
6255 ?. (import-cases-disjoint u.cases) ~
5559 ?. (import-cases-disjoint u.cases) ~
6256 `[%union u.cases ~ ~ ~]
5560 `[%union u.cases ~ ~ ~]
@@ -6270,20 +5574,6 @@
6270 `[%cell u.left u.right]
5574 `[%cell u.left u.right]
6273−++ import-direct-loobean
6276− ?: ?=(%face -.t) $(t body.t)
6277− ?: ?=(%union -.t) (import-has-loobean-singleton cases.t)
6278− ?=([%const [%loobean *]] t)
6280−++ import-has-loobean-singleton
6281− |= cases=(list itype)
6284− ?: (import-direct-loobean i.cases) &
6287++ import-to-itypes
5577++ import-to-itypes
6288 |= nodes=*
5578 |= nodes=*
6289 ^- (unit (list itype))
5579 ^- (unit (list itype))
@@ -6298,9 +5588,7 @@
6298 |= typ=itype
5588 |= typ=itype
6300 ?- -.typ
5590 ?- -.typ
6302 %atom [%atom ~]
5591 %atom [%atom ~]
6303− %flag [%or ~[[%atom `0] [%atom `1]]]
6304 %const [%atom `val.literal.typ]
5592 %const [%atom `val.literal.typ]
6305 %face $(typ body.typ)
5593 %face $(typ body.typ)
6306 %cell [%cell $(typ hed.typ) $(typ tal.typ)]
5594 %cell [%cell $(typ hed.typ) $(typ tal.typ)]
@@ -6328,7 +5616,6 @@
6328 ?@ result ~
5616 ?@ result ~
6329 ?. ?=(%& -.result) ~
5617 ?. ?=(%& -.result) ~
6330 =/ node=* +.result
5618 =/ node=* +.result
6331− ?. (imported-faces-valid node) ~
6332 ?@ node (import-to-itype node)
5619 ?@ node (import-to-itype node)
6333 ?: ?=(%ref -.node) (import-to-itype node)
5620 ?: ?=(%ref -.node) (import-to-itype node)
6334 =/ pattern=(unit irec-pattern) (rec-pattern node module name)
5621 =/ pattern=(unit irec-pattern) (rec-pattern node module name)
@@ -6364,7 +5651,6 @@
6364 =/ result=* result.i.found
5651 =/ result=* result.i.found
6365 ?@ result ~
5652 ?@ result ~
6366 ?. ?=(%& -.result) ~
5653 ?. ?=(%& -.result) ~
6367− ?. (imported-faces-valid +.result) ~
6368 (import-to-itype +.result)
5654 (import-to-itype +.result)
6370++ find-jibb-interface
5656++ find-jibb-interface
@@ -6395,85 +5681,25 @@
6395 ?:(=(`origin origin.typ.template) `name.i.molds $(molds t.molds))
5681 ?:(=(`origin origin.typ.template) `name.i.molds $(molds t.molds))
6396 $(molds t.molds)
5682 $(molds t.molds)
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)]
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]
6415− =/ template=ischeme template.i.molds
6416− ?. ?=(%union -.typ.template) $(molds t.molds)
6417− ?. =(`origin origin.typ.template) $(molds t.molds)
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)))
6425−:: Names exported by the directly imported module are visible through its
5684+:: Only names exported by this directly imported module are visible through
6426−:: face; a matching prelude alias is also visible without a qualifier.
5685+:: its face. Other origins retain identity but print as unnamed unions.
6429− |= [origin=path name=term molds=imold-types]
6432− =/ template=ischeme template.i.molds
6433− ?: &(?=(~ vars.template) ?=(%jrec -.typ.template) =(at.typ.template origin) =(name.typ.template name)) `name.i.molds
6436−++ grec-visible-alias
6437− |= [origin=path name=term proof=shape args=(list itype) molds=imold-types]
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)
6446++ itype-in-import
5687++ itype-in-import
6447− |= [t=itype iface=ifile face=term prelude=(unit ifile)]
5688+ |= [t=itype iface=ifile face=term]
6448 ^- itype
5689 ^- itype
6451 =/ label=(unit @t)
5692 =/ label=(unit @t)
6452 ?~ origin.t ~
5693 ?~ origin.t ~
6453 ?: =(at.u.origin.t /lib/jibb/prelude/jibb) `name.u.origin.t
5694 ?: =(at.u.origin.t /lib/jibb/prelude/jibb) `name.u.origin.t
6454− =/ public=(unit term)
6456− (prelude-union-alias u.origin.t args.t molds.u.prelude)
6457− ?^ public `u.public
6458 =/ alias=(unit term) ~
5695 =/ alias=(unit term) ~
6459 =? alias &(=(at.u.origin.t at.iface) ?=(^ (find-jibb-mold name.u.origin.t iface))) `name.u.origin.t
5696 =? alias &(=(at.u.origin.t at.iface) ?=(^ (find-jibb-mold name.u.origin.t iface))) `name.u.origin.t
6460 =? alias ?=(~ alias) (imported-union-alias u.origin.t molds.iface)
5697 =? alias ?=(~ alias) (imported-union-alias u.origin.t molds.iface)
6461 ?~ alias ~
5698 ?~ alias ~
6462 `(crip "{(trip u.alias)}.{(trip face)}")
5699 `(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)))]
6464 %recursive [%recursive module.t name.t ~]
5701 %recursive [%recursive module.t name.t ~]
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))))
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)))]
6477 %face [%face name.t $(t body.t)]
5703 %face [%face name.t $(t body.t)]
6478 %fn [%fn $(t sample.t) $(t product.t)]
5704 %fn [%fn $(t sample.t) $(t product.t)]
6479 %cell [%cell $(t hed.t) $(t tal.t)]
5705 %cell [%cell $(t hed.t) $(t tal.t)]
@@ -6546,66 +5772,9 @@
6546 =/ rest=[params=iparams vars=(list @ud) next=@ud] $(names t.names, next +(next))
5772 =/ rest=[params=iparams vars=(list @ud) next=@ud] $(names t.names, next +(next))
6547 [[[i.names [%var next]] params.rest] [next vars.rest] next.rest]
5773 [[[i.names [%var next]] params.rest] [next vars.rest] next.rest]
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]
6556− ?. (lien top-molds.state |=(n=term =(n name))) ~
6557− =/ original=(unit shape) (find-simple-mold name molds.state)
6559− ?. =(u.original sh) ~
6560− ?. ?=(%union -.sh) ~
6561− =/ cs=(list shape) cases.sh
6565− ?. ?=(%const -.i.cs) ~
6566− ?. =(%null form.lit.i.cs) ~
6567− ?. ?=(%cell -.i.t.cs) ~
6568− =/ fs=(list field) fields.i.t.cs
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]
6582−++ simple-source-generic-recursive
6583− |= [name=term sh=shape args=(list itype) state=istate]
6585− ?. ?=(%generic -.sh) ~
6586− ?. ?=([@ ~] vars.sh) ~
6587− ?. ?=([* ~] args) ~
6588− ?~ grec-index.state ~
6589− ?. =(at.u.grec-index.state at.state) ~
6591− ?. =(prelude.u.grec-index.state u.prelude.state) ~
6592− =/ proof=(unit shape) (~(get by shapes.u.grec-index.state) name)
6595− `[%grec at.state name `name sh args]
6598++ infer-mold-template
5775++ infer-mold-template
6599 |= [sh=shape state=istate]
5776 |= [sh=shape state=istate]
6600 ^- (unit [template=ischeme state=istate])
5777 ^- (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]
6609 ?: ?=(%generic -.sh)
5778 ?: ?=(%generic -.sh)
6610 ?~ vars.sh ~
5779 ?~ vars.sh ~
6611 ?. (distinct-params vars.sh) ~
5780 ?. (distinct-params vars.sh) ~
@@ -6613,130 +5782,28 @@
6613 =/ out=(unit [typ=itype state=istate])
5782 =/ out=(unit [typ=itype state=istate])
6614 (infer-simple-shape body.sh state(next next.fresh, params params.fresh, in-mold &))
5783 (infer-simple-shape body.sh state(next next.fresh, params params.fresh, in-mold &))
6615 ?~ out ~
5784 ?~ out ~
6616− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
6617 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.sh) ?=(~ origin.typ.u.out)) ~
5785 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.sh) ?=(~ origin.typ.u.out)) ~
6618 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.sh))
5786 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.sh))
6619 typ.u.out(args (turn vars.fresh |=(n=@ud `itype`[%var n])))
5787 typ.u.out(args (turn vars.fresh |=(n=@ud `itype`[%var n])))
6620 =/ used=(list @ud) (itype-vars typ.u.out)
5788 =/ used=(list @ud) (itype-vars typ.u.out)
6621 ?. (levy used |=(n=@ud (lien vars.fresh |=(p=@ud =(p n))))) ~
5789 ?. (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)]
6623 =/ out=(unit [typ=itype state=istate])
5791 =/ out=(unit [typ=itype state=istate])
6624 (infer-simple-shape sh state(params ~, in-mold &))
5792 (infer-simple-shape sh state(params ~, in-mold &))
6625 ?~ out ~
5793 ?~ out ~
6626− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
6627 ?: ?=(^ (itype-vars typ.u.out)) ~
5794 ?: ?=(^ (itype-vars typ.u.out)) ~
6628− `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
5795+ `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state)]
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]
6637− =/ n=term i.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)))
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))))
6662− ?. ?=([%invalid ?(%aura %core %overlap) @] raw) ~
6663− `["{(trip +>.raw)}" ~[[at.sh "invalid imported mold"]]]
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]
6670− ?: ?=(^ (infer-simple-shape sh state)) ~
6673− =/ direct=(unit idiag) (direct-import-invalid sh state)
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)
6682− $(sh u.found, state state(active [n active.state], in-mold &, params ~))
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)
6691−++ nested-field-invalid
6692− |= [fields=(list field) state=istate]
6697− %bare shape.i.fields
6698− %face shape.i.fields
6699− %pun [%ref at.i.fields ~[name.i.fields]]
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)
6705−++ sample-import-invalid
6706− |= [s=sample env=ienv state=istate]
6708− =/ result=isample-result (infer-sample s env state)
6709− ?: ?=(%& -.result) ~
6710− ?. =(p.result "sample mold is not supported by partial inference") ~
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)
6719−++ nested-samples-invalid
6720− |= [items=(list sample) env=ienv state=istate]
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)
6727++ infer-simple-shape
5797++ infer-simple-shape
6728 |= [sh=shape state=istate]
5798 |= [sh=shape state=istate]
6729 ^- (unit [typ=itype state=istate])
5799 ^- (unit [typ=itype state=istate])
6731− %hole `[[%var next.state] state(next +(next.state), holes [[next.state at.sh] holes.state])]
6733 ?: =(0 aura.sh) `[[%any-atom ~] state]
5802 ?: =(0 aura.sh) `[[%any-atom ~] state]
6734 `[[%atom aura.sh] state]
5803 `[[%atom aura.sh] state]
6735 %flag `[[%flag ~] state]
5804 %flag `[[%flag ~] state]
6736− %noun `[[%noun ~] state]
6738− ?. |(=(%term form.lit.sh) =(%null form.lit.sh) =(%loobean form.lit.sh)) ~
5806+ ?. |(=(%term form.lit.sh) =(%null form.lit.sh)) ~
6739− ?: &(=(%loobean form.lit.sh) !|(=(0 val.lit.sh) =(1 val.lit.sh))) ~
6740 `[[%const lit.sh] state]
5807 `[[%const lit.sh] state]
6742 =/ pairs=(list upair) (union-pairs cases.sh molds.state)
5809 =/ pairs=(list upair) (union-pairs cases.sh molds.state)
@@ -6761,7 +5828,7 @@
6761 =/ found=(unit ischeme) (find-jibb-mold n u.iface)
5828 =/ found=(unit ischeme) (find-jibb-mold n u.iface)
6762 ?~ found ~
5829 ?~ found ~
6763 ?^ vars.u.found ~
5830 ?^ 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]
6765 =/ found=(unit itype)
5832 =/ found=(unit itype)
6766 (find-imported-mold i.t.names.sh n externals.state surs.state)
5833 (find-imported-mold i.t.names.sh n externals.state surs.state)
6767 ?~ found ~
5834 ?~ found ~
@@ -6780,13 +5847,10 @@
6780 ?~ prelude-entry ~
5847 ?~ prelude-entry ~
6781 ?^ vars.u.prelude-entry ~
5848 ?^ vars.u.prelude-entry ~
6782 `[typ.u.prelude-entry state]
5849 `[typ.u.prelude-entry state]
6783− =/ direct=(unit itype) (simple-source-recursive n u.found state)
6784− ?^ direct `[u.direct state]
6785 =/ out=(unit [typ=itype state=istate])
5850 =/ out=(unit [typ=itype state=istate])
6786 $(sh u.found, state state(active [n active.state], in-mold &, params ~))
5851 $(sh u.found, state state(active [n active.state], in-mold &, params ~))
6787 ?~ out ~
5852 ?~ 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)]
6791 ?~ ref.sh ~
5855 ?~ ref.sh ~
6792 =/ args=(unit [types=(list itype) state=istate]) (infer-shape-args args.sh state)
5856 =/ args=(unit [types=(list itype) state=istate]) (infer-shape-args args.sh state)
@@ -6801,7 +5865,7 @@
6801 ?~ vars.u.template ~
5865 ?~ vars.u.template ~
6802 =/ applied=(unit itype) (template-apply u.template types.u.args)
5866 =/ applied=(unit itype) (template-apply u.template types.u.args)
6803 ?~ applied ~
5867 ?~ 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]
6805 ?: (lien active.state.u.args |=(x=term =(x n))) ~
5869 ?: (lien active.state.u.args |=(x=term =(x n))) ~
6806 =/ found=(unit shape) (find-simple-mold n molds.state.u.args)
5870 =/ found=(unit shape) (find-simple-mold n molds.state.u.args)
6807 ?~ found
5871 ?~ found
@@ -6814,27 +5878,24 @@
6814 ?~ applied ~
5878 ?~ applied ~
6815 `[u.applied state.u.args]
5879 `[u.applied state.u.args]
6816 ?. ?=(%generic -.u.found) ~
5880 ?. ?=(%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]
6819 ?. (distinct-params vars.u.found) ~
5881 ?. (distinct-params vars.u.found) ~
6820 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
5882 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
6821 ?~ params ~
5883 ?~ params ~
6822 =/ out=(unit [typ=itype state=istate])
5884 =/ out=(unit [typ=itype state=istate])
6823 $(sh body.u.found, state state.u.args(active [n active.state.u.args], in-mold &, params u.params))
5885 $(sh body.u.found, state state.u.args(active [n active.state.u.args], in-mold &, params u.params))
6824 ?~ out ~
5886 ?~ out ~
6825− ?^ (unresolved-hole holes.state.u.out holes.state.u.args state.u.out) ~
6826 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.u.found) ?=(~ origin.typ.u.out)) ~
5887 ?: &(?=(%union -.typ.u.out) !?=(%union -.body.u.found) ?=(~ origin.typ.u.out)) ~
6827 ?: &(?=(%union -.typ.u.out) ?=(%union -.body.u.found) !(lien top-molds.state.u.args |=(x=term =(x n)))) ~
5888 ?: &(?=(%union -.typ.u.out) ?=(%union -.body.u.found) !(lien top-molds.state.u.args |=(x=term =(x n)))) ~
6828 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.u.found))
5889 =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.u.found))
6829 (label-direct-union typ.u.out(args types.u.args) u.found n state.u.args)
5890 (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)]
6832 =/ param=(unit itype) (iparam-lookup name.sh params.state)
5893 =/ param=(unit itype) (iparam-lookup name.sh params.state)
6833 ?^ param `[u.param state]
5894 ?^ param `[u.param state]
6834 ?: in-mold.state ~
5895 ?: in-mold.state ~
6835 =/ n=(unit @ud) (icap-lookup name.sh caps.state)
5896 =/ n=(unit @ud) (icap-lookup name.sh caps.state)
6836 ?^ n `[[%var u.n] state]
5897 ?^ 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])]
@@ -6867,12 +5928,12 @@
6867 ^- isample-result
5928 ^- isample-result
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))))
6871 [%| "sample shadows a name"]
5932 [%| "sample shadows a name"]
6872 =/ t=itype [%var next.state]
5933 =/ t=itype [%var next.state]
6873 [%& t [[name.s [t ~]] env] state(next +(next.state), binders [next.state binders.state])]
5934 [%& t [[name.s [t ~]] env] state(next +(next.state), binders [next.state binders.state])]
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))))
6876 [%| "sample shadows a name"]
5937 [%| "sample shadows a name"]
6877 =/ t=(unit [typ=itype state=istate]) (infer-simple-shape shape.s state)
5938 =/ t=(unit [typ=itype state=istate]) (infer-simple-shape shape.s state)
6878 ?~ t [%| "sample mold is not supported by partial inference"]
5939 ?~ t [%| "sample mold is not supported by partial inference"]
@@ -6910,8 +5971,8 @@
6910 [%& [%cell ht typ.p.tail] env.p.tail state.p.tail]
5971 [%& [%cell ht typ.p.tail] env.p.tail state.p.tail]
6912:: Local definitions generalize only variables outside their enclosing
5973:: Local definitions generalize only variables outside their enclosing
6913−:: environment and explicit-capital scope. Recursive gate groups use
5974+:: environment and explicit-capital scope. Unresolved groups stay
6914−:: monomorphic placeholders while their bodies are checked.
5975+:: unsupported: this fragment does not infer recursive definitions.
6916+$ ilocal-result (each [env=ienv state=istate] idiag)
5977+$ ilocal-result (each [env=ienv state=istate] idiag)
6917++ free-env-vars
5978++ free-env-vars
@@ -6940,7 +6001,6 @@
6942 ?: ?=(%mold -.i.ds) $(ds t.ds)
6003 ?: ?=(%mold -.i.ds) $(ds t.ds)
6943− ?: =(name.i.ds %proj) |
6944 ?. (unique-value-name name.i.ds names) |
6004 ?. (unique-value-name name.i.ds names) |
6945 ?: ?=(^ (ienv-lookup name.i.ds env)) |
6005 ?: ?=(^ (ienv-lookup name.i.ds env)) |
6946 ?: (lien globals.state |=(n=term =(n name.i.ds))) |
6006 ?: (lien globals.state |=(n=term =(n name.i.ds))) |
@@ -6964,7 +6024,6 @@
6965 ?~ locals &
6025 ?~ locals &
6966 =/ n=term name.i.locals
6026 =/ n=term name.i.locals
6968 ?. (unique-value-name n names) |
6027 ?. (unique-value-name n names) |
6969 ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) |
6028 ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) |
6970 ?: (lien marks.state |=(m=term =(n m))) |
6029 ?: (lien marks.state |=(m=term =(n m))) |
@@ -6982,145 +6041,6 @@
6982 ?~ inferred |
6041 ?~ inferred |
6983 $(locals t.locals)
6042 $(locals t.locals)
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]
6990− ^- (list icap-site)
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))
6998− =/ inside=(list icap-site) (scope-shape body.s)
6999− (skim inside |=(site=icap-site !(lien vars.s |=(v=@t =(v name.site)))))
7005− ^- (list icap-site)
7007− %face (scope-shape shape.f)
7008− %bare (scope-shape shape.f)
7014− ^- (list icap-site)
7016− %face (scope-shape shape.s)
7017− %bare (scope-shape shape.s)
7018− %cell (zing (turn items.s scope-sample))
7024− ^- (list icap-site)
7026− =/ first=(list icap-site)
7028− %expr (scope-expr p.i.ps)
7031− (weld first $(ps t.ps))
7035− ^- (list icap-site)
7037− =/ first=(list icap-site)
7039− %expr (scope-expr p.i.ps)
7042− (weld first $(ps t.ps))
7046− ^- (list icap-site)
7048− =/ first=(list icap-site) (scope-expr val.i.xs)
7049− (weld first $(xs t.xs))
7053− ^- (list icap-site)
7055− =/ first=(list icap-site) (scope-expr val.i.xs)
7056− (weld first $(xs t.xs))
7060− ^- (list icap-site)
7062− =/ first=(list icap-site) (scope-expr val.i.xs)
7063− (weld first $(xs t.xs))
7067− ^- (list icap-site)
7069− =/ first=(list icap-site) (scope-expr i.xs)
7070− (weld first $(xs t.xs))
7074− ^- (list icap-site)
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)
7085− =/ first=(list icap-site) (scope-sample sample.e)
7086− =/ last=(list icap-site) (scope-expr body.e)
7089− =/ first=(list icap-site) (scope-sample sample.e)
7090− =/ last=(list icap-site) (scope-expr body.e)
7093− =/ first=(list icap-site) (scope-expr head.e)
7094− =/ last=(list icap-site) (scope-exprs args.e)
7097− =/ first=(list icap-site) (scope-shape shape.e)
7098− =/ last=(list icap-site) (scope-expr val.e)
7101− =/ first=(list icap-site) (scope-expr val.e)
7102− =/ last=(list icap-site) (scope-expr then.e)
7105− =/ first=(list icap-site) (scope-expr subject.e)
7106− =/ last=(list icap-site) (scope-arms arms.e)
7108− %body (scope-expr final.e)
7112−++ reserve-cap-sites
7113− |= [sites=(list icap-site) state=istate]
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]))
7120− |= [e=expr state=istate]
7122− (reserve-cap-sites (scope-expr e) state)
7124++ infer-local-defs
6044++ infer-local-defs
7125 |= [ds=(list def) env=ienv state=istate]
6045 |= [ds=(list def) env=ienv state=istate]
7126 ^- ilocal-result
6046 ^- ilocal-result
@@ -7129,66 +6049,26 @@
7131 ?~ remaining [%& env state]
6051 ?~ remaining [%& env state]
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" ~]]
6052+ ?. progressed [%| ["local definitions need unsupported inference" ~]]
7138− $(ds rest.u.grouped, remaining ~, env env.u.grouped, state state.u.grouped, progressed |)
7139 $(ds (flop remaining), remaining ~, progressed |)
6053 $(ds (flop remaining), remaining ~, progressed |)
7140 =/ d=def i.ds
6054 =/ d=def i.ds
7141 ?> ?=(%value -.d)
6055 ?> ?=(%value -.d)
7142− =/ local-state=istate (reserve-def-caps val.d state)
7143− =/ inferred=iresult (infer-fragment val.d env local-state)
6056+ =/ inferred=iresult (infer-fragment val.d env state)
7144− =/ retried=? ?=(%| -.inferred)
7145− =? inferred retried (infer-recursive-gate d env local-state)
7146 ?: ?=(%| -.inferred) $(ds t.ds, remaining [d remaining])
6057 ?: ?=(%| -.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)
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" ~]]
7157 =/ typ=itype (itype-normalize typ.p.inferred sub.state.p.inferred)
6058 =/ typ=itype (itype-normalize typ.p.inferred sub.state.p.inferred)
7158 ?: |((pending-tags tags.state.p.inferred sub.state.p.inferred) (itype-has-tag typ))
6059 ?: |((pending-tags tags.state.p.inferred sub.state.p.inferred) (itype-has-tag typ))
7159 $(ds t.ds, remaining [d remaining])
6060 $(ds t.ds, remaining [d remaining])
7160 ?: (unsupported-atom-vars typ caps.state.p.inferred binders.state.p.inferred sub.state.p.inferred)
6061 ?: (unsupported-atom-vars typ caps.state.p.inferred binders.state.p.inferred sub.state.p.inferred)
7161 $(ds t.ds, remaining [d remaining])
6062 $(ds t.ds, remaining [d remaining])
7162 =/ free=(list @ud)
6063 =/ 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))
7164 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
6065 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
7165 =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
6066 =. 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 &)
6067+ $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred, progressed &)
7168−:: Try complete cyclic local groups after individual definitions stall.
7169−:: Components with non-gates or unresolved constraints stay unavailable.
7172− |= [ds=(list def) groups=icomponents env=ienv state=istate]
7173− ^- (unit [rest=(list def) env=ienv state=istate])
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)
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)
7187− `[rest env.p.result state.p.result]
7189:: Read only fields of a known record. Unresolved field constraints and
6069:: Read only fields of a known record. Unresolved field constraints and
7190−:: ambiguous repeated faces are outside this fragment. Imported record
6070+:: ambiguous repeated faces are outside this fragment (doc question:
7191−:: spines with repeated names are unavailable when used.
6071+:: whether duplicate imported Hoon faces are valid or select a field).
7193++ record-fields-named
6073++ record-fields-named
7194 |= [name=term t=itype sub=isub]
6074 |= [name=term t=itype sub=isub]
@@ -7207,33 +6087,21 @@
7207 ^- iresult
6087 ^- iresult
7208 =/ reverse=(list term) (flop names)
6088 =/ reverse=(list term) (flop names)
7209 ?~ reverse [%| ["empty wing" ~]]
6089 ?~ 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)
7211 =/ fields=(list term) t.reverse
6093 =/ fields=(list term) t.reverse
7212− ?~ fields [%| ["field access is not supported by partial inference" ~]]
7213− =/ scheme=(unit ischeme)
7215− (ienv-lookup i.reverse env)
7216− (ienv-lookup i.fields values.u.iface)
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)
7226 =/ typ=itype typ.inst
6094 =/ typ=itype typ.inst
7228− ?~ remaining [%& typ state.inst]
6096+ ?~ fields [%& typ state.inst]
7229− =/ found=(list itype) (record-fields-named i.remaining typ sub.state.inst)
6097+ =/ found=(list itype) (record-fields-named i.fields typ sub.state.inst)
7230 ?~ found [%| ["field is not available to partial inference" ~]]
6098 ?~ found [%| ["field is not available to partial inference" ~]]
7231 ?^ t.found [%| ["field name is ambiguous in partial inference" ~]]
6099 ?^ t.found [%| ["field name is ambiguous in partial inference" ~]]
7232− $(remaining t.remaining, typ i.found)
6100+ $(fields t.fields, typ i.found)
7234−:: Propagate a known union or list through supported loobean, unit and list
6102+:: Propagate a known union through supported loobean and unit branches. Empty bodies
7235−:: branches. Empty bodies and groups are transparent; bodies with definitions
6103+:: and groups are transparent; bodies with definitions keep their normal
7236−:: keep their normal scoping and wait for general bidirectional inference.
6104+:: scoping and wait for general bidirectional inference.
7238++ context-union-branch
6106++ context-union-branch
7239 |= e=expr
6107 |= e=expr
@@ -7250,8 +6118,6 @@
7250 ^- iresult
6118 ^- iresult
7251 ?: ?=(%group -.e) $(e inner.e)
6119 ?: ?=(%group -.e) $(e inner.e)
7252 ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
6120 ?: &(?=(%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)
7255 ?: ?=(%branch -.e)
6121 ?: ?=(%branch -.e)
7256 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
6122 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
7257 ?~ t.arms.e [%| ["branch pattern is not supported by partial inference" ~]]
6123 ?~ t.arms.e [%| ["branch pattern is not supported by partial inference" ~]]
@@ -7268,9 +6134,6 @@
7268 [%| ["branch does not cover both loobeans" ~]]
6134 [%| ["branch does not cover both loobeans" ~]]
7269 =/ subject=iresult (infer-fragment subject.e env state)
6135 =/ subject=iresult (infer-fragment subject.e env state)
7270 ?: ?=(%| -.subject) subject
6136 ?: ?=(%| -.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" ~]]
7274 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
6137 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
7275 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
6138 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
7276 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
6139 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
@@ -7282,33 +6145,20 @@
7282 ?: ?=(%| -.value) value
6145 ?: ?=(%| -.value) value
7283 =/ fit=ifit (itype-fit typ.p.value expected sub.state.p.value next.state.p.value)
6146 =/ fit=ifit (itype-fit typ.p.value expected sub.state.p.value next.state.p.value)
7284 ?: ?=(%unknown -.fit)
6147 ?: ?=(%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" ~]]
7288 [%| ["branch union constraint is not supported by partial inference" ~]]
6148 [%| ["branch union constraint is not supported by partial inference" ~]]
7289 ?: ?=(%bad -.fit)
6149 ?: ?=(%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"]]]]
7298 [%| ["branch arm does not fit its expected union" ~[[context "expected union"] [(span-of e) "branch arm"]]]]
6150 [%| ["branch arm does not fit its expected union" ~[[context "expected union"] [(span-of e) "branch arm"]]]]
7299 [%& expected state.p.value(sub sub.fit, next next.fit)]
6151 [%& expected state.p.value(sub sub.fit, next next.fit)]
7301−:: A list expression needs a known list target and the validated prelude list.
6153+:: A list literal 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.
6154+:: Its items receive that target one by one; pending constraints elsewhere
6155+:: stay in the threaded state. Other list syntax remains unsupported.
7305−++ context-list-expression
6157+++ context-list-literal
7306 |= e=expr
6158 |= e=expr
7311− %lit |(=(%null form.lit.e) &(=(%term form.lit.e) =(0 val.lit.e)))
7312 %group $(e inner.e)
6162 %group $(e inner.e)
7313 %body ?~(defs.e $(e final.e) |)
6163 %body ?~(defs.e $(e final.e) |)
@@ -7319,6 +6169,7 @@
7319 ^- iresult
6169 ^- iresult
7320 ?: ?=(%group -.e) $(e inner.e)
6170 ?: ?=(%group -.e) $(e inner.e)
7321 ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
6171 ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
7322 ?~ prelude.state [%| ["list literal needs the standard prelude in partial inference" ~]]
6173 ?~ prelude.state [%| ["list literal needs the standard prelude in partial inference" ~]]
7323 ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
6174 ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
7324 [%| ["list literal needs the standard prelude in partial inference" ~]]
6175 [%| ["list literal needs the standard prelude in partial inference" ~]]
@@ -7331,65 +6182,25 @@
7331 ?. =(%list name.target) [%| ["list context is not supported by partial inference" ~]]
6182 ?. =(%list name.target) [%| ["list context is not supported by partial inference" ~]]
7332 ?~ args.target [%| ["list context is not supported by partial inference" ~]]
6183 ?~ args.target [%| ["list context is not supported by partial inference" ~]]
7333 ?^ t.args.target [%| ["list context is not supported by partial inference" ~]]
6184 ?^ t.args.target [%| ["list context is not supported by partial inference" ~]]
7335− ?. |(=(%null form.lit.e) &(=(%term form.lit.e) =(0 val.lit.e)))
7336− [%| ["list expression is not supported by partial inference" ~]]
7339− =/ result=iresult (infer-list-items items.e i.args.target env state context)
6185+ =/ result=iresult (infer-list-items items.e i.args.target env state context)
7340− ?: ?=(%| -.result) result
6186+ ?: ?=(%| -.result) result
7341− [%& target state.p.result]
6187+ [%& 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)
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" ~]]
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)]
7362−++ infer-open-list-items
7363− |= [items=(list expr) expected=itype env=ienv state=istate context=span]
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" ~]]
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))
7379++ infer-list-items
6189++ infer-list-items
7380 |= [items=(list expr) expected=itype env=ienv state=istate context=span]
6190 |= [items=(list expr) expected=itype env=ienv state=istate context=span]
7381 ^- iresult
6191 ^- iresult
7382 ?~ items [%& expected state]
6192 ?~ items [%& expected state]
7383 =/ target=itype (itype-walk expected sub.state)
6193 =/ target=itype (itype-walk expected sub.state)
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))
7384− =/ value=iresult (infer-call-context-arg i.items target env state context)
6198+ (infer-list-context i.items target env state context)
6199+ (infer-fragment i.items env state)
7385 ?: ?=(%| -.value) value
6200 ?: ?=(%| -.value) value
7386 =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
6201 =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
7387 ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
6202 ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
7388 ?: ?=(%bad -.fit)
6203 ?: ?=(%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]
7393 [%| ["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)]]]]
6204 [%| ["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)]]]]
7394 $(items t.items, state state.p.value(sub sub.fit, next next.fit))
6205 $(items t.items, state state.p.value(sub sub.fit, next next.fit))
@@ -7482,7 +6293,7 @@
7482 [%| ["list branch pattern is not supported by partial inference" ~]]
6293 [%| ["list branch pattern is not supported by partial inference" ~]]
7483 =/ binder=(unit [head=term tail=term]) ?:(first-empty second-name first-name)
6294 =/ binder=(unit [head=term tail=term]) ?:(first-empty second-name first-name)
7484 ?~ binder [%| ["list branch pattern is not supported by partial inference" ~]]
6295 ?~ 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)))))
7486 [%| ["pattern binder shadows a name" ~]]
6297 [%| ["pattern binder shadows a name" ~]]
7487 =/ extended=ienv [[head.u.binder [i.args.typ ~]] [tail.u.binder [typ ~]] env]
6298 =/ extended=ienv [[head.u.binder [i.args.typ ~]] [tail.u.binder [typ ~]] env]
7488 =/ left=iresult
6299 =/ left=iresult
@@ -7519,7 +6330,7 @@
7519 [%| ["unit branch pattern is not supported by partial inference" ~]]
6330 [%| ["unit branch pattern is not supported by partial inference" ~]]
7520 =/ binder=(unit term) ?:(first-empty second-name first-name)
6331 =/ binder=(unit term) ?:(first-empty second-name first-name)
7521 ?~ binder [%| ["unit branch pattern is not supported by partial inference" ~]]
6332 ?~ 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))))
7523 [%| ["pattern binder shadows a name" ~]]
6334 [%| ["pattern binder shadows a name" ~]]
7524 =/ payload=(unit itype) (unit-union-payload typ)
6335 =/ payload=(unit itype) (unit-union-payload typ)
7525 ?~ payload [%| ["unit branch subject is not supported by partial inference" ~]]
6336 ?~ payload [%| ["unit branch subject is not supported by partial inference" ~]]
@@ -7537,628 +6348,10 @@
7537 ?~ joined [%| ["unit branch results need unsupported inference" ~]]
6348 ?~ joined [%| ["unit branch results need unsupported inference" ~]]
7538 [%& typ.p.left state.p.right(sub u.joined)]
6349 [%& typ.p.left state.p.right(sub u.joined)]
7540−:: Infer pieces in order, retaining their substitutions and pending tags.
6351+++ infer-fragment
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]
6352+ |= [e=expr env=ienv state=istate]
7546 ^- iresult
6353 ^- iresult
7547− ?~ ps [%& [%atom %t] state]
6354+ ?- -.e
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"]]]]
7563− [%| ["a cell in interpolation needs a printer" ~[[(span-of p.i.ps) "cell without a printer"]]]]
7564− [%| ["interpolation type needs unsupported inference" ~]]
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]
7574− ?~ t.ps (union-pattern i.ps t)
7575− =. t ?:(?=(%face -.t) body.t t)
7577− ?: |(?=(%atom -.t) ?=(%any-atom -.t) ?=(%flag -.t) ?=(%const -.t)) %none
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)
7585− |= [p=pattern t=itype]
7587− =. t ?:(?=(%face -.t) body.t t)
7592− ?: ?=(%const -.t) ?:(=(val.literal.t val.lit.p) %full %none)
7593− ?: ?=(%cell -.t) %none
7595− ?:(|(=(0 val.lit.p) =(1 val.lit.p)) %unknown %none)
7597− %str ?:(?=(%cell -.t) %none %unknown)
7598− %cell (union-pattern-items items.p t)
7601−++ union-pattern-has-bind
7606− (lien items.p union-pattern-has-bind)
7608−++ union-pattern-bind-items
7609− |= [ps=(list pattern) t=itype env=ienv globals=(list term)]
7612− ?~ t.ps (union-pattern-bind i.ps t env globals)
7613− =. t ?:(?=(%face -.t) body.t t)
7615− =/ first=(unit ienv) (union-pattern-bind i.ps hed.t env globals)
7617− $(ps t.ps, t tal.t, env u.first)
7619−++ union-pattern-bind
7620− |= [p=pattern t=itype env=ienv globals=(list term)]
7622− =. t ?:(?=(%face -.t) body.t t)
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)
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]
7635− |= [hs=(list itype) ts=(list itype) out=(list itype)]
7638− =/ rows=(list itype) (turn ts |=(t=itype [%cell i.hs t]))
7639− $(hs t.hs, out (weld rows out))
7643− ^- (unit (list itype))
7646− `~[[%const [%loobean %f 0 '%.y']] [%const [%loobean %f 1 '%.n']]]
7648− =/ body=(unit (list itype)) $(t body.t)
7650− `(turn u.body |=(x=itype [%face name.t x]))
7652− =/ hed=(unit (list itype)) $(t hed.t)
7654− =/ tal=(unit (list itype)) $(t tal.t)
7656− ?: (gth (mul (lent u.hed) (lent u.tal)) 64) ~
7657− `(finite-product u.hed u.tal ~)
7662− |= [xs=(list itype) out=(list ifinite) origin=@ud]
7663− ^- (unit (list ifinite))
7665− =/ parts=(unit (list itype)) (finite-type i.xs)
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))
7671−++ infer-known-union-whole
7672− |= [e=expr env=ienv subject=iresult]
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) ~
7686− `[%| ["missing union case {(show-itype i.remaining sub.st)}" ~]]
7687− ?~ answer `[%| ["empty union branch is not supported by partial inference" ~]]
7690− ?: (lien remaining |=(c=itype =(%unknown (union-pattern pat.a c))))
7692− =/ matching=(list itype) (skim remaining |=(c=itype =(%full (union-pattern pat.a c))))
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)
7708−++ infer-known-union-context-whole
7709− |= [e=expr expected=itype env=ienv subject=iresult context=span]
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) ~
7723− `[%| ["missing union case {(show-itype i.remaining sub.st)}" ~]]
7724− ?~ answer `[%| ["empty union branch is not supported by partial inference" ~]]
7727− ?: (lien remaining |=(c=itype =(%unknown (union-pattern pat.a c))))
7729− =/ matching=(list itype) (skim remaining |=(c=itype =(%full (union-pattern pat.a c))))
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" ~]]
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)
7752−++ infer-known-union-finite
7753− |= [e=expr env=ienv subject=iresult expected=(unit [typ=itype context=span])]
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) ~
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]
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))))
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" ~]]
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
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" ~]]
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)
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
7812− ?. ?=(%branch -.e) |
7815− =/ p=pattern pat.i.arms.e
7817− !(levy items.p |=(x=pattern ?=(%bind -.x)))
7819−++ infer-single-case-branch
7820− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
7822− ?> (single-structured-pattern 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" ~]]
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)]
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.
7854− |= [e=expr subject=iresult]
7856− ?: ?=(%| -.subject) subject
7857− ?. ?=(%branch -.e) subject
7858− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7859− ?. ?=(%jrec -.typ) 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))]
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]
7886− ?. ?=(%cell -.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 ~)
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)
7899− |= [e=expr subject=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
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))
7913− [%& view.u.view state.p.subject(jrec-fuel left.u.view)]
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]
7921− ?. ?=([@ ~] names.e) ~
7922− =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
7924− ?. (grec-direct-context typ.u.scheme sub.state) ~
7925− `(infer-fragment e env state)
7927−++ infer-known-union-branch-subject
7928− |= [e=expr env=ienv subject=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 ~)
7936−++ infer-known-union-branch
7937− |= [e=expr env=ienv state=istate]
7940− (infer-known-union-branch-subject e env (infer-fragment subject.e env state))
7942−++ infer-known-union-context-subject
7943− |= [e=expr expected=itype env=ienv subject=iresult context=span]
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])
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
7959− %str !(lien pieces.e |=(p=piece ?=(%expr -.p)))
7963−++ safe-union-subject
7966− ?: ?=(%group -.e) $(e inner.e)
7969− ?. ?=(%wing -.head.e) |
7970− (levy args.e simple-union-subject-arg)
7972−++ duplicate-loobean-arms
7975− ?. ?=(%branch -.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)
7985−++ union-subject-call
7988− ?: ?=(%group -.e) $(e inner.e)
7991−++ known-union-subject
7992− |= [e=expr env=ienv state=istate]
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))) ~
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]
8007− =. t (itype-walk t sub)
8010− =/ first=itype (itype-walk hed.t sub)
8011− ?. ?=(%face -.first) |
8014−++ infer-change-edits
8015− |= [edits=(list edit) target=itype env=ienv state=istate seen=(list term)]
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)
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" ~]]
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])
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]
8041− ?. =(at /lib/jibb/prelude/jibb) |
8043− ?^ t.vars.template |
8044− =/ v=@ud i.vars.template
8045− =/ nil=itype [%const [%null %n 0 '~']]
8047− [%union ~[nil [%cell nil [%face %u [%var v]]]] `[at %unit] `%unit ~[[%var v]]]
8048− =(typ.template expected)
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]
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
8066− |= [t=itype value=@ sub=isub]
8068− =. t (itype-walk t sub)
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)
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
8081− %union (tag-presence-cases cases.t value sub)
8085−++ missing-union-tag
8086− |= [e=expr expected=itype sub=isub context=span]
8089− ?. =(%term form.lit.e) ~
8090− =. expected (itype-walk expected sub)
8092− ?: ?=(%face -.expected) $(expected (itype-walk body.expected sub))
8093− ?. ?=(%union -.expected) ~
8094− ?. =(%no (tag-presence-cases cases.expected val.lit.e sub)) ~
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"]]]
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]
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)
8119− ?. ?=(%tuple -.e) ~
8120− (nested-missing-items items.e actual expected sub next context)
8122−++ nested-missing-items
8123− |= [items=(list item) actual=itype expected=itype sub=isub next=@ud context=span]
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)
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.
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]]]
8148−:: A segment costs one shared step; dynamic segments are not handled yet.
8150− |= [segs=(list qseg) fuel=@ud]
8154− ?. ?=(%knot -.i.segs) ~
8155− $(segs t.segs, fuel (dec fuel))
8158− |= [e=expr env=ienv state=istate]
8161− %pair $(e (pair-as-cell e))
8163 ?- form.lit.e
6356 ?- form.lit.e
8164 %number ?: =(%ud aura.lit.e)
6357 %number ?: =(%ud aura.lit.e)
@@ -8172,45 +6365,10 @@
8172 %term [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
6365 %term [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
8173 %null [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
6366 %null [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
8176− ?~ prelude.state [%| ["unit construction needs the standard prelude in partial inference" ~]]
6369+ =/ interpolated=? (lien pieces.e |=(p=piece ?=(%expr -.p)))
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" ~]]
6370+ ?: interpolated [%| ["interpolation is not supported by partial inference" ~]]
8185− [%& u.result state.p.value]
6371+ [%& [%atom %t] state]
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)
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)]
8215 ?~ names.e [%| ["empty wing" ~]]
6373 ?~ names.e [%| ["empty wing" ~]]
8216 ?^ t.names.e
6374 ?^ t.names.e
@@ -8219,7 +6377,7 @@
8219 ?~ iface (infer-field-wing names.e env state)
6377 ?~ iface (infer-field-wing names.e env state)
8220 =/ member=(unit ischeme) (ienv-lookup i.names.e values.u.iface)
6378 =/ member=(unit ischeme) (ienv-lookup i.names.e values.u.iface)
8221 ?~ member [%| ["module member is not available to partial inference" ~]]
6379 ?~ 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)
8223 =/ instance=[typ=itype state=istate] (instantiate-scheme u.member state)
6381 =/ instance=[typ=itype state=istate] (instantiate-scheme u.member state)
8224 [%& typ.instance state.instance]
6382 [%& typ.instance state.instance]
8225 =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
6383 =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
@@ -8232,11 +6390,6 @@
8232 =/ instance=[typ=itype state=istate] (instantiate-scheme u.scheme state)
6390 =/ instance=[typ=itype state=istate] (instantiate-scheme u.scheme state)
8233 [%& typ.instance state.instance]
6391 [%& typ.instance state.instance]
8234 %group $(e inner.e)
6392 %group $(e inner.e)
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 ~)
8240 %ctor [%& [%tag next.state tag.e &] state(next +(next.state), tags [[next.state tag.e] tags.state])]
6393 %ctor [%& [%tag next.state tag.e &] state(next +(next.state), tags [[next.state tag.e] tags.state])]
8242 =/ traced=iresult $(e val.e)
6395 =/ traced=iresult $(e val.e)
@@ -8253,9 +6406,6 @@
8253 [%| ["local molds shadow a name" ~]]
6406 [%| ["local molds shadow a name" ~]]
8254 =/ local-state=istate
6407 =/ local-state=istate
8255 state(globals (weld local-names globals.state), molds (weld local-molds molds.state))
6408 state(globals (weld local-names globals.state), molds (weld local-molds molds.state))
8256− =/ mold-hole=(unit span) (simple-local-mold-hole defs.e)
8258− [%| ["type hole needs a determined type" ~[[u.mold-hole "unresolved type hole"]]]]
8259 ?. (local-molds-supported local-molds local-state)
6409 ?. (local-molds-supported local-molds local-state)
8260 [%| ["local molds need unsupported inference" ~]]
6410 [%| ["local molds need unsupported inference" ~]]
8261 =/ values=(list def) (local-value-defs defs.e)
6411 =/ values=(list def) (local-value-defs defs.e)
@@ -8266,32 +6416,20 @@
8266 [%& typ.p.result state.p.result(globals globals.state, molds molds.state)]
6416 [%& typ.p.result state.p.result(globals globals.state, molds molds.state)]
8268 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
6418 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
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 ~)
6419+ ?~ t.arms.e (infer-cell-branch e env state)
8274− ?^ t.t.arms.e (infer-known-union-branch e env state)
6420+ ?^ t.t.arms.e [%| ["branch is not supported by partial inference" ~]]
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)
8279 =/ x=arm i.arms.e
6421 =/ x=arm i.arms.e
8280 =/ y=arm i.t.arms.e
6422 =/ y=arm i.t.arms.e
8281 ?: |((unit-empty-pattern pat.x) (unit-empty-pattern pat.y))
6423 ?: |((unit-empty-pattern pat.x) (unit-empty-pattern pat.y))
8282 (infer-unit-branch e env state ~)
6424 (infer-unit-branch e env state ~)
8283− ?. ?=(%lit -.pat.x) (infer-known-union-branch e env state)
6425+ ?. ?=(%lit -.pat.x) [%| ["branch pattern is not supported by partial inference" ~]]
8284− ?. ?=(%lit -.pat.y) (infer-known-union-branch e env state)
6426+ ?. ?=(%lit -.pat.y) [%| ["branch pattern is not supported by partial inference" ~]]
8285 ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y))
6427 ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y))
8286− (infer-known-union-branch e env state)
6428+ [%| ["branch pattern is not supported by partial inference" ~]]
8287− ?: &(?=(^ known) ?=(%& -.u.known)) (infer-known-union-branch-subject e env u.known)
8288 ?: =(val.lit.pat.x val.lit.pat.y)
6429 ?: =(val.lit.pat.x val.lit.pat.y)
8289 [%| ["branch does not cover both loobeans" ~]]
6430 [%| ["branch does not cover both loobeans" ~]]
8290 =/ subject=iresult $(e subject.e)
6431 =/ subject=iresult $(e subject.e)
8291 ?: ?=(%| -.subject) subject
6432 ?: ?=(%| -.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" ~]]
8295 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
6433 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
8296 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
6434 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
8297 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
6435 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
@@ -8318,776 +6456,64 @@
8318 [%& typ.p.left state.p.right(sub u.joined)]
6456 [%& typ.p.left state.p.right(sub u.joined)]
8320 =/ target=(unit [typ=itype state=istate]) (infer-simple-shape shape.e state)
6458 =/ target=(unit [typ=itype state=istate]) (infer-simple-shape shape.e state)
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" ~]]
8325 =/ value=iresult
6460 =/ value=iresult
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))
8326− (infer-call-context-arg val.e typ.u.target env state.u.target at.shape.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)
8327 ?: ?=(%| -.value) value
6466 ?: ?=(%| -.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" ~]]
8331 =/ fit=ifit (itype-fit typ.p.value typ.u.target sub.state.p.value next.state.p.value)
6467 =/ fit=ifit (itype-fit typ.p.value typ.u.target sub.state.p.value next.state.p.value)
8332 ?: ?=(%unknown -.fit) [%| ["cast constraint is not supported by partial inference" ~]]
6468 ?: ?=(%unknown -.fit) [%| ["cast constraint is not supported by partial inference" ~]]
8333 ?: ?=(%bad -.fit)
6469 ?: ?=(%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]
8338 [%| ["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)]]]]
6470 [%| ["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)]]]]
8339 =/ merged=itype (itype-merge-faces typ.p.value typ.u.target sub.fit)
6471 =/ merged=itype (itype-merge-faces typ.p.value typ.u.target sub.fit)
8340 [%& merged state.p.value(sub sub.fit, next next.fit)]
6472 [%& merged state.p.value(sub sub.fit, next next.fit)]
8341 %crash [%& [%var next.state] state(next +(next.state))]
6473 %crash [%& [%var next.state] state(next +(next.state))]
8343 =/ sam=isample-result (infer-sample sample.e env state)
6475 =/ sam=isample-result (infer-sample sample.e env state)
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 ~]]
8348 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
6477 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
8349 ?: ?=(%| -.body) body
6478 ?: ?=(%| -.body) body
8350 [%& [%fn typ.p.sam typ.p.body] state.p.body]
6479 [%& [%fn typ.p.sam typ.p.body] state.p.body]
8351 %gate-wide
6480 %gate-wide
8352 =/ sam=isample-result (infer-sample sample.e env state)
6481 =/ sam=isample-result (infer-sample sample.e env state)
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 ~]]
8357 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
6483 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
8358 ?: ?=(%| -.body) body
6484 ?: ?=(%| -.body) body
8359 [%& [%fn typ.p.sam typ.p.body] state.p.body]
6485 [%& [%fn typ.p.sam typ.p.body] state.p.body]
8361 ?~ args.e [%| ["call has no argument" ~]]
6487 ?~ args.e [%| ["call has no argument" ~]]
8362− ?: (explicit-proj-call e env state)
6488+ ?^ t.args.e [%| ["multiple arguments are not supported by partial inference" ~]]
8363− [%| ["proj needs an expected record type" ~]]
6489+ =/ head=iresult $(e head.e)
8364− (infer-call-with-head e env state (infer-fragment head.e env state))
6490+ ?: ?=(%| -.head) head
6491+ =/ head-type=itype (itype-walk typ.p.head sub.state.p.head)
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)
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" ~]]
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)
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)]
8365 * [%| ["expression is not supported by partial inference" ~]]
6514 * [%| ["expression is not supported by partial inference" ~]]
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.
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)
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)]]
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]
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]
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) &
8410−++ direct-unique-names
8411− |= [names=(list term) seen=ivisited]
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)
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)
8431−++ direct-checked-gates
8432− |= [ds=(list def) env=ienv]
8434− =/ names=(list term) (turn env |=(e=[name=term scheme=ischeme] name.e))
8435− =/ known=ivisited (graph-nameset names ~)
8436− =/ out=(map term def) ~
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))
8445− |= [n=term ds=(list def)]
8448− ?: &(?=(%value -.i.ds) =(n name.i.ds)) `i.ds
8450−++ direct-gate-sample
8453− ?. ?=(%value -.d) ~
8455− %gate `sample.val.d
8456− %gate-wide `sample.val.d
8459−++ direct-sample-name
8468−++ direct-field-name
8477− |= [typ=itype name=(unit term)]
8480− ?. ?=(%face -.typ) ~
8481− ?. =(name.typ u.name) ~
8484− |= [a=itype b=itype sub=isub next=@ud]
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 ~]
8493−++ direct-function-fit
8494− |= [a=itype b=itype sam=sample sh=shape sub=isub next=@ud]
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
8501− ?~ t.as [%unknown ~]
8502− ?^ t.t.as [%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)
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)
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]
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)
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)
8556− =/ sample=(unit sample) (direct-gate-sample u.source)
8558− =/ trial=ifit (direct-function-fit x y u.sample shape.i.slots sub next)
8559− ?. ?=(%ok -.trial) ~
8561− ?~ result [%unknown ~]
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)]
8572− ?. ?=(%wing -.i.args) |
8573− ?. ?=([@ ~] names.i.args) |
8574− ?=(^ (~(get by defs) i.names.i.args))
8577−++ direct-gate-call-fit
8578− |= [e=expr actual=itype expected=itype env=ienv state=istate]
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) ~
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)
8596− =/ sam=(unit sample) (direct-gate-sample u.head)
8598− ?. ?=(%cell -.u.sam) ~
8599− =/ fit=ifit (direct-positional-fit args.e items.u.sam actual expected env state sub.state next.state)
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)) ~
8616−++ infer-call-with-head
8617− |= [e=expr env=ienv state=istate head=iresult]
8620− ?~ args.e [%| ["call has no argument" ~]]
8621− ?: ?=(%| -.head) head
8622− =/ head-type=itype (itype-walk typ.p.head sub.state.p.head)
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)
8635− =/ shape=(unit [source=iwfields target=iwfields])
8637− (width-shape typ.p.arg sample.ht sub.st)
8638− ?^ shape [%| ["record width constraint needs unsupported inference" ~]]
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)
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" ~]]
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)
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)]]]]
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)
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)]
8675− |= [args=(list expr) actual=itype expected=itype sub=isub next=@ud]
8676− ^- (unit [at=span typ=itype])
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)
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)
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.
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]
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" ~]]
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)]
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]
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)
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)) |
8750− ?. =(origin.result origin.expected) |
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)) |
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)])
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]
8768− =/ order=(list iwfield) ~
8769− =/ index=(map term iwfield) *(map term iwfield)
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]
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)
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]
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)
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)
8810−:: Experimental intrinsic recognition; real bindings retain normal calls.
8811−++ explicit-proj-call
8812− |= [e=expr env=ienv state=istate]
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))) |
8821− ?:(?=(^ (ienv-lookup %proj values.u.prelude.state)) | &)
8822−++ infer-proj-source
8823− |= [e=expr expected=itype env=ienv state=istate context=span]
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]
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])]
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=@]
8851− ?. ?=(%union -.t) |
8852− =/ cases=(list itype) cases.t
8857− ?: ?=(%cell -.c) $(cases t.cases)
8858− ?. ?=(%const -.c) |
8859− ?: =(noun val.literal.c)
8861− $(cases t.cases, found &)
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)
8873− ?. ?=(?(%lit %wing %ctor) -.i.args) |
8875−++ contextual-direct-payload-call
8878− ?: ?=(%group -.e) $(e inner.e)
8880− ?. ?=(%wing -.head.e) |
8882− (contextual-atomic-arguments args.e)
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
8891− ?: ?=(?(%cell %face %fn %union %collection) -.val.i.sub) |
8894−:: Check the syntactic root before scanning; scan substitutions once.
8895−++ grec-direct-context
8896− |= [expected=itype sub=isub]
8900− ?: ?=(%face -.expected)
8902− $(expected body.expected, left (dec left))
8903− ?. ?=(%grec -.expected) |
8906− ?: ?=(?(%cell %face %fn %union %collection %grec) -.val.i.sub) |
8907− $(sub t.sub, left (dec left))
8908−++ contextual-direct-union
8911− ?: ?=(%face -.target) $(target body.target)
8912− ?=(%union -.target)
8913−++ contextual-tagged-case
8914− |= [target=itype tag=@ sub=isub]
8916− ?. ?=(%union -.target) ~
8917− =/ remaining=(list itype) cases.target
8918− =/ found=(unit itype) ~
8919− =/ seen=(set @) *(set @)
8922− =/ c=itype i.remaining
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)
8932−++ infer-call-context-arg
8933− |= [e=expr expected=itype env=ienv state=istate context=span]
8935− ?: ?=(%pair -.e) $(e (pair-as-cell e))
8936− ?: ?=(%group -.e) $(e inner.e)
8937− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.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)
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))
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)
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)
8992− ?. =(%loobean form.lit.e) ~
8993− ?. |(?=(%const -.target) &(?=(%union -.expected) (explicit-singleton-in-union expected val.lit.e))) ~
8995− ?^ singleton [%& u.singleton state]
8996− =/ known=(unit iresult)
8997− ?: ?=(%branch -.e) (known-union-subject subject.e env state)
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)) ~
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)
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)
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)
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
9051− ?:(?=(%face -.expected) body.expected expected)
9053−++ infer-call-context-items
9054− |= [items=(list item) expected=itype env=ienv state=istate context=span]
9056− ?~ items [%| ["empty cell is not supported by partial inference" ~]]
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)
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]
9075−++ infer-call-context-args
9076− |= [args=(list expr) expected=itype env=ienv state=istate context=span]
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)
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]
9091:: Tuple and record expressions preserve their explicitly written faces.
6517:: Tuple and record expressions preserve their explicitly written faces.
9093++ infer-simple-items
6519++ infer-simple-items
@@ -9103,55 +6529,11 @@
9103 ?: ?=(%| -.tail) tail
6529 ?: ?=(%| -.tail) tail
9104 [%& [%cell ht typ.p.tail] state.p.tail]
6530 [%& [%cell ht typ.p.tail] state.p.tail]
9106−:: A single all-binder cell pattern covers a known cell spine; the final
6532+:: A single two-binder cell pattern covers every value of a cell type.
9107−:: binder captures the remaining noun. Other pattern matrices stay partial.
6533+:: No other pattern matrix is implemented here.
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)
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
9123−++ cell-pattern-types
9124− |= [names=(list term) env=ienv next=@ud]
9125− ^- [typ=itype env=ienv next=@ud]
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]
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]
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))
9144−++ cell-binder-pattern
9147− ?. ?=(%branch -.e) |
9150− ?. ?=(%cell -.pat.i.arms.e) |
9151− !(single-structured-pattern e)
9153++ infer-cell-branch
6535++ infer-cell-branch
9154− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
6536+ |= [e=expr env=ienv state=istate]
9155 ^- iresult
6537 ^- iresult
9156 ?> ?=(%branch -.e)
6538 ?> ?=(%branch -.e)
9157 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
6539 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
@@ -9160,31 +6542,25 @@
9160 =/ pats=(list pattern) items.pat.arm
6542 =/ pats=(list pattern) items.pat.arm
9161 ?~ pats [%| ["branch pattern is not supported by partial inference" ~]]
6543 ?~ pats [%| ["branch pattern is not supported by partial inference" ~]]
9162 ?~ t.pats [%| ["branch pattern is not supported by partial inference" ~]]
6544 ?~ t.pats [%| ["branch pattern is not supported by partial inference" ~]]
9163− =/ names=(each (list term) @t) (cell-pattern-names pats env globals.state ~)
6545+ ?^ t.t.pats [%| ["branch pattern is not supported by partial inference" ~]]
9164− ?: ?=(%| -.names) [%| [(trip p.names) ~]]
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" ~]]
9165 =/ subject=iresult (infer-fragment subject.e env state)
6552 =/ subject=iresult (infer-fragment subject.e env state)
9166 ?: ?=(%| -.subject) subject
6553 ?: ?=(%| -.subject) subject
9167 =/ st=istate state.p.subject
6554 =/ st=istate state.p.subject
9168− =/ subject-type=itype (itype-normalize typ.p.subject sub.st)
6555+ ?: (itype-has-recursive (itype-normalize typ.p.subject sub.st))
9169− ?: (itype-has-recursive subject-type)
9170 [%| ["recursive pattern is not supported by partial inference" ~]]
6556 [%| ["recursive pattern is not supported by partial inference" ~]]
9171 ?: (itype-has-face typ.p.subject sub.st)
6557 ?: (itype-has-face typ.p.subject sub.st)
9172 [%| ["record patterns are not supported by partial inference" ~]]
6558 [%| ["record patterns are not supported by partial inference" ~]]
9173− ?: (cell-pattern-spine-unknown subject-type p.names sub.st)
6559+ =/ head=itype [%var next.st]
9174− [%| ["cell pattern subject is not supported by partial inference" ~]]
6560+ =/ tail=itype [%var +(next.st)]
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)
6561+ =/ sub=(unit isub) (itype-unify typ.p.subject [%cell head tail] sub.st)
9177 ?~ sub [%| ["cell pattern does not match the subject type" ~]]
6562 ?~ sub [%| ["cell pattern does not match the subject type" ~]]
9178− =. st st(next next.binders, sub u.sub)
6563+ (infer-fragment val.arm [[one [head ~]] [two [tail ~]] env] st(next (add 2 next.st), 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)]
9189++ show-itype
6565++ show-itype
9190 |= [t=itype sub=isub]
6566 |= [t=itype sub=isub]
@@ -9197,19 +6573,12 @@
9198 ?: (lth id.t 26) [(add 65 id.t) ~]
6574 ?: (lth id.t 26) [(add 65 id.t) ~]
9199 "T{<id.t>}"
6575 "T{<id.t>}"
9201− ?: (lth id.t 26) [(add 65 id.t) ~]
9204 ?: (lth id.t 26) [(add 65 id.t) ~]
6577 ?: (lth id.t 26) [(add 65 id.t) ~]
9205 "T{<id.t>}"
6578 "T{<id.t>}"
9207− ?: (lth id.t 26) [(add 65 id.t) ~]
9209 %atom "@{(trip aura.t)}"
6579 %atom "@{(trip aura.t)}"
9210 %any-atom "@"
6580 %any-atom "@"
9211 %flag "?"
6581 %flag "?"
9213 %tag (trip txt.literal.t)
6582 %tag (trip txt.literal.t)
9214 %const (trip txt.literal.t)
6583 %const (trip txt.literal.t)
@@ -9217,8 +6586,6 @@
9217 ?~ args.t (trip u.label.t)
6586 ?~ args.t (trip u.label.t)
9218 "({(trip u.label.t)} {(show-itype-cases args.t sub)})"
6587 "({(trip u.label.t)} {(show-itype-cases args.t sub)})"
9219 %recursive ?~(label.t "recursive mold" (trip u.label.t))
6588 %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)})")
9222 %collection "({(trip name.t)} {(show-itype-cases args.t sub)})"
6589 %collection "({(trip name.t)} {(show-itype-cases args.t sub)})"
9223 %face "[{(trip name.t)}={(show-itype-context body.t sub)}]"
6590 %face "[{(trip name.t)}={(show-itype-context body.t sub)}]"
9224 %fn "$-({(show-itype-context sample.t sub)} {(show-itype-context product.t sub)})"
6591 %fn "$-({(show-itype-context sample.t sub)} {(show-itype-context product.t sub)})"
@@ -9254,20 +6621,15 @@
9255 ?- -.typ
6622 ?- -.typ
9262 %any-atom |
6627 %any-atom |
9266 %const |
6630 %const |
9267 %union |((lien cases.typ |=(c=itype (itype-has-nvar c))) (lien args.typ |=(c=itype (itype-has-nvar c))))
6631 %union |((lien cases.typ |=(c=itype (itype-has-nvar c))) (lien args.typ |=(c=itype (itype-has-nvar c))))
9268 %recursive |
6632 %recursive |
9270− %grec (lien args.typ |=(c=itype (itype-has-nvar c)))
9271 %collection (lien args.typ |=(c=itype (itype-has-nvar c)))
6633 %collection (lien args.typ |=(c=itype (itype-has-nvar c)))
9272 %face $(typ body.typ)
6634 %face $(typ body.typ)
9273 %fn |($(typ sample.typ) $(typ product.typ))
6635 %fn |($(typ sample.typ) $(typ product.typ))
@@ -9278,7 +6640,7 @@
9278 |= [label=tape typ=itype sub=isub]
6640 |= [label=tape typ=itype sub=isub]
9280 =/ normalized=itype (itype-normalize typ sub)
6642 =/ 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
9282 ?: (itype-has-hidden-recursive normalized) label
6644 ?: (itype-has-hidden-recursive normalized) label
9283 =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
6645 =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
9284 ?: (gth (lent vars) 26) label
6646 ?: (gth (lent vars) 26) label
@@ -9288,8 +6650,8 @@
9288:: A capital in a written mold is generalized with its enclosing ++.
6650:: A capital in a written mold is generalized with its enclosing ++.
9289:: Atom constraints may remain generic; until full rigidity checking
6651:: Atom constraints may remain generic; until full rigidity checking
9290:: is implemented, do not report a type if one became more specific.
6652:: is implemented, do not report a type if one became more specific.
9291−:: Distinct written capitals cannot be forced equal; use the same
6653+:: Whether distinct written capitals may become equal is a doc question;
9292−:: capital where a type must be shared (Decisions 2026-10-30).
6654+:: the partial checker leaves such inference unsupported for now.
9294++ cap-id-in
6656++ cap-id-in
9295 |= [n=@ud caps=icaps sub=isub]
6657 |= [n=@ud caps=icaps sub=isub]
@@ -9300,43 +6662,11 @@
9300 ?+ -.resolved ~
6662 ?+ -.resolved ~
9301 %var `id.resolved
6663 %var `id.resolved
9302 %avar `id.resolved
6664 %avar `id.resolved
9305 ?~ ident $(caps t.caps)
6666 ?~ ident $(caps t.caps)
9306 ?: =(n u.ident) &
6667 ?: =(n u.ident) &
9307 $(caps t.caps)
6668 $(caps t.caps)
9310− |= [n=@ud caps=icaps sub=isub]
9313− =/ resolved=itype (itype-walk [%var id.i.caps] sub)
9314− =/ ident=(unit @ud)
9320− ?~ ident $(caps t.caps)
9321− ?: =(n u.ident) `i.caps
9325− |= [caps=icaps sub=isub]
9326− ^- (unit [first=icap second=icap])
9328− =/ resolved=itype (itype-walk [%var id.i.caps] sub)
9329− =/ ident=(unit @ud)
9335− ?~ ident $(caps t.caps)
9336− =/ found=(unit icap) (cap-with-id u.ident t.caps sub)
9337− ?^ found `[u.found i.caps]
9340++ constrained-capitals
6670++ constrained-capitals
9341 |= [caps=icaps sub=isub]
6671 |= [caps=icaps sub=isub]
@@ -9346,7 +6676,6 @@
9346 ?+ -.resolved ~
6676 ?+ -.resolved ~
9347 %var `id.resolved
6677 %var `id.resolved
9348 %avar `id.resolved
6678 %avar `id.resolved
9351 ?~ ident &
6680 ?~ ident &
9352 ?: (cap-id-in u.ident t.caps sub) &
6681 ?: (cap-id-in u.ident t.caps sub) &
@@ -9361,8 +6690,8 @@
9362 ?~ caps |
6691 ?~ caps |
9363 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
6692 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
9364− ?: |(?=(%avar -.resolved) ?=(%rvar -.resolved))
6693+ ?: ?=(%avar -.resolved)
9365− ?: =(n +.resolved) &
6694+ ?: =(n id.resolved) &
9366 $(caps t.caps)
6695 $(caps t.caps)
9367 $(caps t.caps)
6696 $(caps t.caps)
@@ -9372,19 +6701,14 @@
9374 %avar =(n id.t)
6703 %avar =(n id.t)
9379 %any-atom |
6706 %any-atom |
9383 %const |
6709 %const |
9384 %union |((lien cases.t |=(c=itype (has-atom-var n c))) (lien args.t |=(c=itype (has-atom-var n c))))
6710 %union |((lien cases.t |=(c=itype (has-atom-var n c))) (lien args.t |=(c=itype (has-atom-var n c))))
9385 %recursive |
6711 %recursive |
9387− %grec (lien args.t |=(c=itype (has-atom-var n c)))
9388 %collection (lien args.t |=(c=itype (has-atom-var n c)))
6712 %collection (lien args.t |=(c=itype (has-atom-var n c)))
9389 %face $(t body.t)
6713 %face $(t body.t)
9390 %fn |($(t sample.t) $(t product.t))
6714 %fn |($(t sample.t) $(t product.t))
@@ -9424,10 +6748,6 @@
9424 =/ out=tape ""
6748 =/ out=tape ""
9426 ?~ vars out
6750 ?~ 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))
9431 ?: (itype-var-is-atom i.vars t)
6751 ?: (itype-var-is-atom i.vars t)
9432 =/ sep=tape ?:(printed ", " " where ")
6752 =/ sep=tape ?:(printed ", " " where ")
9433 =/ clause=tape "{sep}{(show-itype [%avar i.vars] ~)} is an atom"
6753 =/ clause=tape "{sep}{(show-itype [%avar i.vars] ~)} is an atom"
@@ -9436,9 +6756,9 @@
9437:: Build the supported part of the value environment in dependency order.
6757:: Build the supported part of the value environment in dependency order.
9438:: Each pass adds successful definitions. Forward references become
6758:: Each pass adds successful definitions. Forward references become
9439−:: available on a later pass; unsupported syntax does not enter the
6759+:: available on a later pass; recursive groups and unsupported syntax do
9440−:: environment. Generalized definitions are closed, so a use instantiates
6760+:: not enter the environment. Generalized definitions are closed, so a
9441−:: its variables afresh.
6761+:: use instantiates its variables afresh.
9443++ global-value-names
6763++ global-value-names
9444 |= ds=(list def)
6764 |= ds=(list def)
@@ -9456,638 +6776,33 @@
9456 ?~ t.hits &
6776 ?~ t.hits &
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.
9466− |= [e=expr name=term]
9468− ?: ?=(%group -.e) $(e inner.e)
9469− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
9471− ?. ?=(%wing -.head.e) |
9472− =(names.head.e ~[name])
9475− |= [e=expr name=term]
9477− ?: ?=(%group -.e) $(e inner.e)
9478− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
9479− ?. ?=(%branch -.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)
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.
9497−++ recursive-branch-seed
9498− |= [d=def env=ienv state=istate]
9500− ?. ?=(%value -.d) ~
9501− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) ~
9506− %gate-wide body.gate
9509− =/ base=(unit expr) (branch-base-arm body name.d)
9511− =/ outer=ienv (skim env |=(entry=[name=term scheme=ischeme] !=(name.entry name.d)))
9512− =/ sam=isample-result
9514− %gate (infer-sample sample.gate outer state)
9515− %gate-wide (infer-sample sample.gate outer state)
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) ~
9528−++ infer-recursive-gate
9529− |= [d=def env=ienv state=istate]
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)
9537− =/ sam=isample-result
9539− %gate (infer-sample sample.gate env state)
9540− %gate-wide (infer-sample sample.gate env state)
9544− =/ diag=(unit idiag)
9546− %gate (sample-import-invalid sample.gate env state)
9547− %gate-wide (sample-import-invalid sample.gate env state)
9550− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
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]
9560− %gate-wide body.gate
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)]
9570− |= names=(list term)
9579− =/ first=(list term) (dependency-expr i.xs)
9580− (weld first $(xs t.xs))
9582−++ dependency-pieces
9586− =/ first=(list term)
9588− %expr (dependency-expr p.i.xs)
9591− (weld first $(xs t.xs))
9597− =/ first=(list term)
9599− %expr (dependency-expr p.i.xs)
9602− (weld first $(xs t.xs))
9608− =/ first=(list term) (dependency-expr val.i.xs)
9609− (weld first $(xs t.xs))
9615− =/ first=(list term) (dependency-expr val.i.xs)
9616− (weld first $(xs t.xs))
9622− =/ first=(list term) (dependency-expr val.i.xs)
9623− (weld first $(xs t.xs))
9629− =/ first=(list term)
9630− ?: ?=(%value -.i.xs) (dependency-expr val.i.xs)
9632− (weld first $(xs t.xs))
9638− %str (dependency-pieces pieces.e)
9639− %qath (dependency-qsegs segs.e)
9640− %wing (dependency-root names.e)
9642− =/ first=(list term) (dependency-root target.e)
9643− =/ last=(list term) (dependency-edits edits.e)
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)
9653− =/ first=(list term) (dependency-expr head.e)
9654− =/ last=(list term) (dependency-exprs args.e)
9656− %cast (dependency-expr val.e)
9658− =/ first=(list term) (dependency-expr val.e)
9659− =/ last=(list term) (dependency-expr then.e)
9662− =/ first=(list term) (dependency-expr subject.e)
9663− =/ last=(list term) (dependency-arms arms.e)
9666− =/ first=(list term) (dependency-defs defs.e)
9667− =/ last=(list term) (dependency-expr final.e)
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)
9678− |= [ds=(list def) env=ienv state=istate]
9680− ?~ ds [%& [~ state]]
9682− ?. ?=(%value -.d) [%| ["recursive group contains a non-gate" ~]]
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
9689− %gate (infer-sample sample.gate env initial)
9690− %gate-wide (infer-sample sample.gate env initial)
9693− ?: ?=(%| -.sam) [%| [p.sam ~]]
9697− %gate-wide body.gate
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]]
9708− |= [entries=(list igate-entry) env=ienv]
9711− [[name.i.entries [typ.i.entries ~]] $(entries t.entries)]
9713−++ infer-gate-group-bodies
9714− |= [entries=(list igate-entry) seeds=ienv state=istate]
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]]
9731− |= [entries=(list igate-entry) env=ienv outer=istate state=istate]
9732− ^- (each ienv idiag)
9734− =/ entry=igate-entry i.entries
9735− =/ merged=(unit [first=icap second=icap]) (merged-capitals caps.entry sub.state)
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]]
9753− |= [ds=(list def) env=ienv state=istate]
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)]]
9778− |= [ps=(list iwprojection) sub=isub visible=(list @ud)]
9779− ^- (unit (list iwprojection))
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)
9789− =/ entry=iwprojection i.ps
9790− =. entry entry(source src, target dst)
9793++ add-supported-defs
6779++ 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 ~)
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))
9807− |= [names=(list term) seen=ivisited]
9810− $(names t.names, seen (~(put by seen) i.names &))
9813− |= [name=term graph=iadj]
9815− =/ found=(unit (list term)) (~(get by graph) name)
9819−++ graph-make-forward
9820− |= [ds=(list def) names=ivisited graph=iadj]
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))
9828−++ graph-add-reverse
9829− |= [name=term edges=(list term) reverse=iadj]
9832− =/ prior=(list term) (graph-edges i.edges reverse)
9833− $(edges t.edges, reverse (~(put by reverse) i.edges [name prior]))
9836− |= [names=(list term) graph=iadj reverse=iadj]
9839− =. reverse (graph-add-reverse i.names (graph-edges i.names graph) reverse)
9843− |= [todo=iwork seen=ivisited order=(list term) graph=iadj]
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]))
9854− |= [todo=(list term) seen=ivisited component=(list term) graph=iadj]
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])
9861−++ graph-collect-all
9862− |= [order=(list term) seen=ivisited graph=iadj comps=icomponents]
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])
9869−:: Two depth-first passes find components before group inference. Maps
9870−:: preserve the graph identity; duplicate global names fail closed.
9872− |= [ds=(list def) names=(list term)]
9874− =/ nameset=ivisited ~
9875− =/ pending=(list term) names
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 ~)
9886− |= [component=(list term) graph=iadj]
9890− (lien (graph-edges i.component graph) |=(x=term =(x i.component)))
9893− |= [ds=(list def) components=icomponents graph=iadj env=ienv grouped=(list term) artifacts=(list iwidth-definition) state=istate]
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)
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))
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)]
9912− (resolve-groups-core ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude ~)
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)])]
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)]
9917− ^- [env=ienv artifacts=(list iwidth-definition)]
6781+ ^- ienv
9918− ?~ ds [env artifacts]
6782+ ?~ ds env
9919 =/ d=def i.ds
6783 =/ d=def i.ds
9920 ?: ?=(%mold -.d) $(ds t.ds)
6784 ?: ?=(%mold -.d) $(ds t.ds)
9921 ?. (unique-value-name name.d globals) $(ds t.ds)
6785 ?. (unique-value-name name.d globals) $(ds t.ds)
9922 ?^ (ienv-lookup name.d env) $(ds t.ds)
6786 ?^ (ienv-lookup name.d env) $(ds t.ds)
9923 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
6787 =/ 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 ~ ~ ~ ~]
6788+ =/ result=iresult (infer-fragment val.d env [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude])
9925− =. grec-index.initial index
9926− =. gate-defs.initial checked
9927− =. head-evidence.initial heads
9928− =. initial (reserve-def-caps val.d initial)
9929− =/ result=iresult (infer-fragment val.d env initial)
9930− =? result ?=(%| -.result) (infer-recursive-gate d env initial)
9931 ?: ?=(%| -.result) $(ds t.ds)
6789 ?: ?=(%| -.result) $(ds t.ds)
9932− =. state.p.result (promote-restricted-numbers state.p.result env)
9933− =. state.p.result (default-hole-numbers holes.state.p.result holes.initial state.p.result env !(itype-has-gate (itype-normalize typ.p.result sub.state.p.result)))
9934− ?^ (unresolved-hole holes.state.p.result holes.initial state.p.result) $(ds t.ds)
9935 ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
6790 ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
9936 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
6791 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
9937 ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
6792 ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
9938 ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
6793 ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
9939 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
6794 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
9940 ?: (gth (lent vars) 26) $(ds t.ds)
6795 ?: (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)
6796+ $(ds t.ds, env [[name.d [typ vars]] env])
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)])]
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)
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)
9970++ resolve-supported-defs
6798++ resolve-supported-defs
9971 |= [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)]
6799 |= [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)]
9973− env:(resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude)
6801+ =/ env=ienv ~
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]
9981− |= [xs=(list expr) globals=(list term) locals=(list term)]
9982− ^- (unit (list icyclesite))
9984− =/ first=(unit (list icyclesite)) (cycle-sites i.xs globals locals)
9986− =/ tail=(unit (list icyclesite)) $(xs t.xs)
9988− `(weld u.first u.tail)
9990−++ cycle-sample-name
9991− |= [sam=sample globals=(list term) locals=(list term)]
9992− ^- (unit (unit term))
9995− ?: (lien (weld globals locals) |=(n=term =(n name.sam))) ~
9998− ?: (lien (weld globals locals) |=(n=term =(n name.sam))) ~
10005− |= [e=expr globals=(list term) locals=(list term)]
10006− ^- (unit (list icyclesite))
10009− ?. ?=([@ ~] names.e) ~
10010− `~[[i.names.e at.e]]
10013− ?: (lien pieces.e |=(p=piece ?=(%expr -.p))) ~
10015− %group $(e inner.e)
10016− %body ?~(defs.e $(e final.e) ~)
10019− =/ binder=(unit (unit term)) (cycle-sample-name sample.e globals locals)
10021− =/ nested=(list term) ?~(u.binder locals [u.u.binder locals])
10022− $(e body.e, locals nested)
10024− =/ binder=(unit (unit term)) (cycle-sample-name sample.e globals locals)
10026− =/ nested=(list term) ?~(u.binder locals [u.u.binder locals])
10027− $(e body.e, locals nested)
10029− =/ first=(unit (list icyclesite)) $(e head.e)
10031− =/ tail=(unit (list icyclesite)) (cycle-sites-list args.e globals locals)
10033− `(weld u.first u.tail)
10037−++ cycle-definitely-atom
10040− ?: ?=(%group -.e) $(e inner.e)
10041− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
10042− ?. ?=(%cast -.e) |
10043− |(?=(%aura -.shape.e) ?=(%flag -.shape.e))
10045−++ cycle-proof-group
10046− |= [members=(list def) globals=(list term)]
10049− ?. ?=(%value -.i.members) |
10050− ?. (unique-value-name name.i.members globals) |
10051− ?. ?=(^ (cycle-sites val.i.members globals ~)) |
10052− $(members t.members)
10055− |= [sites=(list icyclesite) component=(list term)]
10058− ?: (lien component |=(n=term =(n name.i.sites))) `at.i.sites
10061−++ cycle-group-errors
10062− |= [members=(list def) component=(list term) globals=(list term)]
10065− =/ d=def i.members
10067− =/ tail=(list icycle) $(members t.members)
10068− ?. (cycle-definitely-atom val.d) tail
10069− =/ sites=(unit (list icyclesite)) (cycle-sites val.d globals ~)
10071− =/ found=(unit span) (cycle-find-site u.sites component)
10073− [[name.d at.d u.found] tail]
10075−++ definite-value-cycles
10076− |= [ds=(list def) globals=(list term)]
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) ~
10083− ?~ components out
6803+ =/ next=ienv (add-supported-defs ds env molds globals externals surs mark-externals marks jimports reserved-molds at prelude)
10084− =/ component=(list term) i.components
6804+ ?: =(next env) env
10085− ?. (graph-cycle component graph) $(components t.components)
6805+ $(env next)
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))
10092+| %union-analysis
6807+| %union-analysis
@@ -10224,142 +6939,11 @@
10224 [at.first at.second (union-relate a (project-union-mold second molds ~))]
6939 [at.first at.second (union-relate a (project-union-mold second molds ~))]
10225 (weld pairs $(cases t.cases))
6940 (weld pairs $(cases t.cases))
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
10231− ^- (unit (unit span))
10232− ?: ?=(%generic -.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))
10242− ?(%aura %noun %void %flag %const) `~
10243− %tvar ?:((lien vars |=(v=@t =(v name.sh))) `~ ~)
10244− %cell (simple-mold-field-holes fields.sh vars)
10246− =/ a=(unit (unit span)) $(sh sample.sh)
10248− =/ b=(unit (unit span)) $(sh product.sh)
10254−++ simple-mold-field-holes
10255− |= [fields=(list field) vars=(list @t)]
10256− ^- (unit (unit span))
10258− =/ f=field i.fields
10259− =/ first=(unit (unit span))
10261− %face (simple-mold-hole-in shape.f vars)
10262− %bare (simple-mold-hole-in shape.f vars)
10266− =/ rest=(unit (unit span)) $(fields t.fields)
10268− `?~(u.first u.rest u.first)
10269−++ simple-local-mold-hole
10270− |= defs=(list def)
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
10279−:: A partial prelude may omit unsupported declarations, but may not
10280−:: publish an interface while a named mold's hole remains unchecked.
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)
10298− %face (shape-has-hole shape.f)
10299− %bare (shape-has-hole shape.f)
10302−++ named-mold-has-hole
10306− ?: &(?=(%mold -.i.ds) (shape-has-hole shape.i.ds)) &
10313− %face (shape-has-hole shape.sam)
10314− %bare (shape-has-hole shape.sam)
10315− %cell (lien items.sam sample-has-hole)
10322− %mold (shape-has-hole shape.d)
10323− %value (expr-has-hole val.d)
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)))
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))
10345−++ hole-values-present
10346− |= [ds=(list def) env=ienv]
10349− ?. ?=(%value -.i.ds) $(ds t.ds)
10350− ?: (expr-has-hole val.i.ds)
10351− ?. ?=(^ (ienv-lookup name.i.ds env)) |
10354++ show-partial-mold
6942++ show-partial-mold
10355 |= [file=path src=@t d=def molds=imolds]
6943 |= [file=path src=@t d=def molds=imolds]
10357 ?> ?=(%mold -.d)
6945 ?> ?=(%mold -.d)
10358 =/ sh=shape shape.d
6946 =/ 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])
10363 =? sh ?=(%generic -.sh) body.sh
6947 =? sh ?=(%generic -.sh) body.sh
10364 ?. ?=(%union -.sh) (crip "+$ {(trip name.d)}: not checked")
6948 ?. ?=(%union -.sh) (crip "+$ {(trip name.d)}: not checked")
10365 =/ pairs=(list upair) (union-pairs cases.sh molds)
6949 =/ pairs=(list upair) (union-pairs cases.sh molds)
@@ -10386,21 +6970,6 @@
10386 (show-error src [file line.beg.at.site col.beg.at.site note.site])
6970 (show-error src [file line.beg.at.site col.beg.at.site note.site])
10387 (of-wain:format [summary excerpts])
6971 (of-wain:format [summary excerpts])
10389−:: Both written field sites are shown in the source that declares them.
10390−++ show-duplicate-fields
10391− |= [file=path src=@t diagnostic=idiag]
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])
10399−++ duplicate-fields-report
10400− |= [file=path src=@t diagnostic=idiag]
10402− (of-wain:format ~['partial inference; module not checked' (show-duplicate-fields file src diagnostic)])
10404:: +golden-types: a partial report; it does not claim the module checks
6973:: +golden-types: a partial report; it does not claim the module checks
10406++ golden-types
6975++ golden-types
@@ -10430,180 +6999,6 @@
10430+$ jfile-result (each [iface=ifile cache=jcache] @t)
6999+$ jfile-result (each [iface=ifile cache=jcache] @t)
10431+$ jimports-result (each [resolved=ijimports cache=jcache] @t)
7000+$ jimports-result (each [resolved=ijimports cache=jcache] @t)
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]
10438− =/ prior=(unit span) (~(get by seen) name)
10440− `["record field `{(trip name)}` is repeated" ~[[u.prior "first field"] [at "repeated field"]]]
10441−++ duplicate-shapes
10442− |= xs=(list shape)
10445− =/ first (duplicate-shape i.xs)
10448−++ duplicate-fields
10449− |= [fields=(list field) seen=written-fields]
10452− =/ f=field i.fields
10459− =/ dup=(unit idiag) ?~(n ~ (duplicate-written-field u.n at.f seen))
10461− =/ inner=(unit idiag)
10463− %face (duplicate-shape shape.f)
10465− %bare (duplicate-shape shape.f)
10468− $(fields t.fields, seen ?~(n seen (~(put by seen) u.n at.f)))
10473− %cell (duplicate-fields fields.s ~)
10474− %apply (duplicate-shapes args.s)
10475− %union (duplicate-shapes cases.s)
10477− =/ left (duplicate-shape sample.s)
10479− (duplicate-shape product.s)
10480− %generic (duplicate-shape body.s)
10483−++ duplicate-samples
10484− |= [items=(list sample) seen=written-fields]
10487− =/ a=sample i.items
10495− =/ dup=(unit idiag) ?~(n ~ (duplicate-written-field u.n at.a seen))
10497− =/ inner (duplicate-sample a)
10499− $(items t.items, seen ?~(n seen (~(put by seen) u.n at.a)))
10500−++ duplicate-sample
10504− %cell (duplicate-samples items.s ~)
10505− %face (duplicate-shape shape.s)
10506− %bare (duplicate-shape shape.s)
10513− =/ first (duplicate-expr i.xs)
10517− |= [items=(list item) seen=written-fields]
10521− =/ dup=(unit idiag) ?~(face.a ~ (duplicate-written-field u.face.a at.a seen))
10523− =/ inner (duplicate-expr val.a)
10525− $(items t.items, seen ?~(face.a seen (~(put by seen) u.face.a at.a)))
10526−++ duplicate-pieces
10527− |= pieces=(list piece)
10530− =/ first=(unit idiag) ?:(?=(%expr -.i.pieces) (duplicate-expr p.i.pieces) ~)
10532− $(pieces t.pieces)
10534− |= segs=(list qseg)
10537− =/ first=(unit idiag) ?:(?=(%expr -.i.segs) (duplicate-expr p.i.segs) ~)
10541− |= edits=(list edit)
10544− =/ first (duplicate-expr val.i.edits)
10548− |= arms=(list arm)
10551− =/ first (duplicate-expr val.i.arms)
10555− |= defs=(list def)
10558− =/ first=(unit idiag)
10560− %mold (duplicate-shape shape.i.defs)
10561− %value (duplicate-expr val.i.defs)
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 ~)
10578− =/ first (duplicate-sample sample.e)
10580− (duplicate-expr body.e)
10582− =/ first (duplicate-sample sample.e)
10584− (duplicate-expr body.e)
10586− =/ first (duplicate-shape shape.e)
10588− (duplicate-expr val.e)
10590− =/ first (duplicate-expr head.e)
10592− (duplicate-exprs args.e)
10594− =/ first (duplicate-expr val.e)
10596− (duplicate-expr then.e)
10598− =/ first (duplicate-expr subject.e)
10600− (duplicate-arms arms.e)
10602− =/ first (duplicate-defs defs.e)
10604− (duplicate-expr final.e)
10607++ import-binding-names
7002++ import-binding-names
10608 |= imports=(list import)
7003 |= imports=(list import)
10609 ^- (list term)
7004 ^- (list term)
@@ -10616,60 +7011,6 @@
10617 [n $(imports t.imports)]
7012 [n $(imports t.imports)]
10619−++ reserved-proj-sample
10623− %bind =(name.sam %proj)
10624− %face =(name.sam %proj)
10625− %pun =(name.sam %proj)
10626− %cell (lien items.sam reserved-proj-sample)
10629−++ reserved-proj-pattern
10633− %bind =(name.p %proj)
10634− %cell (lien items.p reserved-proj-pattern)
10637−++ reserved-proj-def
10640− ?: =(name.d %proj) &
10641− ?: ?=(%value -.d) (reserved-proj-expr val.d)
10643−++ reserved-proj-expr
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)))
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))
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))
10664−++ module-has-reserved-proj
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))
10673++ module-scope-valid
7014++ module-scope-valid
10674 |= [mod=module prelude-values=(list term) prelude-molds=(list term)]
7015 |= [mod=module prelude-values=(list term) prelude-molds=(list term)]
@@ -10677,7 +7018,6 @@
10677 =/ vals=(list term) (global-value-names defs.mod)
7018 =/ vals=(list term) (global-value-names defs.mod)
10678 =/ molds=imolds (collect-simple-molds defs.mod)
7019 =/ molds=imolds (collect-simple-molds defs.mod)
10679 =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
7020 =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10680− ?: (module-has-reserved-proj mod) |
10681 ?. %+ levy imported
7021 ?. %+ levy imported
10682 |= n=term
7022 |= n=term
10683 &((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))))
7023 &((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 @@
10685 ?. (levy vals |=(n=term &((unique-value-name n vals) !(lien prelude-values |=(v=term =(n v)))))) |
7025 ?. (levy vals |=(n=term &((unique-value-name n vals) !(lien prelude-values |=(v=term =(n v)))))) |
10686 (levy mold-names |=(n=term &((unique-value-name n mold-names) !(lien prelude-molds |=(m=term =(n m))))))
7026 (levy mold-names |=(n=term &((unique-value-name n mold-names) !(lien prelude-molds |=(m=term =(n m))))))
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)]
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))))
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)
10704++ module-mold-types
7028++ module-mold-types
10705 |= [molds=imolds state=istate]
7029 |= [molds=imolds state=istate]
10706 ^- (each imold-types @t)
7030 ^- (each imold-types @t)
@@ -10716,9 +7040,9 @@
10717:: Prepare a provisional interface from the trusted vendored source.
7041:: Prepare a provisional interface from the trusted vendored source.
10718:: Every declared name remains reserved, but only molds and values this
7042:: Every declared name remains reserved, but only molds and values this
10719−:: fragment can infer are usable. Unsupported bodies are not validated.
7043+:: fragment can infer are usable. Unsupported bodies are not validated,
10720−:: An optional internal source supplies the prelude's one supported import;
7044+:: and imports into the prelude are not supported yet. The fixed origin
10721−:: clients cannot import that path directly. Named unions retain their origin.
7045+:: gives its named unions the same identity in every importing module.
10723:: Recognize only the complete standard prelude list shape. Its recursive
7047:: Recognize only the complete standard prelude list shape. Its recursive
10724:: tail uses the same parameter and the unqualified list name. The reader
7048:: tail uses the same parameter and the unqualified list name. The reader
@@ -10758,20 +7082,6 @@
10758 ?. ?=(%tvar -.i.args.tail) |
7082 ?. ?=(%tvar -.i.args.tail) |
10759 =(var name.i.args.tail)
7083 =(var name.i.args.tail)
10762− |= [typ=itype name=term vars=(list @ud)]
10764− ?: ?=(%jrec -.typ) typ(label `name)
10765− ?: ?=(%grec -.typ)
10766− ?. (identity-union-parameters vars args.typ) typ(label ~)
10768− ?. ?=(%union -.typ) typ
10769− ?. (identity-union-parameters vars args.typ)
10771− ?: =(at.u.origin.typ /lib/jibb/internal/jibb) typ(label ~)
10775++ partial-prelude-molds
7085++ partial-prelude-molds
10776 |= [molds=imolds state=istate]
7086 |= [molds=imolds state=istate]
10777 ^- imold-types
7087 ^- imold-types
@@ -10784,163 +7094,26 @@
10784 (infer-mold-template body.m state(active [name.m active.state], in-mold &))
7094 (infer-mold-template body.m state(active [name.m active.state], in-mold &))
10785 ?~ out $(molds t.molds)
7095 ?~ out $(molds t.molds)
10786 =. typ.template.u.out (label-direct-union typ.template.u.out body.m name.m state)
7096 =. 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)
10788 [[name.m template.u.out] $(molds t.molds)]
7097 [[name.m template.u.out] $(molds t.molds)]
10790−:: A compiler-owned interface available only to the dedicated
7099+++ partial-prelude-interface
10791−:: internal-prelude preparation path, never the ordinary module resolver.
7100+ |= src=@t
10792−++ private-primitive-interface
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 ~ ~ ~ ~ ~]
10802−++ infer-private-internal
10803− |= [src=@t public-source=@t]
10805− =/ at=path /lib/jibb/internal/jibb
10806− =/ parsed (parse at src)
10807− ?: ?=(%| -.parsed) ~
10808− =/ mod=module p.parsed
10809− ?^ (duplicate-defs defs.mod) ~
10811− =/ built=jfile-result (infer-jibb-file at src ~ ~ ~ ~[at] ~ ~ ~ ~)
10812− ?: ?=(%| -.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)
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)
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)
10846− ?. (standard-unit-template u.found /lib/jibb/prelude/jibb) ~
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)
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 ~]
10881−++ partial-prelude-interface-with-internal
10882− |= [src=@t internal-source=(unit @t)]
10883 ^- (unit ifile)
7101 ^- (unit ifile)
10884 ?: =(0 src) ~
7102 ?: =(0 src) ~
10885 =/ at=path /lib/jibb/prelude/jibb
7103 =/ at=path /lib/jibb/prelude/jibb
10886 =/ parsed (parse at src)
7104 =/ parsed (parse at src)
10887 ?: ?=(%| -.parsed) ~
7105 ?: ?=(%| -.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)
10897− `~[[face.i.imports.p.parsed u.built]]
7106+ ?^ imports.p.parsed ~
10899 ?~ defs.p.parsed ~
7107 ?~ defs.p.parsed ~
10900 ?. (module-scope-valid p.parsed ~ ~) ~
7108 ?. (module-scope-valid p.parsed ~ ~) ~
10901 =/ ds=(list def) defs.p.parsed
7109 =/ ds=(list def) defs.p.parsed
10902 =/ molds=imolds (collect-simple-molds ds)
7110 =/ molds=imolds (collect-simple-molds ds)
10903 =/ names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
7111 =/ 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))
7112+ =/ globals=(list term) (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 ~ ~ ~ ~]
7113+ =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ ~ ~ ~ ~ ~ | at names ~]
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))
7114+ =/ mt=imold-types (partial-prelude-molds molds state)
10921− =/ partial=ifile [~ mt at ~ ~ ~ ~ ~]
7115+ =/ env=ienv (resolve-supported-defs ds molds globals ~ ~ ~ ~ ~ ~ at ~)
10922− :: An explicitly qualified re-export must resolve. Other unsupported
7116+ `[env mt at]
10923− :: prelude declarations remain reserved but absent from the interface.
10924− =/ required=imolds
10926− |= m=[name=term body=shape]
10927− =/ sh=shape body.m
10928− ?. ?=(%ref -.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)
10937− ~[[at.interface.i.u.private source.interface.i.u.private elaborations.interface.i.u.private]]
10938− `[env mt at ~ artifacts.resolution deps `src ~]
10940−++ partial-prelude-interface
10943− (partial-prelude-interface-with-internal src ~)
10945+$ iprelude [iface=ifile values=(list term) molds=(list term)]
7118+$ iprelude [iface=ifile values=(list term) molds=(list term)]
@@ -10955,17 +7128,6 @@
10955 =/ ms=(list term) (turn (collect-simple-molds defs.p.parsed) |=(m=[name=term body=shape] name.m))
7128 =/ ms=(list term) (turn (collect-simple-molds defs.p.parsed) |=(m=[name=term body=shape] name.m))
10956 `[u.iface vals ms]
7129 `[u.iface vals ms]
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)
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]
10969++ module-values-complete
7131++ module-values-complete
10970 |= [ds=(list def) env=ienv]
7132 |= [ds=(list def) env=ienv]
@@ -10986,76 +7148,12 @@
10986 ?: =(at at.i.cache) `iface.i.cache
7148 ?: =(at at.i.cache) `iface.i.cache
10987 $(cache t.cache)
7149 $(cache t.cache)
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))
10999− =/ hit=(list irequest-evidence)
11000− (skim acc |=(x=irequest-evidence &(=(api-at.x api-at.i.pending) =(name.x name.i.pending))))
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)]
11009− ?& =(bundle-input.g modules)
11010− =(prelude-input.g prelude)
11011− =(prelude-values.g values)
11012− =(prelude-molds.g molds)
11013− =(externals.g externals)
11016−++ request-graph-merge
11017− |= [imports=ijimports g=irequest-graph fuel=@ud]
11018− ^- (unit irequest-graph)
11021− =/ child=ifile interface.i.imports
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)
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)))
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)]
11042− ?. =(u.source.f src) |
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)))
11049++ resolve-jibb-imports
7151++ resolve-jibb-imports
11050 |= [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)]
7152 |= [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)]
11051 ^- jimports-result
7153 ^- jimports-result
11052 ?~ imports [%& [~ cache]]
7154 ?~ imports [%& [~ cache]]
11053 ?. ?=(%jibb -.i.imports) $(imports t.imports)
7155 ?. ?=(%jibb -.i.imports) $(imports t.imports)
11054 =/ at=path (weld path.i.imports `path`~[%jibb])
7156 =/ 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']
11059 ?: (lien active |=(p=path =(p at)))
7157 ?: (lien active |=(p=path =(p at)))
11060 [%| (crip "import cycle at {(spud at)}")]
7158 [%| (crip "import cycle at {(spud at)}")]
11061 =/ found=jbundle (skim modules |=(m=jsource =(at at.m)))
7159 =/ found=jbundle (skim modules |=(m=jsource =(at at.m)))
@@ -11063,882 +7161,39 @@
11063 ?^ t.found [%| (crip "duplicate module sources: {(spud at)}")]
7161 ?^ t.found [%| (crip "duplicate module sources: {(spud at)}")]
11064 =/ cached=(unit ifile) (find-jibb-cache at cache)
7162 =/ cached=(unit ifile) (find-jibb-cache at cache)
11065 =/ iface=jfile-result
7163 =/ iface=jfile-result
11067− ?. =(at.u.cached at) [%| 'cached module identity needs unsupported inference']
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]]
11076 (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
7165 (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
11077 ?: ?=(%| -.iface) [%| p.iface]
7166 ?: ?=(%| -.iface) [%| p.iface]
11078 =/ rest=jimports-result $(imports t.imports, cache cache.p.iface)
7167 =/ rest=jimports-result $(imports t.imports, cache cache.p.iface)
11079 ?: ?=(%| -.rest) rest
7168 ?: ?=(%| -.rest) rest
11080 [%& [[[face.i.imports iface.p.iface] resolved.p.rest] cache.p.rest]]
7169 [%& [[[face.i.imports iface.p.iface] resolved.p.rest] cache.p.rest]]
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))]
11086− |= [sh=shape marks=(list term)]
11088− ?. ?=(%ref -.sh) ~
11089− ?. ?=([@ ~] names.sh) ~
11090− ?. (unique-value-name i.names.sh marks) ~
11094− |= [shapes=(list shape) marks=(list term) used=(list term)]
11095− ^- (unit (list term))
11097− =/ n=(unit term) (api-path-mark i.shapes marks)
11099− ?: (lien used |=(x=term =(x u.n))) ~
11100− =/ rest=(unit (list term)) $(shapes t.shapes, used [u.n used])
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) ~
11113− =/ full=(unit term) (api-path-mark i.args.sh marks)
11115− =/ diffs=(unit (list term)) (api-path-diffs t.args.sh marks ~[u.full])
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))
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])
11131− `[[name.seg aura.seg at.seg] u.rest]
11133−++ api-scry-parameters-compatible
11134− |= [scry=(list iapi-parameter) watch=(list iapi-parameter)]
11137− ?. (lien watch |=(p=iapi-parameter &(=(name.p name.i.scry) =(aura.p aura.i.scry)))) |
11141− |= [sh=shape marks=(list term)]
11142− ^- (unit iapi-path)
11143− ?. ?=(%cell -.sh) ~
11144− =/ fs=(list field) fields.sh
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)
11161− =/ scry=(unit (unit (list pseg)))
11163− =/ entry=field i.t.t.t.fs
11164− ?. ?=(%face -.entry) ~
11165− ?. =(%scry name.entry) ~
11166− ?. ?=(%path -.shape.entry) ~
11167− ``segs.shape.entry
11169− =/ params=(unit (list iapi-parameter)) (api-path-parameters segs.path-shape ~)
11172− =/ scry-params=(unit (list iapi-parameter)) (api-path-parameters u.u.scry ~)
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]
11179− |= [shapes=(list shape) marks=(list term) seen=(list term)]
11180− ^- (unit (list iapi-path))
11182− =/ one=(unit iapi-path) (api-path-one i.shapes marks)
11184− ?: (lien seen |=(n=term =(n name.u.one))) ~
11185− =/ rest=(unit (list iapi-path)) $(shapes t.shapes, seen [name.u.one seen])
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 ~)
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)
11202− %mark $(imports t.imports)
11203− %sur [name.i.imports $(imports t.imports)]
11204− %jibb [face.i.imports $(imports t.imports)]
11207−++ api-derived-names-valid
11208− |= [paths=(list iapi-path) poke-names=(list term) mod=module prelude-values=(list term)]
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))))))
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)]
11221− |= [names=(list term) externals=imark-externals declared=(list term)]
11222− ^- (unit (list iapi-mark-type))
11224− =/ typ=(unit itype) (find-imported-mark i.names externals declared)
11226− =/ tail=(unit (list iapi-mark-type)) $(names t.names)
11228− `[[i.names u.typ] u.tail]
11231− |= [paths=(list iapi-path) externals=imark-externals declared=(list term)]
11232− ^- (unit (list iapi-path-typed))
11234− =/ full=(unit itype) (find-imported-mark full.i.paths externals declared)
11236− =/ diffs=(unit (list iapi-mark-type)) (api-diff-types diffs.i.paths externals declared)
11238− =/ tail=(unit (list iapi-path-typed)) $(paths t.paths)
11240− `[[i.paths u.full u.diffs] u.tail]
11242−++ api-poke-mark-names
11243− |= [pokes=(list def) declared=(list term)]
11244− ^- (unit (list term))
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)
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)
11273− =/ decl=def i.declarations
11274− ?> ?=(%mold -.decl)
11275− =/ paths=(unit (list iapi-path)) (api-path-declaration shape.decl declared)
11277− ?. (api-derived-names-valid u.paths u.poke-names mod prelude-values) ~
11278− (api-path-types u.paths externals declared)
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']
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]]
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
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))
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)
11375− `[[name.i.params [%atom aura] at.i.params] u.rest]
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))
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]
11389−++ api-request-parts
11390− |= [evidence=(unit iapi-path-evidence) case-name=term]
11391− ^- (unit iapi-request-parts)
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 ~)
11399− =/ params=(unit (list iapi-request-parameter)) (api-request-parameter-types u.raw)
11401− =/ fold=(unit (unit itype)) (api-request-fold-type p)
11403− =/ watch=?(%watchable %not-watchable) ?~(scry.path.p %watchable %not-watchable)
11404− `[u.evidence p u.params full.p u.fold watch]
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]]
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
11491− =/ public=ifile iface.prelude
11492− ?. =(at.public /lib/jibb/prelude/jibb) ~
11493− =/ ask=(unit ischeme) (find-jibb-mold %ask public)
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)
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 ~]])
11517− =/ path-unit=(unit itype) (template-apply u.unit-template ~[path-type])
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]) ~
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']
11554− ?~ fold.u.parts ?=([* ~] marks.support)
11555− ?=([* [* ~]] marks.support)
11556− ?. valid-marks [%| 'request marks need unsupported inference']
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]]
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']
11608− ?~ fold.u.parts ?=([* ~] marks.support)
11609− ?=([* [* ~]] marks.support)
11610− ?. valid-marks [%| 'request marks need unsupported inference']
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]]
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]]
11641−++ api-mark-exports
11642− |= [marks=(list term) all=(list term) externals=imark-externals]
11645− =/ t=(unit itype) (find-imported-mark i.marks externals all)
11646− ?~ t $(marks t.marks)
11647− [[i.marks [u.t ~]] $(marks t.marks)]
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)]
11654− ?: (lien defs.mod def-has-hole) ~
11655− ?. ?=([%ui %api @ %jibb ~] at) ~
11656− ?^ (duplicate-defs defs.mod) ~
11658− ?. =(at.u.prelude /lib/jibb/prelude/jibb) ~
11659− =/ poke=(unit ischeme) (find-jibb-mold %poke u.prelude)
11661− ?. ?=(%union -.typ.u.poke) ~
11664− %+ lien cases.typ.u.poke
11666− ?=([%cell [%const [%term %tas %agent *]] [%cell [%face %agent [%atom %tas]] [%cell [%face %mark [%atom %tas]] [%face %payload [%noun ~]]]]] c)
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)
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]] ~ ~ ~ ~]
11686−:: Source-proven ordinary helpers validate each selected /sur dependency.
11687−:: Unused or less direct cores remain unsupported by this first interface.
11689− |= [surs=(list term) defs=(list def) externals=iexternals all=(list term)]
11692− =/ found=(list def)
11695− ?. ?=(%mold -.d) |
11696− ?. ?=(%ref -.shape.d) |
11697− ?. ?=([@ [@ ~]] names.shape.d) |
11698− =(i.t.names.shape.d i.surs)
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)
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)
11715− =/ p=iapi-path-typed i.paths
11716− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
11718− ?. ?=(?(~ [* ~]) parameters.u.parts) ~
11719− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) ~
11721− ?^ (itype-vars reply-sample.u.parts) ~
11722− ?: (itype-has-tag reply-sample.u.parts) ~
11725− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
11727− =/ result=(unit itype) (template-apply ask ~[[%var 0]])
11729− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
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))
11741− `[[[name.path.p scheme] values.u.rest] [req requests.u.rest]]
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))))
11749− ?. ?=([* ~] pokes) ~
11750− =/ declared=(list term) (collect-mark-imports imports.mod)
11751− =/ ns=(unit (list term)) (api-poke-mark-names pokes declared)
11753− ?. ?=([@ ~] u.ns) ~
11754− =/ matching=(list import)
11755− %+ skim imports.mod
11757− ?. ?=(%mark -.i) |
11759− ?. ?=([* ~] matching) ~
11760− =/ checked=(unit ifile)
11761− (api-poke-interface file mod(defs pokes, imports matching) marks values molds prelude)
11763− `[values.u.checked derived.u.checked]
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]
11809− [env exports file derived.u.poke elaborations.support ~ `src `graph]
11810− [%& [iface dependencies.ev]]
11812++ infer-jibb-file
7171++ infer-jibb-file
11813 |= [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)]
7172 |= [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)]
11814 ^- jfile-result
7173 ^- jfile-result
7174+ ?: ?=([%ui %api *] at) [%| (crip "API module needs unsupported inference: {(spud at)}")]
11815 =/ parsed (parse at src)
7175 =/ parsed (parse at src)
11816 ?: ?=(%| -.parsed) [%| (crip "module source does not parse: {(spud at)}")]
7176 ?: ?=(%| -.parsed) [%| (crip "module source does not parse: {(spud at)}")]
11817 =/ mod=module p.parsed
7177 =/ 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)
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]
11828− ?. ?=([[%mark *] ~] imports.mod) |
11829− ?. ?=([[%mold *] ~] defs.mod) |
11830− ?. =(%paths name.i.defs.mod) |
11831− !?=(%union -.shape.i.defs.mod)
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)
7178+ ?. (module-scope-valid mod prelude-values prelude-molds) [%| (crip "module has conflicting names: {(spud at)}")]
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)}")]
11846 =/ vals=(list term) (global-value-names defs.mod)
7179 =/ vals=(list term) (global-value-names defs.mod)
11847 ?: (lien vals |=(n=term =(n %main)))
7180 ?: (lien vals |=(n=term =(n %main)))
11848 [%| (crip "module kind needs unsupported inference: {(spud at)}")]
7181 [%| (crip "module kind needs unsupported inference: {(spud at)}")]
11849 =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
7182 =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
11850 ?: ?=(%| -.js) [%| p.js]
7183 ?: ?=(%| -.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)
11855 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
7185 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
11856 =/ surs=(list term) (collect-sur-imports imports.mod)
7186 =/ surs=(list term) (collect-sur-imports imports.mod)
11857 =/ marks=(list term) (collect-mark-imports imports.mod)
7187 =/ marks=(list term) (collect-mark-imports imports.mod)
11858 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
7188 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
11859 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
7189 =/ 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 ~ ~ ~ ~]
7190+ =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude]
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)])
11866− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude)
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
11874 =/ mts=(each imold-types @t) (module-mold-types molds state)
7191 =/ mts=(each imold-types @t) (module-mold-types molds state)
11875 ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
7192 ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
11876− =/ resolution=iresolved
7193+ =/ env=ienv (resolve-supported-defs defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
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
11881 ?. (module-values-complete defs.mod env)
7194 ?. (module-values-complete defs.mod env)
11882 [%| (crip "module definitions need unsupported inference: {(spud at)}")]
7195 [%| (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]
7196+ [%& [[env p.mts at] [[at [env p.mts at]] cache.p.js]]]
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]]]
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.
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]]
11943:: +golden-types-with-modules fails closed for imports without prelude
7198:: +golden-types-with-modules fails closed for imports without prelude
11944:: scope. +golden-types-with-prelude resolves supported library graphs;
7199:: scope. +golden-types-with-prelude resolves supported library graphs;
@@ -11949,8 +7204,6 @@
11950 =/ parsed (parse file src)
7205 =/ parsed (parse file src)
11951 ?: ?=(%| -.parsed) (show-error src p.parsed)
7206 ?: ?=(%| -.parsed) (show-error src p.parsed)
11952− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11953− ?^ duplicate (duplicate-fields-report file src u.duplicate)
11954 ?: (lien imports.p.parsed |=(i=import ?=(%jibb -.i)))
7207 ?: (lien imports.p.parsed |=(i=import ?=(%jibb -.i)))
11955 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
7208 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
11956 (golden-types-with-marks file src externals mark-externals)
7209 (golden-types-with-marks file src externals mark-externals)
@@ -11965,8 +7218,6 @@
11966 =/ parsed (parse file src)
7219 =/ parsed (parse file src)
11967 ?: ?=(%| -.parsed) (show-error src p.parsed)
7220 ?: ?=(%| -.parsed) (show-error src p.parsed)
11968− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11969− ?^ duplicate (duplicate-fields-report file src u.duplicate)
11970 ?: =(0 prelude-source) 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
7221 ?: =(0 prelude-source) 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
11971 =/ prelude (parse /lib/jibb/prelude/jibb prelude-source)
7222 =/ prelude (parse /lib/jibb/prelude/jibb prelude-source)
11972 ?: ?=(%| -.prelude) 'partial inference; module not checked\0aprelude source does not parse; module import inference unsupported'
7223 ?: ?=(%| -.prelude) 'partial inference; module not checked\0aprelude source does not parse; module import inference unsupported'
@@ -11974,26 +7225,16 @@
11974 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
7225 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
11975 (golden-types-with-prepared-prelude file src externals mark-externals modules prepared)
7226 (golden-types-with-prepared-prelude file src externals mark-externals modules prepared)
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]
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)
11983++ golden-types-with-prepared-prelude
7228++ golden-types-with-prepared-prelude
11984 |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prepared=(unit iprelude)]
7229 |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prepared=(unit iprelude)]
11986 =/ parsed (parse file src)
7231 =/ parsed (parse file src)
11987 ?: ?=(%| -.parsed) (show-error src p.parsed)
7232 ?: ?=(%| -.parsed) (show-error src p.parsed)
11988− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11989− ?^ duplicate (duplicate-fields-report file src u.duplicate)
11990 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
7233 ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
11991 =/ prelude-values=(list term) values.u.prepared
7234 =/ prelude-values=(list term) values.u.prepared
11992 =/ prelude-molds=(list term) molds.u.prepared
7235 =/ prelude-molds=(list term) molds.u.prepared
11993 =/ iface=(unit ifile) `iface.u.prepared
7236 =/ iface=(unit ifile) `iface.u.prepared
11994 ?. (module-scope-valid p.parsed prelude-values prelude-molds)
7237 ?. (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'
11997 'partial inference; module not checked\0amodule has conflicting names'
7238 'partial inference; module not checked\0amodule has conflicting names'
11998 =/ js=jimports-result
7239 =/ js=jimports-result
11999 (resolve-jibb-imports imports.p.parsed externals mark-externals modules ~[file] prelude-values prelude-molds ~ iface)
7240 (resolve-jibb-imports imports.p.parsed externals mark-externals modules ~[file] prelude-values prelude-molds ~ iface)
@@ -12006,23 +7247,6 @@
12006:: entries, as [mark result] with the result from +read-mark:jibb-import.
7247:: entries, as [mark result] with the result from +read-mark:jibb-import.
12007:: Unknown, duplicated, failed and undeclared entries never resolve a mold.
7248:: Unknown, duplicated, failed and undeclared entries never resolve a mold.
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
12014− ?: ?=([%ok *] result) [%& +.result]
12017−++ golden-types-with-reader-diagnostics
12018− |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
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)
12026++ golden-types-with-marks
7250++ golden-types-with-marks
12027 |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
7251 |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
@@ -12034,20 +7258,12 @@
12034 =. reserved-molds (weld reserved-molds (turn jimports |=(j=[face=term interface=ifile] face.j)))
7258 =. reserved-molds (weld reserved-molds (turn jimports |=(j=[face=term interface=ifile] face.j)))
12035 =/ parsed (parse file src)
7259 =/ parsed (parse file src)
12036 ?: ?=(%| -.parsed) (show-error src p.parsed)
7260 ?: ?=(%| -.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'
12041 =/ ds=(list def) defs.p.parsed
7261 =/ ds=(list def) defs.p.parsed
12042 =/ molds=imolds (collect-simple-molds ds)
7262 =/ molds=imolds (collect-simple-molds ds)
12043 =/ globals=(list term) (weld prelude-values (weld (turn jimports |=(j=[face=term interface=ifile] face.j)) (global-value-names ds)))
7263 =/ globals=(list term) (weld prelude-values (weld (turn jimports |=(j=[face=term interface=ifile] face.j)) (global-value-names ds)))
12044 =/ surs=(list term) (collect-sur-imports imports.p.parsed)
7264 =/ surs=(list term) (collect-sur-imports imports.p.parsed)
12045 =/ marks=(list term) (collect-mark-imports imports.p.parsed)
7265 =/ 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)
7266+ =/ env=ienv (resolve-supported-defs 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)
12051 =/ lines=(list @t) ~
7267 =/ lines=(list @t) ~
12053 ?~ ds (of-wain:format ['partial inference; module not checked' (flop lines)])
7269 ?~ ds (of-wain:format ['partial inference; module not checked' (flop lines)])
@@ -12056,38 +7272,10 @@
12056 $(ds t.ds, lines [(show-partial-mold file src d molds) lines])
7272 $(ds t.ds, lines [(show-partial-mold file src d molds) lines])
12057 ?. (unique-value-name name.d globals)
7273 ?. (unique-value-name name.d globals)
12058 $(ds t.ds, lines [(crip "++ {(trip name.d)}: name already in scope") lines])
7274 $(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)))
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])
12069 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
7275 =/ 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 ~ ~ ~ ~]
7276+ =/ result=iresult (infer-fragment val.d env [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude])
12071− =. gate-defs.initial source-defs
12072− =. head-evidence.initial heads
12073− =. initial (reserve-def-caps val.d initial)
12075− ?: |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
12076− (infer-recursive-gate d env initial)
12077− (infer-fragment val.d env initial)
12078 ?: ?=(%| -.result)
7277 ?: ?=(%| -.result)
12079 $(ds t.ds, lines [(show-inference-diagnostic file src name.d p.result) lines])
7278 $(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)
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)
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])
12091 ?: (constrained-capitals caps.state.p.result sub.state.p.result)
7279 ?: (constrained-capitals caps.state.p.result sub.state.p.result)
12092 $(ds t.ds, lines [(crip "++ {(trip name.d)}: explicit capital constraints are not supported by partial inference") lines])
7280 $(ds t.ds, lines [(crip "++ {(trip name.d)}: explicit capital constraints are not supported by partial inference") lines])
12093 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
7281 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
@@ -12104,126 +7292,7 @@
12104 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
7292 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
12105 ?: (gth (lent vars) 26)
7293 ?: (gth (lent vars) 26)
12106 $(ds t.ds, lines [(crip "++ {(trip name.d)}: too many variables for partial printer") lines])
7294 $(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])
12109 =/ printable=itype (canonical-itype typ vars)
7295 =/ printable=itype (canonical-itype typ vars)
12110 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
7296 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
12111 $(ds t.ds, lines [line lines])
7297 $(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
12117− ^- (unit [tag=@ fields=(list field)])
12118− ?. ?=(%cell -.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]
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) ~
12143− |= [name=term sh=shape]
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)
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)
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) ~
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
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)
12204− ?> ?=(%face -.u.kids)
12205− =/ children=itype [%face name.u.kids [%collection %list ~[typ]]]
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)]
12216−++ grec-collect-molds
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]