@@ -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
@@ -4609,75 +4595,26 @@
4609:: their defaulting and inferred generalization are implemented.
4595:: their defaulting and inferred generalization are implemented.
4610:: Bare @ is a separate unrestricted atom type. A directional fit check
4596:: Bare @ is a separate unrestricted atom type. A directional fit check
4611:: 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
4612−:: needs a not-yet-implemented constraint remains unsupported. Named unions
4598+:: needs a not-yet-implemented constraint remains unsupported. Only
4613−:: retain origin and ordered arguments, including phantom arguments, apart
4599+:: unfaced cells are represented here.
4614−:: from their display name. Generic cases must be disjoint for all arguments.
4615−:: Unnamed union printing is informational; it is not Jibb syntax.
4617−:: `proj` is a reserved, type-directed operation, not an ordinary gate.
4618−:: The supported fragment selects uniquely faced fields from a known record
4619−:: in source order (reordering is a doc question). It records the original
4620−:: call, source and target types, and source axes with its definition;
4621−:: A single selected field keeps its face and uses one source axis.
4622−:: Checked module interfaces retain that evidence and their source, including
4623−:: the private prelude dependency. A later lowerer must replace the call by
4624−:: an inline gate applied to the operand once; no lowering is implemented yet.
4625−:: Ordinary fits never insert a projection. Unknown or variable-origin record
4626−:: spines, nested projected fields and projections in
4627−:: recursive groups remain unsupported. Directional fits bound faced-spine
4628−:: proofs to fewer than 1,024 cells; the projection planner has a separate
4629−:: 4,096-step bound. These are inference limits, not language limits.
4631−:: Supported API imports derive request-gate types atomically for multiple
4632−:: paths, including one typed segment or one diff fold per case. Their checked
4633−:: ordinary definitions, mark molds and supported poke constructor are also
4634−:: exported. A selected /sur mold is checked through its trusted reader result;
4635−:: unused cores and other bindings are not independently validated. APIs
4636−:: with /= imports, separate scry paths, multiple parameters or diffs, or a
4637−:: parameter together with a fold remain unsupported. The unchanged todo API
4638−:: fits this fragment, including named closed fold gates.
4640−:: Each case's source-derived schema and canonical API identity travel in a
4641−:: dependency closure bound to the exact supplied bundle, prelude, scope and
4642−:: trusted reader results. Unknown cached entries are rebuilt. Request-bearing
4643−:: closures are limited to 256 source paths and requests. This is type
4644−:: inference only: no request lowering, runtime schema validator or proof that
4645−:: an arbitrary ask value is watchable is supplied.
4647−:: A closed gate sample may omit one outer face from a known input slot when
4648−:: its product is identical. Distinct written names, nested value faces,
4649−:: ambiguous cell tails and raw-variable-origin fits retain their prior rules.
4651−:: In one synthetic eval of a 48-module deep and 48-module wide request-free
4652−:: graph, baseline versus certificate inference took 21.53 s versus 23.10 s
4653−:: elapsed (21.10 s versus 22.34 s CPU), including startup. The deep cache's
4654−:: jam grew from 2,402 to 4,209 bytes (+1,807 bytes). These single-run figures
4655−:: are not production memory or performance benchmarks.
4658 $~ [%var 0]
4602 $~ [%var 0]
4659 $% [%var id=@ud]
4603 $% [%var id=@ud]
4660 [%avar id=@ud]
4604 [%avar id=@ud]
4662 [%nvar id=@ud]
4605 [%nvar id=@ud]
4664 [%atom aura=@ta]
4606 [%atom aura=@ta]
4665 [%any-atom ~]
4607 [%any-atom ~]
4666 [%flag ~]
4608 [%flag ~]
4668 [%tag id=@ud literal=lit constructor=?]
4609 [%tag id=@ud literal=lit constructor=?]
4669 [%const literal=lit]
4610 [%const literal=lit]
4670− [%collection name=term args=(list itype)]
4671− [%recursive module=term name=term label=(unit @t)]
4672− [%jrec at=path name=term label=(unit @t) head=term aura=@ta tail=term]
4673− [%union cases=(list itype) origin=(unit [at=path name=term]) label=(unit @t) args=(list itype)]
4611+ [%union cases=(list itype)]
4674 [%face name=term body=itype]
4612 [%face name=term body=itype]
4675 [%fn sample=itype product=itype]
4613 [%fn sample=itype product=itype]
4676 [%cell hed=itype tal=itype]
4614 [%cell hed=itype tal=itype]
4678+$ ibinding [id=@ud val=itype]
4616+$ ibinding [id=@ud val=itype]
4679+$ isub (list ibinding)
4617+$ isub (list ibinding)
4680−+$ ipending [id=@ud literal=lit]
4682++ itype-lookup
4619++ itype-lookup
4683 |= [n=@ud sub=isub]
4620 |= [n=@ud sub=isub]
@@ -4693,32 +4630,18 @@
4694 =/ found=(unit itype) (itype-lookup id.t sub)
4631 =/ found=(unit itype) (itype-lookup id.t sub)
4695 ?~ found t
4632 ?~ found t
4696− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4697 $(t u.found)
4633 $(t u.found)
4699 =/ found=(unit itype) (itype-lookup id.t sub)
4635 =/ found=(unit itype) (itype-lookup id.t sub)
4700 ?~ found t
4636 ?~ found t
4701− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4704− =/ found=(unit itype) (itype-lookup id.t sub)
4706− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4707 $(t u.found)
4637 $(t u.found)
4709 =/ found=(unit itype) (itype-lookup id.t sub)
4639 =/ found=(unit itype) (itype-lookup id.t sub)
4710 ?~ found t
4640 ?~ found t
4711− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4714− =/ found=(unit itype) (itype-lookup id.t sub)
4716− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4717 $(t u.found)
4641 $(t u.found)
4719 =/ found=(unit itype) (itype-lookup id.t sub)
4643 =/ found=(unit itype) (itype-lookup id.t sub)
4720 ?~ found t
4644 ?~ found t
4721− ?: &(|(?=(%rvar -.u.found) ?=(%rnvar -.u.found)) =(id.t +.u.found)) u.found
4722 $(t u.found)
4645 $(t u.found)
@@ -4729,19 +4652,13 @@
4730 %var =(n id.t)
4653 %var =(n id.t)
4731 %avar =(n id.t)
4654 %avar =(n id.t)
4733 %nvar =(n id.t)
4655 %nvar =(n id.t)
4736 %any-atom |
4657 %any-atom |
4739 %tag =(n id.t)
4659 %tag =(n id.t)
4740 %const |
4660 %const |
4741− %union |((lien cases.t |=(c=itype (itype-occurs n c sub))) (lien args.t |=(c=itype (itype-occurs n c sub))))
4661+ %union (lien cases.t |=(c=itype (itype-occurs n c sub)))
4744− %collection (lien args.t |=(c=itype (itype-occurs n c sub)))
4745 %face $(t body.t)
4662 %face $(t body.t)
4746 %fn |($(t sample.t) $(t product.t))
4663 %fn |($(t sample.t) $(t product.t))
4747 %cell |($(t hed.t) $(t tal.t))
4664 %cell |($(t hed.t) $(t tal.t))
@@ -4759,50 +4676,12 @@
4759 =. a (itype-walk a sub)
4676 =. a (itype-walk a sub)
4760 =. b (itype-walk b sub)
4677 =. b (itype-walk b sub)
4761 ?: =(a b) `sub
4678 ?: =(a b) `sub
4762− ?: &(?=(%jrec -.a) ?=(%jrec -.b))
4763− ?:(&(=(at.a at.b) =(name.a name.b) =(head.a head.b) =(aura.a aura.b) =(tail.a tail.b)) `sub ~)
4764− ?: &(?=(%recursive -.a) ?=(%recursive -.b))
4765− ?:(&(=(module.a module.b) =(name.a name.b)) `sub ~)
4766− ?: &(?=(%union -.a) ?=(%union -.b))
4767− ?. =(origin.a origin.b) ~
4768− ?: &(?=(~ args.a) ?=(~ args.b)) ?:(=(cases.a cases.b) `sub ~)
4770− (itype-unify-args args.a args.b sub)
4771− ?: &(?=(%collection -.a) ?=(%collection -.b))
4772− ?. =(name.a name.b) ~
4773− (itype-unify-args args.a args.b sub)
4774 ?: ?=(%var -.a)
4679 ?: ?=(%var -.a)
4775 ?: (itype-occurs id.a b sub) ~
4680 ?: (itype-occurs id.a b sub) ~
4776 `[[id.a b] sub]
4681 `[[id.a b] sub]
4777 ?: ?=(%var -.b)
4682 ?: ?=(%var -.b)
4778 ?: (itype-occurs id.b a sub) ~
4683 ?: (itype-occurs id.b a sub) ~
4779 `[[id.b a] sub]
4684 `[[id.b a] sub]
4780− :: Arithmetic's aura variable excludes loobeans; decimal literals
4781− :: remain defaultable until a later constraint makes them concrete.
4782− ?: &(?=(%nvar -.a) ?=(%rvar -.b))
4783− `[[id.b [%rnvar id.a]] [id.a [%rnvar id.a]] sub]
4784− ?: &(?=(%rvar -.a) ?=(%nvar -.b))
4785− `[[id.a [%rnvar id.b]] [id.b [%rnvar id.b]] sub]
4786− ?: &(?=(%rnvar -.a) ?=(%rvar -.b)) `[[id.b a] sub]
4787− ?: &(?=(%rvar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4788− ?: &(?=(%rnvar -.a) ?=(%nvar -.b)) `[[id.b a] sub]
4789− ?: &(?=(%nvar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4790− ?: &(?=(%rnvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4791− ?: &(?=(%avar -.a) ?=(%rnvar -.b)) `[[id.a b] sub]
4793− ?. |(?=(%rnvar -.b) ?=(%atom -.b)) ~
4798− ?: &(?=(%avar -.a) ?=(%rvar -.b)) `[[id.a b] sub]
4799− ?: &(?=(%rvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4801− ?. |(?=(%rvar -.b) ?=(%atom -.b)) ~
4806 :: The narrower decimal constraint survives a match with an atom
4685 :: The narrower decimal constraint survives a match with an atom
4807 :: variable; decimal syntax alone does not make it a loobean.
4686 :: variable; decimal syntax alone does not make it a loobean.
4808 ?: &(?=(%nvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
4687 ?: &(?=(%nvar -.a) ?=(%avar -.b)) `[[id.b a] sub]
@@ -4835,15 +4714,6 @@
4835 $(a tal.a, b tal.b, sub u.first)
4714 $(a tal.a, b tal.b, sub u.first)
4839− |= [as=(list itype) bs=(list itype) sub=isub]
4841− ?~ as ?~(bs `sub ~)
4843− =/ next=(unit isub) (itype-unify i.as i.bs sub)
4845− $(as t.as, bs t.bs, sub u.next)
4847:: +itype-fit: one-way widening from an actual type to an expected type
4717:: +itype-fit: one-way widening from an actual type to an expected type
4849:: An unknown variable used where @ is expected gains a fresh atom
4719:: An unknown variable used where @ is expected gains a fresh atom
@@ -4857,19 +4727,13 @@
4864 %any-atom &
4732 %any-atom &
4868 %const |
4735 %const |
4869− %union |((lien cases.t |=(c=itype (itype-has-any-atom c sub))) (lien args.t |=(c=itype (itype-has-any-atom c sub))))
4736+ %union (lien cases.t |=(c=itype (itype-has-any-atom c sub)))
4872− %collection (lien args.t |=(c=itype (itype-has-any-atom c sub)))
4873 %face $(t body.t)
4737 %face $(t body.t)
4874 %fn |($(t sample.t) $(t product.t))
4738 %fn |($(t sample.t) $(t product.t))
4875 %cell |($(t hed.t) $(t tal.t))
4739 %cell |($(t hed.t) $(t tal.t))
@@ -4893,14 +4757,6 @@
4893:: Related auras in a structural unification need a common-type rule;
4757:: Related auras in a structural unification need a common-type rule;
4894:: until that rule is implemented, report an unknown rather than error.
4758:: until that rule is implemented, report an unknown rather than error.
4896−++ itype-family-related-collection-args
4897− |= [as=(list itype) bs=(list itype) sub=isub]
4901− ?: (itype-family-related i.as i.bs sub) &
4902− $(as t.as, bs t.bs)
4904++ itype-family-related
4760++ itype-family-related
4905 |= [a=itype b=itype sub=isub]
4761 |= [a=itype b=itype sub=isub]
@@ -4909,9 +4765,6 @@
4909 ?: &(?=(%atom -.a) ?=(%atom -.b))
4765 ?: &(?=(%atom -.a) ?=(%atom -.b))
4910 ?. !=(aura.a aura.b) |
4766 ?. !=(aura.a aura.b) |
4911 |((aura-prefix aura.a aura.b) (aura-prefix aura.b aura.a))
4767 |((aura-prefix aura.a aura.b) (aura-prefix aura.b aura.a))
4912− ?: &(?=(%collection -.a) ?=(%collection -.b))
4913− ?. =(name.a name.b) |
4914− (itype-family-related-collection-args args.a args.b sub)
4915 ?: &(?=(%face -.a) ?=(%face -.b))
4768 ?: &(?=(%face -.a) ?=(%face -.b))
4916 ?. =(name.a name.b) |
4769 ?. =(name.a name.b) |
4917 $(a body.a, b body.b)
4770 $(a body.a, b body.b)
@@ -4931,19 +4784,13 @@
4931 ?- -.typ
4784 ?- -.typ
4938 %any-atom &
4789 %any-atom &
4942 %const &
4792 %const &
4943− %union |((lien cases.typ |=(c=itype (itype-has-fixed-atom c))) (lien args.typ |=(c=itype (itype-has-fixed-atom c))))
4793+ %union (lien cases.typ |=(c=itype (itype-has-fixed-atom c)))
4946− %collection (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
4947 %face $(typ body.typ)
4794 %face $(typ body.typ)
4948 %fn |($(typ sample.typ) $(typ product.typ))
4795 %fn |($(typ sample.typ) $(typ product.typ))
4949 %cell |($(typ hed.typ) $(typ tal.typ))
4796 %cell |($(typ hed.typ) $(typ tal.typ))
@@ -4971,68 +4818,20 @@
4972 =. t (itype-walk t sub)
4819 =. t (itype-walk t sub)
4974− %collection (lien args.t |=(c=itype (itype-has-face c sub)))
4976 %cell |($(t hed.t) $(t tal.t))
4822 %cell |($(t hed.t) $(t tal.t))
4977 %fn |($(t sample.t) $(t product.t))
4823 %fn |($(t sample.t) $(t product.t))
4981−:: Closed function samples may omit a slot face, but a known name must
4982−:: match another known name. Keep nested value faces and require exact
4983−:: invariant compatibility; a faced tail against a cell is ambiguous.
4984−++ itype-closed-slot-match
4985− |= [a=itype b=itype]
4987− ?: &(?=(%face -.a) ?=(%face -.b))
4988− ?. =(name.a name.b) |
4989− ?=(^ (itype-unify body.a body.b ~))
4990− ?: ?=(%face -.a) ?=(^ (itype-unify body.a b ~))
4991− ?: ?=(%face -.b) ?=(^ (itype-unify a body.b ~))
4992− ?=(^ (itype-unify a b ~))
4993−++ itype-closed-sample-match
4994− |= [a=itype b=itype fuel=@ud]
4997− ?. &(?=(%cell -.a) ?=(%cell -.b)) |
4998− ?. (itype-closed-slot-match hed.a hed.b) |
5001− ?: &(?=(%cell -.x) ?=(%cell -.y))
5002− ?=(^ (itype-unify x y ~))
5003− ?: |(&(?=(%face -.x) ?=(%cell -.y)) &(?=(%cell -.x) ?=(%face -.y))) |
5004− (itype-closed-slot-match x y)
5005−++ itype-closed-gates-match
5006− |= [a=itype b=itype]
5008− ?. &(?=(%fn -.a) ?=(%fn -.b)) |
5009− ?. &(?=(%cell -.sample.a) ?=(%cell -.sample.b)) |
5010− ?. =(product.a product.b) |
5011− ?^ (itype-vars a) |
5012− ?^ (itype-vars b) |
5013− ?: |((itype-has-tag a) (itype-has-tag b)) |
5014− ?. (itype-closed-sample-match sample.a sample.b 1.024) |
5015− ?=(^ (itype-unify product.a product.b ~))
5017−++ itype-face-asym-collection-args
5018− |= [as=(list itype) bs=(list itype) sub=isub]
5022− ?: (itype-face-asym i.as i.bs sub) &
5023− $(as t.as, bs t.bs)
5025++ itype-face-asym
4827++ itype-face-asym
5026 |= [a=itype b=itype sub=isub]
4828 |= [a=itype b=itype sub=isub]
5028 =. a (itype-walk a sub)
4830 =. a (itype-walk a sub)
5029 =. b (itype-walk b sub)
4831 =. b (itype-walk b sub)
5030− ?: &(?=(%collection -.a) ?=(%collection -.b))
5031− ?. =(name.a name.b) |
5032− (itype-face-asym-collection-args args.a args.b sub)
5033 ?: &(?=(%face -.a) ?=(%face -.b)) $(a body.a, b body.b)
4832 ?: &(?=(%face -.a) ?=(%face -.b)) $(a body.a, b body.b)
5034− ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%rvar -.b) |(?=(%nvar -.b) ?=(%rnvar -.b)))
4833+ ?: ?=(%face -.a) !|(?=(%var -.b) ?=(%avar -.b) ?=(%nvar -.b))
5035− ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%rvar -.a) |(?=(%nvar -.a) ?=(%rnvar -.a)))
4834+ ?: ?=(%face -.b) !|(?=(%var -.a) ?=(%avar -.a) ?=(%nvar -.a))
5036 ?: &(?=(%cell -.a) ?=(%cell -.b)) |($(a hed.a, b hed.b) $(a tal.a, b tal.b))
4835 ?: &(?=(%cell -.a) ?=(%cell -.b)) |($(a hed.a, b hed.b) $(a tal.a, b tal.b))
5037 ?: &(?=(%fn -.a) ?=(%fn -.b)) |($(a sample.a, b sample.b) $(a product.a, b product.b))
4836 ?: &(?=(%fn -.a) ?=(%fn -.b)) |($(a sample.a, b sample.b) $(a product.a, b product.b))
@@ -5055,30 +4854,6 @@
5055 [%cell $(actual hed.actual, expected hed.expected) $(actual tal.actual, expected tal.expected)]
4854 [%cell $(actual hed.actual, expected hed.expected) $(actual tal.actual, expected tal.expected)]
5056 expected
4855 expected
5058−:: Positional call arguments do not write the sample's enclosing field
5059−:: labels. Ignore one raw sample-slot face per written argument while
5060−:: checking value faces as usual. An unknown or variable-bound cell spine
5061−:: cannot justify this distinction, so keep the existing conservative guard.
5062−++ itype-positional-slot-face-asym
5063− |= [actual=itype expected=itype sub=isub]
5065− ?: &(?=(%fn -.actual) ?=(%fn -.expected) (itype-closed-gates-match actual expected)) |
5066− (itype-face-asym actual expected sub)
5068−++ itype-positional-face-asym
5069− |= [args=(list expr) actual=itype expected=itype sub=isub]
5073− =/ slot=itype expected
5074− =? slot ?=(%face -.slot) body.slot
5075− (itype-positional-slot-face-asym actual slot sub)
5076− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) &
5077− =/ slot=itype hed.expected
5078− =? slot ?=(%face -.slot) body.slot
5079− ?: (itype-positional-slot-face-asym hed.actual slot sub) &
5080− $(args t.args, actual tal.actual, expected tal.expected)
5082++ itype-output-may-be-cell
4857++ itype-output-may-be-cell
5083 |= [t=itype sub=isub]
4858 |= [t=itype sub=isub]
@@ -5087,27 +4862,16 @@
5089 %union &
4864 %union &
5094 %face $(t body.t)
4865 %face $(t body.t)
5095 %fn |($(t sample.t) $(t product.t))
4866 %fn |($(t sample.t) $(t product.t))
5099++ pending-tags
4870++ pending-tags
5100− |= [tags=(list ipending) sub=isub]
4871+ |= [tags=(list @ud) sub=isub]
5102 ?~ tags |
4873 ?~ tags |
5103− ?~ (itype-lookup id.i.tags sub) &
4874+ ?~ (itype-lookup i.tags sub) &
5107− |= [tags=(list ipending) sub=isub]
5110− ?: &(?=(%null form.literal.i.tags) ?=(~ (itype-lookup id.i.tags sub))) &
5111 $(tags t.tags)
4875 $(tags t.tags)
5113:: Tags remain constrained until a mold selects a case or permitted atom
4877:: Tags remain constrained until a mold selects a case or permitted atom
@@ -5118,11 +4882,10 @@
5121− %collection (lien args.t |=(c=itype (itype-has-tag c)))
5122 %face $(t body.t)
4885 %face $(t body.t)
5123 %fn |($(t sample.t) $(t product.t))
4886 %fn |($(t sample.t) $(t product.t))
5124 %cell |($(t hed.t) $(t tal.t))
4887 %cell |($(t hed.t) $(t tal.t))
5125− %union |((lien cases.t |=(c=itype (itype-has-tag c))) (lien args.t |=(c=itype (itype-has-tag c))))
4888+ %union (lien cases.t |=(c=itype (itype-has-tag c)))
@@ -5131,59 +4894,12 @@
5133 %union &
4896 %union &
5134− %collection (lien args.t |=(c=itype (itype-has-union c)))
5135 %face $(t body.t)
4897 %face $(t body.t)
5136 %fn |($(t sample.t) $(t product.t))
4898 %fn |($(t sample.t) $(t product.t))
5137 %cell |($(t hed.t) $(t tal.t))
4899 %cell |($(t hed.t) $(t tal.t))
5141−:: Until a visible generic alias can be selected, expanding a named
5142−:: generic union would hide phantom arguments and its origin. This is a
5143−:: limitation of partial inference, not the unnamed-union print notation.
5145−++ itype-has-hidden-generic
5150− ?: &(?=(~ label.t) ?=(^ args.t)) &
5151− (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-generic c)))
5152− %collection (lien args.t |=(c=itype (itype-has-hidden-generic c)))
5154− %fn |($(t sample.t) $(t product.t))
5155− %cell |($(t hed.t) $(t tal.t))
5159−++ itype-has-recursive
5165− %collection (lien args.t |=(c=itype (itype-has-recursive c)))
5166− %union (lien (weld args.t cases.t) |=(c=itype (itype-has-recursive c)))
5168− %cell |($(t hed.t) $(t tal.t))
5169− %fn |($(t sample.t) $(t product.t))
5173−++ itype-has-hidden-recursive
5177− %recursive ?=(~ label.t)
5178− %jrec ?=(~ label.t)
5179− %collection (lien args.t |=(c=itype (itype-has-hidden-recursive c)))
5180− %union (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-recursive c)))
5182− %cell |($(t hed.t) $(t tal.t))
5183− %fn |($(t sample.t) $(t product.t))
5187++ itype-fit-cases
4903++ itype-fit-cases
5188 |= [actual=itype cases=(list itype) sub=isub next=@ud]
4904 |= [actual=itype cases=(list itype) sub=isub next=@ud]
@@ -5203,117 +4919,36 @@
5203 $(cases t.cases, good `trial)
4919 $(cases t.cases, good `trial)
5206−:: A constructor needs a case whose head has the same literal noun as its
4922+:: A constructor needs a case with its tag at the head and a payload
5207−:: tag. An unresolved or opaque case may reveal one later, so it cannot
4923+:: compatible with the expected gate sample. Other case forms do not
5208−:: prove a mismatch or a unique match. A broad atom mold is not a case.
4924+:: identify a constructor.
5210++ itype-fit-ctor-cases
4926++ itype-fit-ctor-cases
5211 |= [tag=lit sample=itype cases=(list itype) sub=isub next=@ud]
4927 |= [tag=lit sample=itype cases=(list itype) sub=isub next=@ud]
5213 =/ found=(unit ifit) ~
4929 =/ found=(unit ifit) ~
5217− ?: pending [%unknown ~]
5218− ?~ found [%bad ~]
4931+ ?~ cases ?~(found [%bad ~] u.found)
5220− =/ raw=itype i.cases
5222− $(cases t.cases, pending &)
5223− =/ c=itype (itype-walk raw sub)
4932+ =/ c=itype (itype-walk i.cases sub)
5224− ?: ?=(?(%var %tag %recursive %jrec %union %face) -.c)
5225− $(cases t.cases, pending &)
5226 ?. ?=(%cell -.c) $(cases t.cases)
4933 ?. ?=(%cell -.c) $(cases t.cases)
5227− =/ raw-head=itype hed.c
4934+ =/ head=itype (itype-walk hed.c sub)
5228− ?: ?=(%var -.raw-head)
5229− $(cases t.cases, pending &)
5230− =/ head=itype (itype-walk raw-head sub)
5231− :: A single faced, explicitly atom-only head cannot be the tag case.
5232− :: Do not follow variables or peel nested faces for this negative proof.
5233− ?: ?=(%face -.head)
5234− ?: ?=(?(%atom %any-atom %flag %avar %rvar %nvar %rnvar) -.body.head)
5236− $(cases t.cases, pending &)
5237− ?: ?=(?(%var %tag %recursive %jrec %union) -.head)
5238− $(cases t.cases, pending &)
5239 ?. ?=(%const -.head) $(cases t.cases)
4935 ?. ?=(%const -.head) $(cases t.cases)
5240 ?. =(val.literal.head val.tag) $(cases t.cases)
4936 ?. =(val.literal.head val.tag) $(cases t.cases)
5241− :: Equal heads can have disjoint payloads. Test each from the original
4937+ ?^ found [%unknown ~]
5242− :: substitution; a unique success is usable only with no unknown rival.
5243 =/ trial=ifit (itype-fit sample tal.c sub next)
4938 =/ trial=ifit (itype-fit sample tal.c sub next)
5245− %bad $(cases t.cases)
5246− %unknown $(cases t.cases, pending &)
5248− ?^ found [%unknown ~]
5249− $(cases t.cases, found `trial)
4939+ $(cases t.cases, found `trial)
5252++ itype-fit
4941++ itype-fit
5253 |= [actual=itype expected=itype sub=isub next=@ud]
4942 |= [actual=itype expected=itype sub=isub next=@ud]
5255− (itype-fit-inner actual expected sub next | |)
5257− |= [actual=itype expected=itype sub=isub next=@ud skip-width=? spine-proof=?]
5259− ?: &(!skip-width ?=(%cell -.actual) ?=(%cell -.expected) |((width-spine-exhausted actual 1.024) (width-spine-exhausted expected 1.024)))
5261− =/ known=(unit [source=iwfields target=iwfields])
5263− (width-known-shape actual expected sub)
5264− =/ too-wide=? ?~(known | (gth (lent order.source.u.known) (lent order.target.u.known)))
5265− ?: too-wide [%unknown ~]
5266− =/ spine-checked=? |(spine-proof ?=(^ known))
5267 =/ uncertain=?
4944 =/ uncertain=?
5268− |(?=(%var -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)) ?=(%var -.expected) ?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected)))
4945+ |(?=(%var -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%var -.expected) ?=(%avar -.expected) ?=(%nvar -.expected))
5270− |(?=(%var -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))
5271 =. actual (itype-walk actual sub)
4946 =. actual (itype-walk actual sub)
5272 =. expected (itype-walk expected sub)
4947 =. expected (itype-walk expected sub)
5273 ?: =(actual expected) [%ok sub next]
4948 ?: =(actual expected) [%ok sub next]
5274− :: The relation of the source loobean mold to explicit @f is not yet
5275− :: established. Keep it unsupported rather than asserting a mismatch.
5276− ?: &(?=(%flag -.actual) ?=(%atom -.expected) =(%f aura.expected)) [%unknown ~]
5277− :: Any value can be used where a noun is expected. An unresolved
5278− :: bare tag is fixed as a constant; a constructor still needs a gate.
5279− ?: ?=(%noun -.expected)
5280− ?: ?=(%tag -.actual)
5281− ?: constructor.actual [%unknown ~]
5282− [%ok [[id.actual expected] sub] next]
5284− :: An arbitrary noun is not known to fit a narrower type.
5285− ?: &(?=(%noun -.actual) !?=(%var -.expected)) [%unknown ~]
5286− ?: &(!uncertain ?=(%jrec -.actual) ?=(%face -.expected)) $(expected body.expected)
5287− ?: &(!uncertain ?=(%face -.actual) ?=(%jrec -.expected)) $(actual body.actual)
5288− ?: &(?=(%jrec -.actual) ?=(%jrec -.expected))
5289− ?:(&(=(at.actual at.expected) =(name.actual name.expected) =(head.actual head.expected) =(aura.actual aura.expected) =(tail.actual tail.expected)) [%ok sub next] [%bad ~])
5290− ?: &(|(?=(%jrec -.actual) ?=(%jrec -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
5291− ?: &(?=(%recursive -.actual) ?=(%recursive -.expected))
5292− ?:(&(=(module.actual module.expected) =(name.actual name.expected)) [%ok sub next] [%bad ~])
5293− ?: &(|(?=(%recursive -.actual) ?=(%recursive -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
5294− ?: &(?=(%union -.actual) ?=(%union -.expected))
4949+ ?: &(?=(%union -.actual) ?=(%union -.expected)) [%unknown ~]
5295− ?. =(origin.actual origin.expected) [%unknown ~]
5296− ?: &(?=(~ args.actual) ?=(~ args.expected))
5297− ?:(=(cases.actual cases.expected) [%ok sub next] [%unknown ~])
5298− ?~ origin.actual [%unknown ~]
5299− =/ unified=(unit isub) (itype-unify-args args.actual args.expected sub)
5300− ?^ unified [%ok u.unified next]
5302− :: A known union can instantiate an unconstrained sample directly;
5303− :: preserve unknown results for variable-bound union origins.
5304− ?: &(!actual-open ?=(%union -.actual) ?=(%var -.expected))
5305− ?~ origin.actual [%unknown ~]
5306− =/ normalized=itype (itype-normalize actual sub)
5307− ?: |((itype-has-tag normalized) (itype-has-recursive normalized) (itype-has-any-atom actual sub)) [%unknown ~]
5308− =/ unified=(unit isub) (itype-unify actual expected sub)
5309− ?~ unified [%unknown ~]
5310− [%ok u.unified next]
5311− :: A concrete union value in a tuple may acquire the expected field's
5312− :: face. A variable-bound union still needs face propagation support.
5313− ?: &(!uncertain ?=(%union -.actual) ?=(%face -.expected))
5314− $(expected body.expected)
5315 ?: ?=(%union -.actual) [%unknown ~]
4950 ?: ?=(%union -.actual) [%unknown ~]
5316− ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)))) [%unknown ~]
4951+ ?: &(?=(%union -.expected) |(?=(%avar -.actual) ?=(%nvar -.actual))) [%unknown ~]
5317 ?: &(?=(%union -.expected) !?=(%var -.actual))
4952 ?: &(?=(%union -.expected) !?=(%var -.actual))
5318 (itype-fit-cases actual cases.expected sub next)
4953 (itype-fit-cases actual cases.expected sub next)
5319 ?: ?=(%tag -.actual)
4954 ?: ?=(%tag -.actual)
@@ -5321,7 +4956,7 @@
5321 =/ u=(unit isub) (itype-unify actual expected sub)
4956 =/ u=(unit isub) (itype-unify actual expected sub)
5322 ?~ u [%bad ~]
4957 ?~ u [%bad ~]
5323 [%ok u.u next]
4958 [%ok u.u next]
5324− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
4959+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5325 ?: ?=(%face -.expected) $(expected body.expected)
4960 ?: ?=(%face -.expected) $(expected body.expected)
5326 ?: constructor.actual
4961 ?: constructor.actual
5327 ?. ?=(%fn -.expected) [%bad ~]
4962 ?. ?=(%fn -.expected) [%bad ~]
@@ -5330,10 +4965,6 @@
5330 =/ trial=ifit (itype-fit-ctor-cases literal.actual sample.expected cases sub next)
4965 =/ trial=ifit (itype-fit-ctor-cases literal.actual sample.expected cases sub next)
5331 ?. ?=(%ok -.trial) trial
4966 ?. ?=(%ok -.trial) trial
5332 [%ok [[id.actual expected] sub.trial] next.trial]
4967 [%ok [[id.actual expected] sub.trial] next.trial]
5333− :: Zero may be the empty list. A nested cell fit lacks the context
5334− :: needed to resolve it here, so do not report a definite mismatch.
5335− ?: &(?=(%collection -.expected) =(%list name.expected) =(0 val.literal.actual))
5337 ?: ?=(%const -.expected)
4968 ?: ?=(%const -.expected)
5338 ?:(=(val.literal.actual val.literal.expected) [%ok [[id.actual expected] sub] next] [%bad ~])
4969 ?:(=(val.literal.actual val.literal.expected) [%ok [[id.actual expected] sub] next] [%bad ~])
5339 ?: ?=(%atom -.expected)
4970 ?: ?=(%atom -.expected)
@@ -5349,17 +4980,11 @@
5349 =/ u=(unit isub) (itype-unify actual expected sub)
4980 =/ u=(unit isub) (itype-unify actual expected sub)
5350 ?~ u [%bad ~]
4981 ?~ u [%bad ~]
5351 [%ok u.u next]
4982 [%ok u.u next]
5352− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
4983+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5353 ?: ?=(%face -.expected) $(expected body.expected)
4984 ?: ?=(%face -.expected) $(expected body.expected)
5354− ?: &(?=(%collection -.expected) =(%list name.expected) =(0 val.literal.actual))
5356 ?: ?=(%const -.expected)
4985 ?: ?=(%const -.expected)
5357 ?:(=(val.literal.actual val.literal.expected) [%ok sub next] [%bad ~])
4986 ?:(=(val.literal.actual val.literal.expected) [%ok sub next] [%bad ~])
5358 ?: ?=(%atom -.expected)
4987 ?: ?=(%atom -.expected)
5359− :: A loobean singleton must not silently widen into another aura.
5360− ?: =(%loobean form.literal.actual)
5361− ?: =(%f aura.expected) [%unknown ~]
5363 ?: |(=(%tas aura.expected) =(%ta aura.expected)) [%ok sub next]
4988 ?: |(=(%tas aura.expected) =(%ta aura.expected)) [%ok sub next]
5364 [%bad ~]
4989 [%bad ~]
5365 ?: ?=(%flag -.expected)
4990 ?: ?=(%flag -.expected)
@@ -5367,14 +4992,8 @@
5367 ?: ?=(%any-atom -.expected) [%ok sub next]
4992 ?: ?=(%any-atom -.expected) [%ok sub next]
5368 [%bad ~]
4993 [%bad ~]
5369 ?: &(uncertain (itype-face-asym actual expected sub)) [%unknown ~]
4994 ?: &(uncertain (itype-face-asym actual expected sub)) [%unknown ~]
5370− :: A known face labels the same noun. Peel it before applying the
5371− :: directional unrestricted-atom rule, preserving raw-variable guards.
5372− ?: &(!uncertain ?=(%any-atom -.actual) ?=(%face -.expected))
5373− $(expected body.expected, skip-width |, spine-proof |)
5374− ?: &(!uncertain ?=(%any-atom -.expected) ?=(%face -.actual))
5375− $(actual body.actual, skip-width |, spine-proof |)
5376 ?: ?=(%any-atom -.expected)
4995 ?: ?=(%any-atom -.expected)
5377− ?: |(?=(%atom -.actual) ?=(%avar -.actual) ?=(%rvar -.actual) |(?=(%nvar -.actual) ?=(%rnvar -.actual)) ?=(%flag -.actual)) [%ok sub next]
4996+ ?: |(?=(%atom -.actual) ?=(%avar -.actual) ?=(%nvar -.actual) ?=(%flag -.actual)) [%ok sub next]
5378 ?: ?=(%var -.actual)
4997 ?: ?=(%var -.actual)
5379 =/ unified=(unit isub) (itype-unify actual [%avar next] sub)
4998 =/ unified=(unit isub) (itype-unify actual [%avar next] sub)
5380 ?~ unified [%bad ~]
4999 ?~ unified [%bad ~]
@@ -5385,48 +5004,34 @@
5385 =/ unified=(unit isub) (itype-unify actual expected sub)
5004 =/ unified=(unit isub) (itype-unify actual expected sub)
5386 ?~ unified [%bad ~]
5005 ?~ unified [%bad ~]
5387 [%ok u.unified next]
5006 [%ok u.unified next]
5388− ?: |(?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected))) [%unknown ~]
5007+ ?: |(?=(%avar -.expected) ?=(%nvar -.expected)) [%unknown ~]
5389 [%bad ~]
5008 [%bad ~]
5390 ?: &(?=(%atom -.actual) ?=(%atom -.expected))
5009 ?: &(?=(%atom -.actual) ?=(%atom -.expected))
5391 ?: (aura-prefix aura.expected aura.actual) [%ok sub next]
5010 ?: (aura-prefix aura.expected aura.actual) [%ok sub next]
5392 ?: &((aura-prefix aura.actual aura.expected) uncertain) [%unknown ~]
5011 ?: &((aura-prefix aura.actual aura.expected) uncertain) [%unknown ~]
5393 [%bad ~]
5012 [%bad ~]
5394 ?: &(?=(%cell -.actual) ?=(%cell -.expected))
5013 ?: &(?=(%cell -.actual) ?=(%cell -.expected))
5395− =/ first=ifit $(actual hed.actual, expected hed.expected, skip-width |, spine-proof |)
5014+ =/ first=ifit $(actual hed.actual, expected hed.expected)
5396 ?. ?=(%ok -.first) first
5015 ?. ?=(%ok -.first) first
5397− $(actual tal.actual, expected tal.expected, sub sub.first, next next.first, skip-width spine-checked, spine-proof spine-checked)
5016+ $(actual tal.actual, expected tal.expected, sub sub.first, next next.first)
5398− :: A field may add a face to an occurrence of the very same type
5399− :: variable. Binding that variable to a face around itself would fail
5400− :: the occurs check, but its underlying type has already matched.
5401− ?: &(?=(%var -.actual) ?=(%face -.expected) =(actual (itype-walk body.expected sub)))
5403− :: Differing variables and faces need propagation that is not yet
5404− :: represented. Binding one to the face can create a false mismatch.
5405− ?: &(?=(%var -.actual) ?=(%face -.expected)) [%unknown ~]
5406− ?: &(?=(%face -.actual) ?=(%var -.expected)) [%unknown ~]
5407 ?: &(?=(%var -.actual) (itype-has-any-atom expected sub))
5017 ?: &(?=(%var -.actual) (itype-has-any-atom expected sub))
5408 [%unknown ~]
5018 [%unknown ~]
5409 ?: |(?=(%var -.actual) ?=(%var -.expected))
5019 ?: |(?=(%var -.actual) ?=(%var -.expected))
5410 =/ unified=(unit isub) (itype-unify actual expected sub)
5020 =/ unified=(unit isub) (itype-unify actual expected sub)
5411 ?~ unified
5021 ?~ unified
5412− ?: |(?=(%face -.actual) ?=(%face -.expected)) [%unknown ~]
5413− ?: |((itype-has-recursive (itype-normalize actual sub)) (itype-has-recursive (itype-normalize expected sub))) [%unknown ~]
5414 ?: (itype-family-related actual expected sub) [%unknown ~]
5022 ?: (itype-family-related actual expected sub) [%unknown ~]
5415 [%bad ~]
5023 [%bad ~]
5416 [%ok u.unified next]
5024 [%ok u.unified next]
5417 ?: &(?=(%face -.actual) ?=(%face -.expected))
5025 ?: &(?=(%face -.actual) ?=(%face -.expected))
5418 ?. =(name.actual name.expected) [%bad ~]
5026 ?. =(name.actual name.expected) [%bad ~]
5419− $(actual body.actual, expected body.expected, skip-width |, spine-proof |)
5027+ $(actual body.actual, expected body.expected)
5420− ?: ?=(%face -.actual) $(actual body.actual, skip-width |, spine-proof |)
5028+ ?: ?=(%face -.actual) $(actual body.actual)
5421− ?: ?=(%face -.expected) $(expected body.expected, skip-width |, spine-proof |)
5029+ ?: ?=(%face -.expected) $(expected body.expected)
5422− ?: &(!uncertain (itype-closed-gates-match actual expected)) [%ok sub next]
5423 ?: (itype-face-asym actual expected sub) [%unknown ~]
5030 ?: (itype-face-asym actual expected sub) [%unknown ~]
5424 ?: |((itype-has-any-atom actual sub) (itype-has-any-atom expected sub))
5031 ?: |((itype-has-any-atom actual sub) (itype-has-any-atom expected sub))
5425 [%unknown ~]
5032 [%unknown ~]
5426 =/ unified=(unit isub) (itype-unify actual expected sub)
5033 =/ unified=(unit isub) (itype-unify actual expected sub)
5427 ?~ unified
5034 ?~ unified
5428− ?: |((itype-has-union (itype-normalize actual sub)) (itype-has-union (itype-normalize expected sub))) [%unknown ~]
5429− ?: |((itype-has-recursive (itype-normalize actual sub)) (itype-has-recursive (itype-normalize expected sub))) [%unknown ~]
5430 ?: (itype-family-related actual expected sub) [%unknown ~]
5035 ?: (itype-family-related actual expected sub) [%unknown ~]
5431 [%bad ~]
5036 [%bad ~]
5432 [%ok u.unified next]
5037 [%ok u.unified next]
@@ -5455,226 +5060,25 @@
5455 ["a shared type variable should reject incompatible arguments" problems]
5060 ["a shared type variable should reject incompatible arguments" problems]
5456 =? problems ?=(~ (itype-unify same fine ~))
5061 =? problems ?=(~ (itype-unify same fine ~))
5457 ["a shared type variable should accept equal arguments" problems]
5062 ["a shared type variable should accept equal arguments" problems]
5458− =/ list-a=itype [%collection %list ~[a]]
5459− =/ list-t=itype [%collection %list ~[txt]]
5460− =/ list-n=itype [%collection %list ~[num]]
5461− =? problems ?=(^ (itype-unify a list-a ~))
5462− ["occurs check should look through collection arguments" problems]
5463− =? problems !=((itype-vars list-a) ~[0])
5464− ["generalization should see collection argument variables" problems]
5465− =? problems !=((itype-rename list-a ~[[0 num]]) list-n)
5466− ["instantiation should rename collection argument variables" problems]
5467− =? problems ?=(^ (itype-unify list-t list-n ~))
5468− ["collection arguments with different auras should conflict" problems]
5469− =? problems ?=(^ (itype-unify list-t [%collection %unit ~[txt]] ~))
5470− ["different collection names should conflict" problems]
5471− =? problems !(itype-family-related list-t [%collection %list ~[[%atom 'tD']]] ~)
5472− ["collection arguments should preserve aura-family uncertainty" problems]
5473− =? problems !(itype-face-asym [%collection %list ~[[%face %x txt]]] list-t ~)
5474− ["collection arguments should preserve face uncertainty" problems]
5475− =/ recursive=itype [%recursive %fixture %chain `'chain.fixture']
5476− =/ same-recursive=itype [%recursive %fixture %chain ~]
5477− =/ other-recursive=itype [%recursive %other %chain `'chain.other']
5478− =? problems ?=(~ (itype-unify recursive same-recursive ~))
5479− ["recursive identity should not depend on its visible name" problems]
5480− =? problems ?=(^ (itype-unify recursive other-recursive ~))
5481− ["recursive identity should include the source module" problems]
5482− =/ recursive-fit=ifit (itype-fit recursive txt ~ 0)
5483− =? problems !?=(%unknown -.recursive-fit)
5484− ["opaque recursive types should not be unfolded by a fit" problems]
5486− (itype-fit [%collection %list ~[a]] list-t ~[[0 recursive]] 1)
5487− =? problems !?=(%unknown -.nested-fit)
5488− ["recursive types behind substitutions should remain uncertain" problems]
5489 problems
5063 problems
5491:: The expression inference below is deliberately a fragment: bindings,
5065:: The expression inference below is deliberately a fragment: bindings,
5492−:: simple gates, calls, fixed-aura literals, and some interpolated strings. The
5066+:: simple gates, unary calls, fixed-aura literals, and plain strings. The
5493:: result for unsupported syntax is a diagnostic, never a checked module.
5067:: result for unsupported syntax is a diagnostic, never a checked module.
5495+$ ischeme [typ=itype vars=(list @ud)]
5069+$ ischeme [typ=itype vars=(list @ud)]
5496+$ ienv (list [name=term scheme=ischeme])
5070+$ ienv (list [name=term scheme=ischeme])
5497+$ imold-types (list [name=term template=ischeme])
5071+$ imold-types (list [name=term template=ischeme])
5498−+$ iderived [name=term agent=term mark=term]
5072++$ ifile [values=ienv molds=imold-types]
5499−+$ iwidth-definition [name=term original=expr typ=itype sub=isub projections=(list iwprojection)]
5500−+$ iwidth-dependency [at=path source=(unit @t) definitions=(list iwidth-definition)]
5501−:: Nonrecursive request evidence is compiler-owned metadata, not a property
5502−:: of an arbitrary ask value. Reader graphs and source inputs are trusted.
5503−+$ irequest-evidence
5504− [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]
5505−:: A unit distinguishes a verified empty closure from a detached legacy file.
5506−:: The opaque prelude is an exact trusted input, not a recursive interface mold.
5508− [paths=(set path) requests=(list irequest-evidence) bundle-input=* prelude-input=* prelude-values=(list term) prelude-molds=(list term) externals=iexternals marks=imark-externals]
5509−+$ 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)]
5510+$ ijimports (list [face=term interface=ifile])
5073+$ ijimports (list [face=term interface=ifile])
5511−+$ icap [name=@t id=@ud at=span]
5074++$ icaps (list [name=@t id=@ud])
5512−+$ icaps (list icap)
5513+$ iparams (list [name=@t typ=itype])
5075+$ iparams (list [name=@t typ=itype])
5514+$ imolds (list [name=term body=shape])
5076+$ imolds (list [name=term body=shape])
5515:: A caller supplies the exact noun returned by +read-mold:jibb-import.
5077:: A caller supplies the exact noun returned by +read-mold:jibb-import.
5516:: This core has no Ford dependencies; unrecognized payloads fail closed.
5078:: This core has no Ford dependencies; unrecognized payloads fail closed.
5517+$ iexternals (list [module=term name=term result=*])
5079+$ iexternals (list [module=term name=term result=*])
5518+$ imark-externals (list [mark=term result=*])
5080+$ imark-externals (list [mark=term result=*])
5519−:: Hole obligations survive discarded expressions until their owning
5520−:: definition has inferred; their source spans support unresolved reports.
5521−+$ ihole [id=@ud at=span]
5522−:: Recursive-mold unfolding spends fuel in the threaded inference state.
5523−:: Retries can restart from an earlier state, so this bounds an attempt,
5524−:: not all parsing or module-checking work.
5525−:: Experimental: only closed, uniquely faced records have known axes.
5526−+$ iwfield [name=term axis=@ud typ=itype]
5527−+$ iwfields [order=(list iwfield) index=(map term iwfield)]
5528−+$ iwstep [name=term axis=@ud]
5529−+$ iwidth-result [steps=(list iwstep) sub=isub next=@ud]
5530−+$ iwprojection [at=span original=expr source=itype target=itype steps=(list iwstep)]
5532− |= [typ=itype sub=isub axis=@ud fuel=@ud]
5534− =/ order=(list iwfield) ~
5535− =/ index=(map term iwfield) *(map term iwfield)
5538− ?: |(?=(%var -.typ) ?=(%avar -.typ) ?=(%rvar -.typ) ?=(%nvar -.typ) ?=(%rnvar -.typ)) ~
5540− =/ entry=iwfield [name.typ axis body.typ]
5541− ?: ?=(^ (~(get by index) name.entry)) ~
5542− `[(flop [entry order]) (~(put by index) name.entry entry)]
5543− ?. ?=(%cell -.typ) ~
5544− =/ head=itype hed.typ
5545− ?: |(?=(%var -.head) ?=(%avar -.head) ?=(%rvar -.head) ?=(%nvar -.head) ?=(%rnvar -.head)) ~
5546− ?. ?=(%face -.head) ~
5547− =/ entry=iwfield [name.head (mul 2 axis) body.head]
5548− ?: ?=(^ (~(get by index) name.entry)) ~
5549− $(typ tal.typ, axis +((mul 2 axis)), fuel (dec fuel), order [entry order], index (~(put by index) name.entry entry))
5551− |= [source=(list iwfield) target=(list iwfield)]
5555− ?: =(name.i.source name.i.target) $(source t.source, target t.target)
5558− |= [source=(map term iwfield) target=(list iwfield) sub=isub next=@ud]
5559− ^- (unit iwidth-result)
5560− ?~ target `[~ sub next]
5561− =/ found=(unit iwfield) (~(get by source) name.i.target)
5563− =/ fit=ifit (itype-fit typ.u.found typ.i.target sub next)
5565− =/ rest=(unit iwidth-result) $(target t.target, sub sub.fit, next next.fit)
5567− `[[[name.i.target axis.u.found] steps.u.rest] sub.u.rest next.u.rest]
5568−++ width-spine-exhausted
5569− |= [t=itype fuel=@ud]
5573− ?. ?=(%face -.hed.t) |
5574− $(t tal.t, fuel (dec fuel))
5575−++ width-known-shape
5576− |= [actual=itype expected=itype sub=isub]
5577− ^- (unit [source=iwfields target=iwfields])
5578− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
5579− =/ source=(unit iwfields) (width-scan actual sub 1 1.024)
5580− =/ target=(unit iwfields) (width-scan expected sub 1 1.024)
5583− `[u.source u.target]
5586− |= [actual=itype expected=itype sub=isub]
5587− ^- (unit [source=iwfields target=iwfields])
5588− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
5589− =/ source=(unit iwfields) (width-scan actual sub 1 4.096)
5590− =/ target=(unit iwfields) (width-scan expected sub 1 4.096)
5593− ?. (gth (lent order.u.source) (lent order.u.target)) ~
5594− `[u.source u.target]
5596− |= [actual=itype expected=itype sub=isub]
5597− ^- (unit [source=iwfields target=iwfields])
5598− ?. &(|(?=(%cell -.actual) ?=(%face -.actual)) |(?=(%cell -.expected) ?=(%face -.expected))) ~
5599− =/ source=(unit iwfields) (width-scan actual sub 1 4.096)
5600− =/ target=(unit iwfields) (width-scan expected sub 1 4.096)
5603− ?: (lth (lent order.u.source) (lent order.u.target)) ~
5604− `[u.source u.target]
5607− |= [shape=[source=iwfields target=iwfields] sub=isub next=@ud]
5608− ^- (unit iwidth-result)
5609− ?. (width-in-order order.source.shape order.target.shape) ~
5610− (width-fit-fields index.source.shape order.target.shape sub next)
5612−:: Provisional, globally budgeted gate-free proof. %no includes a
5613−:: gate-bearing witness; an uninhabited sibling could invalidate it.
5614−:: Input types must be resolved and normalized under valid substitutions,
5615−:: from trusted source-backed interfaces and reader results. Collection
5616−:: list/unit names rely on their existing identity invariant; this arm
5617−:: does not validate fabricated internal types.
5619− $% [%field name=term]
5625−+$ igate-free [verdict=?(%yes %no %unknown) inhabited=? left=@ud path=(unit (list igf-segment))]
5627− |= [types=(list itype) fuel=@ud path=(list igf-segment) index=@ud]
5629− ?~ types [%yes | fuel ~]
5630− ?: =(0 fuel) [%unknown | 0 ~]
5631− =/ first=igate-free (gate-free-type i.types fuel [[%case index] path])
5632− ?: =(%no verdict.first) first
5633− =/ rest=igate-free $(types t.types, fuel left.first, index +(index))
5634− ?: =(%no verdict.rest) rest
5635− =/ inhabited=? |(inhabited.first inhabited.rest)
5636− ?: |(=(%unknown verdict.first) =(%unknown verdict.rest)) [%unknown inhabited left.rest ~]
5637− [%yes inhabited left.rest ~]
5639− |= [typ=itype fuel=@ud path=(list igf-segment)]
5641− ?: =(0 fuel) [%unknown | 0 ~]
5644− %fn [%no & fuel `(flop path)]
5645− %atom [%yes & fuel ~]
5646− %any-atom [%yes & fuel ~]
5647− %flag [%yes & fuel ~]
5648− %const [%yes & fuel ~]
5649− %face $(typ body.typ, path [[%field name.typ] path])
5651− =/ head=igate-free $(typ hed.typ, path [[%head ~] path])
5652− =/ tail=igate-free $(typ tal.typ, fuel left.head, path [[%tail ~] path])
5653− =/ inhabited=? &(inhabited.head inhabited.tail)
5654− ?: &(=(%no verdict.head) inhabited.tail) head(left left.tail)
5655− ?: &(=(%no verdict.tail) inhabited.head) tail
5656− ?: |(!=(%yes verdict.head) !=(%yes verdict.tail)) [%unknown inhabited left.tail ~]
5657− [%yes inhabited left.tail ~]
5659− ?. |(=(%list name.typ) =(%unit name.typ)) [%unknown | fuel ~]
5660− ?. ?=([* ~] args.typ) [%unknown | fuel ~]
5661− =/ item=igate-free $(typ i.args.typ, path [[%item ~] path])
5664− ?~ cases.typ [%unknown | fuel ~]
5665− (gate-free-types cases.typ fuel path 0)
5666− %noun [%unknown & fuel ~]
5667− %var [%unknown | fuel ~]
5668− %avar [%yes & fuel ~]
5669− %rvar [%yes & fuel ~]
5670− %nvar [%yes & fuel ~]
5671− %rnvar [%yes & fuel ~]
5672− %tag [%unknown | fuel ~]
5673− %recursive [%unknown | fuel ~]
5674− %jrec [%yes & fuel ~]
5677−+$ 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)]
5081++$ 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 @ud) in-mold=?]
5678+$ idiag [msg=tape sites=(list [at=span note=tape])]
5082+$ idiag [msg=tape sites=(list [at=span note=tape])]
5679+$ iresult (each [typ=itype state=istate] idiag)
5083+$ iresult (each [typ=itype state=istate] idiag)
5680+$ isample-result (each [typ=itype env=ienv state=istate] tape)
5084+$ isample-result (each [typ=itype env=ienv state=istate] tape)
@@ -5694,9 +5098,8 @@
5694 |= [t=itype sub=isub]
5098 |= [t=itype sub=isub]
5695 ^- itype
5099 ^- itype
5696 =. t (itype-walk t sub)
5100 =. t (itype-walk t sub)
5697− ?: ?=(%collection -.t) [%collection name.t (turn args.t |=(c=itype (itype-normalize c sub)))]
5698 ?: ?=(%union -.t)
5101 ?: ?=(%union -.t)
5699− [%union (turn cases.t |=(c=itype (itype-normalize c sub))) origin.t label.t (turn args.t |=(c=itype (itype-normalize c sub)))]
5102+ [%union (turn cases.t |=(c=itype (itype-normalize c sub)))]
5700 ?: ?=(%face -.t)
5103 ?: ?=(%face -.t)
5701 [%face name.t $(t body.t)]
5104 [%face name.t $(t body.t)]
5702 ?: ?=(%fn -.t)
5105 ?: ?=(%fn -.t)
@@ -5710,30 +5113,22 @@
5710:: generalize an aura from its sample, which requires constraint analysis
5113:: generalize an aura from its sample, which requires constraint analysis
5711:: beyond this fragment; leave those cases unresolved.
5114:: beyond this fragment; leave those cases unresolved.
5713−:: This helper only controls decimal defaulting in visible types. A noun
5714−:: may contain gates and is not proof of a gate-free value.
5715++ itype-has-gate
5116++ itype-has-gate
5716 |= t=itype
5117 |= t=itype
5720 %cell |($(t hed.t) $(t tal.t))
5121 %cell |($(t hed.t) $(t tal.t))
5723− %collection (lien args.t |=(c=itype (itype-has-gate c)))
5724 %face $(t body.t)
5122 %face $(t body.t)
5725 %union (lien cases.t |=(c=itype (itype-has-gate c)))
5123 %union (lien cases.t |=(c=itype (itype-has-gate c)))
5727 %const |
5125 %const |
5734 %any-atom |
5130 %any-atom |
5739++ default-decimals
5134++ default-decimals
@@ -5742,130 +5137,24 @@
5742 ?: (itype-has-gate t) t
5137 ?: (itype-has-gate t) t
5744 %nvar [%atom %ud]
5139 %nvar [%atom %ud]
5746− %collection [%collection name.t (turn args.t |=(c=itype (default-decimals c)))]
5747 %face [%face name.t $(t body.t)]
5140 %face [%face name.t $(t body.t)]
5748 %cell [%cell $(t hed.t) $(t tal.t)]
5141 %cell [%cell $(t hed.t) $(t tal.t)]
5752−:: A hole is solved only by a fully determined type or a written
5753−:: in-scope type variable. Ordinary fresh variables are not evidence.
5754−:: Compare representatives after substitution, since unification can
5755−:: orient a written capital toward the hole rather than the reverse.
5768−++ hole-same-variable
5769− |= [a=itype b=itype]
5771− =/ x=(unit @ud) (hole-variable-id a)
5773− =/ y=(unit @ud) (hole-variable-id b)
5777− |= [t=itype state=istate]
5779− =. t (itype-walk t sub.state)
5781− ?(%var %avar %rvar %nvar %rnvar)
5782− ?: (lien caps.state |=(c=icap (hole-same-variable t (itype-walk [%var id.c] sub.state)))) &
5783− (lien params.state |=(p=[name=@t typ=itype] (hole-same-variable t (itype-walk typ.p sub.state))))
5786− %union &((levy cases.t |=(c=itype (hole-known c state))) (levy args.t |=(c=itype (hole-known c state))))
5787− %collection (levy args.t |=(c=itype (hole-known c state)))
5789− %fn &($(t sample.t) $(t product.t))
5790− %cell &($(t hed.t) $(t tal.t))
5793−++ promote-restricted-numbers
5794− |= [state=istate env=ienv]
5796− =/ ids=(list @ud) (turn caps.state |=(c=icap id.c))
5797− =/ free=(list @ud) (free-env-vars env sub.state)
5800− =/ t=itype (itype-walk [%var i.ids] sub.state)
5801− ?: &(?=(%rnvar -.t) !(lien free |=(n=@ud =(n +.t))))
5802− $(ids t.ids, state state(sub [[+.t [%rvar +.t]] sub.state]))
5805−++ default-hole-numbers
5806− |= [all=(list ihole) prior=(list ihole) state=istate env=ienv permit=?]
5808− :: Do not default a named capital or a variable captured from env.
5810− ?: =(all prior) state
5812− =/ t=itype (itype-walk [%var id.i.all] sub.state)
5813− =/ free=(list @ud) (free-env-vars env sub.state)
5814− =? state &(?=(?(%nvar %rnvar) -.t) !(hole-known t state) !(lien free |=(id=@ud =(id id.t))))
5815− state(sub [[id.t [%atom %ud]] sub.state])
5818−:: Only obligations created inside this definition belong to it.
5820− |= [all=(list ihole) prior=(list ihole)]
5824− [i.all $(all t.all)]
5826− |= [t=itype state=istate]
5828− =. t (itype-walk t sub.state)
5830− ?(%tag %nvar %rnvar %avar %rvar) !(hole-known t state)
5831− %union |((lien cases.t |=(c=itype (hole-uncertain c state))) (lien args.t |=(c=itype (hole-uncertain c state))))
5832− %collection (lien args.t |=(c=itype (hole-uncertain c state)))
5834− %fn |($(t sample.t) $(t product.t))
5835− %cell |($(t hed.t) $(t tal.t))
5840− |= [all=(list ihole) prior=(list ihole) state=istate]
5842− =/ work=(list ihole) (flop (holes-created all prior))
5845− ?: (hole-known [%var id.i.work] state) $(work t.work)
5846− ?: (hole-uncertain [%var id.i.work] state)
5847− `["type hole needs unsupported inference" ~[[at.i.work "type hole"]]]
5848− `["type hole needs a determined type" ~[[at.i.work "unresolved type hole"]]]
5850++ itype-vars
5145++ itype-vars
5851 |= t=itype
5146 |= t=itype
5852 ^- (list @ud)
5147 ^- (list @ud)
5854 %var ~[id.t]
5149 %var ~[id.t]
5855 %avar ~[id.t]
5150 %avar ~[id.t]
5857 %nvar ~[id.t]
5151 %nvar ~[id.t]
5860 %any-atom ~
5153 %any-atom ~
5864 %const ~
5156 %const ~
5865− %union (zing (turn (weld args.t cases.t) |=(c=itype (itype-vars c))))
5157+ %union (zing (turn cases.t |=(c=itype (itype-vars c))))
5868− %collection (zing (turn args.t |=(c=itype (itype-vars c))))
5869 %face $(t body.t)
5158 %face $(t body.t)
5870 %fn (weld $(t sample.t) $(t product.t))
5159 %fn (weld $(t sample.t) $(t product.t))
5871 %cell (weld $(t hed.t) $(t tal.t))
5160 %cell (weld $(t hed.t) $(t tal.t))
@@ -5892,28 +5181,16 @@
5892 =/ found=(unit itype) (itype-lookup id.t ren)
5181 =/ found=(unit itype) (itype-lookup id.t ren)
5893 ?~ found t
5182 ?~ found t
5896− =/ found=(unit itype) (itype-lookup id.t ren)
5900 =/ found=(unit itype) (itype-lookup id.t ren)
5185 =/ found=(unit itype) (itype-lookup id.t ren)
5901 ?~ found t
5186 ?~ found t
5904− =/ found=(unit itype) (itype-lookup id.t ren)
5908 %any-atom t
5189 %any-atom t
5912 %const t
5192 %const t
5913− %union [%union (turn cases.t |=(c=itype (itype-rename c ren))) origin.t label.t (turn args.t |=(c=itype (itype-rename c ren)))]
5193+ %union [%union (turn cases.t |=(c=itype (itype-rename c ren)))]
5916− %collection [%collection name.t (turn args.t |=(c=itype (itype-rename c ren)))]
5917 %face [%face name.t $(t body.t)]
5194 %face [%face name.t $(t body.t)]
5918 %fn [%fn $(t sample.t) $(t product.t)]
5195 %fn [%fn $(t sample.t) $(t product.t)]
5919 %cell [%cell $(t hed.t) $(t tal.t)]
5196 %cell [%cell $(t hed.t) $(t tal.t)]
@@ -5928,42 +5205,13 @@
5930 %avar =(n id.t)
5207 %avar =(n id.t)
5932 %nvar =(n id.t)
5208 %nvar =(n id.t)
5940− %union |((lien cases.t |=(c=itype (itype-var-is-atom n c))) (lien args.t |=(c=itype (itype-var-is-atom n c))))
5943− %collection (lien args.t |=(c=itype (itype-var-is-atom n c)))
5945− %fn |($(t sample.t) $(t product.t))
5946− %cell |($(t hed.t) $(t tal.t))
5948−++ itype-var-is-restricted
5958 %any-atom |
5210 %any-atom |
5962 %const |
5213 %const |
5963− %union |((lien cases.t |=(c=itype (itype-var-is-restricted n c))) (lien args.t |=(c=itype (itype-var-is-restricted n c))))
5214+ %union (lien cases.t |=(c=itype (itype-var-is-atom n c)))
5966− %collection (lien args.t |=(c=itype (itype-var-is-restricted n c)))
5967 %face $(t body.t)
5215 %face $(t body.t)
5968 %fn |($(t sample.t) $(t product.t))
5216 %fn |($(t sample.t) $(t product.t))
5969 %cell |($(t hed.t) $(t tal.t))
5217 %cell |($(t hed.t) $(t tal.t))
@@ -5979,7 +5227,7 @@
5979 =/ n=@ud 0
5227 =/ n=@ud 0
5981 ?~ vars (itype-rename t ren)
5229 ?~ vars (itype-rename t ren)
5982− =/ replacement=itype ?:((itype-var-is-restricted i.vars t) [%rvar n] ?:((itype-var-is-atom i.vars t) [%avar n] [%var n]))
5230+ =/ replacement=itype ?:((itype-var-is-atom i.vars t) [%avar n] [%var n])
5983 $(vars t.vars, ren [[i.vars replacement] ren], n +(n))
5231 $(vars t.vars, ren [[i.vars replacement] ren], n +(n))
5985++ instantiate-scheme
5233++ instantiate-scheme
@@ -5990,11 +5238,11 @@
5991 ?~ vars [(itype-rename typ.scheme ren) state]
5239 ?~ vars [(itype-rename typ.scheme ren) state]
5992 =/ replacement=itype
5240 =/ replacement=itype
5993− ?:((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]))
5241+ ?:((itype-var-is-atom i.vars typ.scheme) [%avar next.state] [%var next.state])
5994 :: A generalized atom variable is a valid origin for re-generalizing
5242 :: A generalized atom variable is a valid origin for re-generalizing
5995 :: an alias, just as a sample binder is.
5243 :: an alias, just as a sample binder is.
5996 =/ st=istate state(next +(next.state))
5244 =/ st=istate state(next +(next.state))
5997− =? binders.st |(?=(%avar -.replacement) ?=(%rvar -.replacement)) [next.state binders.state]
5245+ =? binders.st ?=(%avar -.replacement) [next.state binders.state]
5998 $(vars t.vars, ren [[i.vars replacement] ren], state st)
5246 $(vars t.vars, ren [[i.vars replacement] ren], state st)
6000++ icap-lookup
5248++ icap-lookup
@@ -6025,12 +5273,9 @@
6025 $(ds t.ds)
5273 $(ds t.ds)
6028−:: The caller supplies unchanged results from the source-aware importer.
5276+:: The importer owns its algebra. Fixed atoms, cells and Jibb-named faces
6029−:: That boundary is trusted for source provenance: a fork alone cannot
5277+:: are decoded recursively. Singletons, unions, collections, recursive
6030−:: reveal cases Hoon collapsed before it was constructed. Validate the
5278+:: references and invalid face names remain unsupported, never widened.
6031−:: supplied graph independently, including pairwise disjointness. Fixed
6032−:: atoms, term singletons, cells, faces and proven forks are decoded;
6033−:: unsupported singletons, collections and recursive references fail.
6035++ jibb-face-name
5280++ jibb-face-name
6036 |= name=@
5281 |= name=@
@@ -6040,180 +5285,16 @@
6040 ?. (is-lower i.chars) |
5285 ?. (is-lower i.chars) |
6041 (levy t.chars |=(c=@tD (in c name-mask)))
5286 (levy t.chars |=(c=@tD (in c name-mask)))
6043−:: A source-aware reader result is trusted for origin. Validate every
6044−:: supplied branch and keep the recursive mold opaque: unfolding its
6045−:: root while naming only its tail would change its type identity.
6046−+$ irec-pattern [pat=upat has=?]
6048− |= [node=* module=term name=term]
6049− ^- (unit irec-pattern)
6053− ?: ?=([%atom %n [~ @]] node)
6056− ?: ?=([%atom %tas [~ @]] node)
6057− =/ value=@ +>+.node
6058− ?. |(=(value 0) (jibb-face-name value)) ~
6059− `[[%atom `value] |]
6060− ?. ?=([%atom @ ~] node) ~
6061− =/ aura=@ta (@ta +<.node)
6062− ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
6065− ?. ?=([%ref @ @] node) ~
6066− ?. &(=(module +<.node) =(name +>.node)) ~
6069− ?. ?=([%apply %list [* ~]] node) ~
6070− =/ item $(node -.+>.node)
6072− `[[%or ~[[%atom `0] [%cell pat.u.item [%unknown ~]]]] has.u.item]
6074− ?. ?=([%face @ *] node) ~
6075− ?. (jibb-face-name +<.node) ~
6078− ?. ?=([%cell * *] node) ~
6079− =/ left $(node +<.node)
6081− =/ right $(node +>.node)
6083− `[[%cell pat.u.left pat.u.right] |(has.u.left has.u.right)]
6085− =/ cases (rec-patterns +.node module name)
6088− ?~ t.pats.u.cases ~
6089− ?. (rec-patterns-disjoint pats.u.cases) ~
6090− `[[%or pats.u.cases] has.u.cases]
6094− |= [nodes=* module=term name=term]
6095− ^- (unit [pats=(list upat) has=?])
6096− ?@ nodes ?:(=(nodes 0) `[~ |] ~)
6097− =/ first (rec-pattern -.nodes module name)
6099− =/ rest $(nodes +.nodes)
6101− `[[pat.u.first pats.u.rest] |(has.u.first has.u.rest)]
6103−++ rec-patterns-disjoint
6104− |= pats=(list upat)
6107− ?. (levy t.pats |=(p=upat =(%disjoint (union-relate i.pats p)))) |
6112−:: Repeated faces along an imported record spine fail closed. Hoon's type
6113−:: graph can erase unfaced nested-cell boundaries, so that alone does not
6114−:: prove the original source repeated a name within one record. A faced
6115−:: body and each union alternative have separate scopes. Check recursive
6116−:: roots before making them opaque; unused molds are never inspected.
6118−++ imported-faces-valid
6123− %face ?:(?=([%face @ *] node) $(node +>.node) |)
6124− %cell ?:(?=([%cell * *] node) (imported-record-faces-valid node ~) |)
6125− %fork (imported-faces-valid-list +.node)
6126− %apply ?:(?=([%apply @ *] node) (imported-faces-valid-list +>.node) |)
6128− ?. ?=([%named @ @ *] node) |
6129− =/ n=[%named module=@ name=@ body=*] ;;([%named module=@ name=@ body=*] node)
6130− (imported-faces-valid body.n)
6133−++ imported-faces-valid-list
6136− ?@ nodes =(nodes 0)
6137− ?. (imported-faces-valid -.nodes) |
6140−++ imported-record-faces-valid
6141− |= [node=* names=(list @)]
6143− ?: ?=([%cell * *] node)
6146− ?: ?=([%face @ *] head)
6147− ?: (lien names |=(n=@ =(n +<.head))) |
6148− ?. (imported-faces-valid +>.head) |
6149− $(node rest, names [+<.head names])
6150− ?. (imported-faces-valid head) |
6152− ?: ?=([%face @ *] node)
6153− ?: (lien names |=(n=@ =(n +<.node))) |
6154− (imported-faces-valid +>.node)
6155− (imported-faces-valid node)
6157++ import-to-itype
5288++ import-to-itype
6158 |= node=*
5289 |= node=*
6159 ^- (unit itype)
5290 ^- (unit itype)
6160 ?@ node ~
5291 ?@ node ~
6161 ?+ -.node ~
5292 ?+ -.node ~
6162− %noun ?:(=(node [%noun ~]) `[%noun ~] ~)
6164− :: A Hoon loobean singleton is one of the two Jibb loobeans.
6165− ?: ?=([%atom %f [~ @]] node)
6166− =/ value=@ +>+.node
6167− ?. |(=(value 0) =(value 1)) ~
6168− =/ printed=@t ?:(=(value 0) '%.y' '%.n')
6169− `[%const [%loobean %f value printed]]
6170− :: Hoon's null singleton is the same noun as Jibb's `~` mold.
6171− :: Other non-term singleton atoms remain unsupported here.
6172− ?: ?=([%atom %n [~ @]] node)
6174− `[%const [%null %n 0 '~']]
6175− ?: ?=([%atom %tas [~ @]] node)
6176− =/ value=@ +>+.node
6177− ?. |(=(value 0) (jibb-face-name value)) ~
6178− =/ printed=@t ?:(=(value 0) '%$' (cat 3 '%' value))
6179− `[%const [%term %tas value printed]]
6180 ?. ?=([%atom @ ~] node) ~
5294 ?. ?=([%atom @ ~] node) ~
6181 =/ aura=@ta (@ta +<.node)
5295 =/ aura=@ta (@ta +<.node)
6182 ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
5296 ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
6183 `[%atom aura]
5297 `[%atom aura]
6185− ?. ?=([%named @ @ *] node) ~
6186− =/ n=[%named module=@ name=@ body=*] ;;([%named module=@ name=@ body=*] node)
6187− ?. &((jibb-face-name module.n) (jibb-face-name name.n)) ~
6188− ?. ?=([%fork *] body.n) ~
6189− =/ proof=(unit irec-pattern) (rec-pattern body.n (@tas module.n) (@tas name.n))
6192− `[%recursive (@tas module.n) (@tas name.n) `(crip "{(trip name.n)}.{(trip module.n)}")]
6194− ?. ?=([%apply @ *] node) ~
6195− =/ name=term (@tas +<.node)
6197− ?: |(=(%list name) =(%unit name) =(%set name) =(%qeu name)) 1
6198− ?: |(=(%map name) =(%mop name) =(%jar name) =(%jug name)) 2
6201− =/ args=(unit (list itype)) (import-to-itypes +>.node)
6203− ?. =(arity (lent u.args)) ~
6204− `[%collection name u.args]
6206− :: Hoon's ordinary ? mold is the fork of its two %f singletons.
6208− ?: |(=(raw ~[[%atom %f `0] [%atom %f `1]]) =(raw ~[[%atom %f `1] [%atom %f `0]]))
6210− =/ cases=(unit (list itype)) (import-to-itypes raw)
6214− ?: (import-has-loobean-singleton u.cases) ~
6215− ?. (import-cases-disjoint u.cases) ~
6216− `[%union u.cases ~ ~ ~]
6218 ?. ?=([%face @ *] node) ~
5299 ?. ?=([%face @ *] node) ~
6219 =/ name=@ +<.node
5300 =/ name=@ +<.node
@@ -6230,52 +5311,6 @@
6230 `[%cell u.left u.right]
5311 `[%cell u.left u.right]
6233−++ import-direct-loobean
6236− ?: ?=(%face -.t) $(t body.t)
6237− ?: ?=(%union -.t) (import-has-loobean-singleton cases.t)
6238− ?=([%const [%loobean *]] t)
6240−++ import-has-loobean-singleton
6241− |= cases=(list itype)
6244− ?: (import-direct-loobean i.cases) &
6249− ^- (unit (list itype))
6250− ?@ nodes ?:(=(nodes 0) `~ ~)
6251− =/ first (import-to-itype -.nodes)
6253− =/ rest $(nodes +.nodes)
6257−++ import-type-pattern
6263− %flag [%or ~[[%atom `0] [%atom `1]]]
6264− %const [%atom `val.literal.typ]
6265− %face $(typ body.typ)
6266− %cell [%cell $(typ hed.typ) $(typ tal.typ)]
6267− %union [%or (turn cases.typ |=(t=itype (import-type-pattern t)))]
6271−++ import-cases-disjoint
6272− |= cases=(list itype)
6275− =/ first=upat (import-type-pattern i.cases)
6276− ?. (levy t.cases |=(t=itype =(%disjoint (union-relate first (import-type-pattern t))))) |
6279++ find-imported-mold
5314++ find-imported-mold
6280 |= [module=term name=term externals=iexternals surs=(list term)]
5315 |= [module=term name=term externals=iexternals surs=(list term)]
6281 ^- (unit itype)
5316 ^- (unit itype)
@@ -6287,15 +5322,7 @@
6287 =/ result=* result.i.found
5322 =/ result=* result.i.found
6288 ?@ result ~
5323 ?@ result ~
6289 ?. ?=(%& -.result) ~
5324 ?. ?=(%& -.result) ~
6290− =/ node=* +.result
5325+ (import-to-itype +.result)
6291− ?. (imported-faces-valid node) ~
6292− ?@ node (import-to-itype node)
6293− ?: ?=(%ref -.node) (import-to-itype node)
6294− =/ pattern=(unit irec-pattern) (rec-pattern node module name)
6295− ?~ pattern (import-to-itype node)
6296− ?. has.u.pattern (import-to-itype node)
6297− `[%recursive module name `(crip "{(trip name)}.{(trip module)}")]
6300++ collect-sur-imports
5327++ collect-sur-imports
6301 |= imports=(list import)
5328 |= imports=(list import)
@@ -6324,7 +5351,6 @@
6324 =/ result=* result.i.found
5351 =/ result=* result.i.found
6325 ?@ result ~
5352 ?@ result ~
6326 ?. ?=(%& -.result) ~
5353 ?. ?=(%& -.result) ~
6327− ?. (imported-faces-valid +.result) ~
6328 (import-to-itype +.result)
5354 (import-to-itype +.result)
6330++ find-jibb-interface
5356++ find-jibb-interface
@@ -6343,103 +5369,9 @@
6343 ?: =(name name.i.ms) `template.i.ms
5369 ?: =(name name.i.ms) `template.i.ms
6344 $(ms t.ms)
5370 $(ms t.ms)
6346−:: An exported alias may name a union from another module. Only a
6347−:: nongeneric alias of the same origin is usable through this import face.
6349−++ imported-union-alias
6350− |= [origin=[at=path name=term] molds=imold-types]
6353− =/ template=ischeme template.i.molds
6354− ?: &(?=(~ vars.template) ?=(%union -.typ.template))
6355− ?:(=(`origin origin.typ.template) `name.i.molds $(molds t.molds))
6358−:: A prelude union alias is a display name, not a new union identity. An
6359−:: identity-generic alias can carry the origin's arguments only when the
6360−:: origin, arity and ordered parameters match. Swapped, repeated, fixed
6361−:: or phantom parameters cannot be printed that way and remain unsupported
6362−:: when their only available name is private. A nongeneric alias of a
6363−:: generic instantiation cannot be printed with the origin's arguments.
6364−++ identity-union-parameters
6365− |= [vars=(list @ud) args=(list itype)]
6369− ?. =([%var i.vars] i.args) |
6370− $(vars t.vars, args t.args)
6371−++ prelude-union-alias
6372− |= [origin=[at=path name=term] args=(list itype) molds=imold-types]
6375− =/ template=ischeme template.i.molds
6376− ?. ?=(%union -.typ.template) $(molds t.molds)
6377− ?. =(`origin origin.typ.template) $(molds t.molds)
6379− ?^ args $(molds t.molds)
6380− ?:(=(args args.typ.template) `name.i.molds $(molds t.molds))
6381− ?: &((identity-union-parameters vars.template args.typ.template) =((lent vars.template) (lent args)))
6385−:: Names exported by the directly imported module are visible through its
6386−:: face; a matching prelude alias is also visible without a qualifier.
6389− |= [origin=path name=term molds=imold-types]
6392− =/ template=ischeme template.i.molds
6393− ?: &(?=(~ vars.template) ?=(%jrec -.typ.template) =(at.typ.template origin) =(name.typ.template name)) `name.i.molds
6397− |= [t=itype iface=ifile face=term prelude=(unit ifile)]
6403− ?: =(at.u.origin.t /lib/jibb/prelude/jibb) `name.u.origin.t
6404− =/ public=(unit term)
6406− (prelude-union-alias u.origin.t args.t molds.u.prelude)
6407− ?^ public `u.public
6408− =/ alias=(unit term) ~
6409− =? alias &(=(at.u.origin.t at.iface) ?=(^ (find-jibb-mold name.u.origin.t iface))) `name.u.origin.t
6410− =? alias ?=(~ alias) (imported-union-alias u.origin.t molds.iface)
6412− `(crip "{(trip u.alias)}.{(trip face)}")
6413− [%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)))]
6414− %recursive [%recursive module.t name.t ~]
6416− =/ public=(unit term) ?~(prelude ~ (jrec-alias at.t name.t molds.u.prelude))
6417− ?^ public t(label `u.public)
6418− =/ alias=(unit term) (jrec-alias at.t name.t molds.iface)
6419− ?~ alias t(label ~)
6420− t(label `(crip "{(trip u.alias)}.{(trip face)}"))
6421− %collection [%collection name.t (turn args.t |=(c=itype (itype-in-import c iface face prelude)))]
6422− %face [%face name.t $(t body.t)]
6423− %fn [%fn $(t sample.t) $(t product.t)]
6424− %cell [%cell $(t hed.t) $(t tal.t)]
6428−++ label-direct-union
6429− |= [typ=itype body=shape name=term state=istate]
6431− ?. ?=(%union -.typ) typ
6432− =/ direct=? ?=(%union -.body)
6433− =? direct ?=(%generic -.body) ?=(%union -.body.body)
6435− ?. (lien top-molds.state |=(n=term =(n name))) typ
6436− [%union cases.typ `[at.state name] `name args.typ]
6438:: Generic mold parameters are lexical and distinct from the enclosing
5372:: Generic mold parameters are lexical and distinct from the enclosing
6439:: value's capital variables. Arguments are substituted only once, so
5373:: value's capital variables. Arguments are substituted only once, so
6440:: an argument's variable ID cannot be captured by a template ID.
5374:: an argument's variable ID cannot be captured by a template ID.
6441−:: A generic alias of a named union keeps the underlying union's origin
6442−:: and substituted argument order; an originless union stays unsupported.
6444++ iparam-lookup
5376++ iparam-lookup
6445 |= [name=@t params=iparams]
5377 |= [name=@t params=iparams]
@@ -6491,46 +5423,9 @@
6491 =/ rest=[params=iparams vars=(list @ud) next=@ud] $(names t.names, next +(next))
5423 =/ rest=[params=iparams vars=(list @ud) next=@ud] $(names t.names, next +(next))
6492 [[[i.names [%var next]] params.rest] [next vars.rest] next.rest]
5424 [[[i.names [%var next]] params.rest] [next vars.rest] next.rest]
6494−:: Recognize a unique top-level source mold with exactly a null case and a
6495−:: faced atom-headed cell whose faced tail names that same mold. Its Jibb
6496−:: path and name provide nominal identity. Other recursive shapes fail closed;
6497−:: construction and matching expose the proven shape one layer at a time.
6498−++ simple-source-recursive
6499− |= [name=term sh=shape state=istate]
6501− ?. (lien top-molds.state |=(n=term =(n name))) ~
6502− =/ original=(unit shape) (find-simple-mold name molds.state)
6504− ?. =(u.original sh) ~
6505− ?. ?=(%union -.sh) ~
6506− =/ cs=(list shape) cases.sh
6510− ?. ?=(%const -.i.cs) ~
6511− ?. =(%null form.lit.i.cs) ~
6512− ?. ?=(%cell -.i.t.cs) ~
6513− =/ fs=(list field) fields.i.t.cs
6517− ?. ?=(%face -.i.fs) ~
6518− ?. ?=(%aura -.shape.i.fs) ~
6519− ?. !=(0 aura.shape.i.fs) ~
6520− ?. ?=(%face -.i.t.fs) ~
6521− ?. !=(name.i.fs name.i.t.fs) ~
6522− =/ tail=shape shape.i.t.fs
6523− ?. ?=(%ref -.tail) ~
6524− ?. =(names.tail ~[name]) ~
6525− `[%jrec at.state name `name name.i.fs aura.shape.i.fs name.i.t.fs]
6527++ infer-mold-template
5426++ infer-mold-template
6528 |= [sh=shape state=istate]
5427 |= [sh=shape state=istate]
6529 ^- (unit [template=ischeme state=istate])
5428 ^- (unit [template=ischeme state=istate])
6530− =/ direct=(unit itype)
6531− ?. ?=([@ ~] active.state) ~
6532− (simple-source-recursive i.active.state sh state)
6533− ?^ direct `[[u.direct ~] state]
6534 ?: ?=(%generic -.sh)
5429 ?: ?=(%generic -.sh)
6535 ?~ vars.sh ~
5430 ?~ vars.sh ~
6536 ?. (distinct-params vars.sh) ~
5431 ?. (distinct-params vars.sh) ~
@@ -6538,137 +5433,33 @@
6538 =/ out=(unit [typ=itype state=istate])
5433 =/ out=(unit [typ=itype state=istate])
6539 (infer-simple-shape body.sh state(next next.fresh, params params.fresh, in-mold &))
5434 (infer-simple-shape body.sh state(next next.fresh, params params.fresh, in-mold &))
6540 ?~ out ~
5435 ?~ out ~
6541− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
6542− ?: &(?=(%union -.typ.u.out) !?=(%union -.body.sh) ?=(~ origin.typ.u.out)) ~
6543− =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.sh))
6544− typ.u.out(args (turn vars.fresh |=(n=@ud `itype`[%var n])))
6545 =/ used=(list @ud) (itype-vars typ.u.out)
5436 =/ used=(list @ud) (itype-vars typ.u.out)
6546 ?. (levy used |=(n=@ud (lien vars.fresh |=(p=@ud =(p n))))) ~
5437 ?. (levy used |=(n=@ud (lien vars.fresh |=(p=@ud =(p n))))) ~
6547− `[[typ.u.out vars.fresh] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
5438+ `[[typ.u.out vars.fresh] state.u.out(params params.state, in-mold in-mold.state)]
6548 =/ out=(unit [typ=itype state=istate])
5439 =/ out=(unit [typ=itype state=istate])
6549 (infer-simple-shape sh state(params ~, in-mold &))
5440 (infer-simple-shape sh state(params ~, in-mold &))
6550 ?~ out ~
5441 ?~ out ~
6551− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
6552 ?: ?=(^ (itype-vars typ.u.out)) ~
5442 ?: ?=(^ (itype-vars typ.u.out)) ~
6553− `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state, holes holes.state)]
5443+ `[[typ.u.out ~] state.u.out(params params.state, in-mold in-mold.state)]
6555−:: A direct imported reference may carry definite reader evidence. Only
6556−:: uniquely supplied, declared inputs are used; unsupported data stay generic.
6557−++ direct-import-invalid
6558− |= [sh=shape state=istate]
6562− =/ n=term i.names.sh
6565− ?. (unique-value-name n marks.state) ~
6566− ?: (lien surs.state |=(x=term =(x n))) ~
6567− ?: ?=(^ (find-jibb-interface n jimports.state)) ~
6568− ?: (lien globals.state |=(x=term =(x n))) ~
6569− ?: (lien reserved-molds.state |=(x=term =(x n))) ~
6570− ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) ~
6571− =/ found=imark-externals (skim mark-externals.state |=(e=[mark=term result=*] =(mark.e n)))
6576− =/ mod=term i.t.names.sh
6577− ?: ?=(^ (find-jibb-interface mod jimports.state)) ~
6578− ?. (unique-value-name mod surs.state) ~
6579− ?: (lien marks.state |=(x=term =(x mod))) ~
6580− ?: (lien globals.state |=(x=term =(x mod))) ~
6581− ?: (lien reserved-molds.state |=(x=term =(x mod))) ~
6582− ?: (lien molds.state |=(m=[name=term body=shape] =(mod name.m))) ~
6583− =/ found=iexternals (skim externals.state |=(e=[module=term name=term result=*] &(=(module.e mod) =(name.e n))))
6587− ?. ?=([%invalid ?(%aura %core) @] raw) ~
6588− `["{(trip +>.raw)}" ~[[at.sh "invalid imported mold"]]]
6590−:: Replay only the shape branches whose evaluation order we can prove.
6591−:: Successful prefixes must be checked before descending to a failure.
6592−++ nested-import-invalid
6593− |= [sh=shape state=istate]
6595− ?: ?=(^ (infer-simple-shape sh state)) ~
6598− =/ direct=(unit idiag) (direct-import-invalid sh state)
6602− =/ n=term i.names.sh
6603− ?: (lien marks.state |=(x=term =(x n))) ~
6604− ?: (lien active.state |=(x=term =(x n))) ~
6605− =/ found=(unit shape) (find-simple-mold n molds.state)
6607− $(sh u.found, state state(active [n active.state], in-mold &, params ~))
6609− =/ first=(unit [typ=itype state=istate]) (infer-simple-shape sample.sh state)
6610− ?~ first $(sh sample.sh)
6611− $(sh product.sh, state state.u.first)
6612− %cell (nested-field-invalid fields.sh state)
6616−++ nested-field-invalid
6617− |= [fields=(list field) state=istate]
6622− %bare shape.i.fields
6623− %face shape.i.fields
6624− %pun [%ref at.i.fields ~[name.i.fields]]
6626− =/ out=(unit [typ=itype state=istate]) (infer-simple-shape sh state)
6627− ?~ out (nested-import-invalid sh state)
6628− $(fields t.fields, state state.u.out)
6630−++ sample-import-invalid
6631− |= [s=sample env=ienv state=istate]
6633− =/ result=isample-result (infer-sample s env state)
6634− ?: ?=(%& -.result) ~
6635− ?. =(p.result "sample mold is not supported by partial inference") ~
6637− [%face *] (nested-import-invalid shape.s state)
6638− [%bare *] (nested-import-invalid shape.s state)
6639− [%pun *] (nested-import-invalid [%ref at.s ~[name.s]] state)
6640− [%cell *] (nested-samples-invalid items.s env state)
6644−++ nested-samples-invalid
6645− |= [items=(list sample) env=ienv state=istate]
6648− =/ head=isample-result (infer-sample i.items env state)
6649− ?: ?=(%| -.head) (sample-import-invalid i.items env state)
6650− $(items t.items, env env.p.head, state state.p.head)
6652++ infer-simple-shape
5445++ infer-simple-shape
6653 |= [sh=shape state=istate]
5446 |= [sh=shape state=istate]
6654 ^- (unit [typ=itype state=istate])
5447 ^- (unit [typ=itype state=istate])
6656− %hole `[[%var next.state] state(next +(next.state), holes [[next.state at.sh] holes.state])]
6658 ?: =(0 aura.sh) `[[%any-atom ~] state]
5450 ?: =(0 aura.sh) `[[%any-atom ~] state]
6659 `[[%atom aura.sh] state]
5451 `[[%atom aura.sh] state]
6660 %flag `[[%flag ~] state]
5452 %flag `[[%flag ~] state]
6661− %noun `[[%noun ~] state]
6663− ?. |(=(%term form.lit.sh) =(%null form.lit.sh) =(%loobean form.lit.sh)) ~
5454+ ?. =(%term form.lit.sh) ~
6664− ?: &(=(%loobean form.lit.sh) !|(=(0 val.lit.sh) =(1 val.lit.sh))) ~
6665 `[[%const lit.sh] state]
5455 `[[%const lit.sh] state]
6667 =/ pairs=(list upair) (union-pairs cases.sh molds.state)
5457 =/ pairs=(list upair) (union-pairs cases.sh molds.state)
6668 ?. (levy pairs |=(p=upair =(%disjoint relation.p))) ~
5458 ?. (levy pairs |=(p=upair =(%disjoint relation.p))) ~
6669 =/ cs=(unit [types=(list itype) state=istate]) (infer-shape-args cases.sh state)
5459 =/ cs=(unit [types=(list itype) state=istate]) (infer-shape-args cases.sh state)
5461+ ?: (lien types.u.cs |=(t=itype ?=(^ (itype-vars t)))) ~
6671− `[[%union types.u.cs ~ ~ ~] state.u.cs]
5462+ `[[%union types.u.cs] state.u.cs]
6672 %cell (infer-simple-fields fields.sh state)
5463 %cell (infer-simple-fields fields.sh state)
6674 =/ arg=(unit [typ=itype state=istate]) $(sh sample.sh)
5465 =/ arg=(unit [typ=itype state=istate]) $(sh sample.sh)
@@ -6686,7 +5477,7 @@
6686 =/ found=(unit ischeme) (find-jibb-mold n u.iface)
5477 =/ found=(unit ischeme) (find-jibb-mold n u.iface)
6687 ?~ found ~
5478 ?~ found ~
6688 ?^ vars.u.found ~
5479 ?^ vars.u.found ~
6689− `[(itype-in-import typ.u.found u.iface i.t.names.sh prelude.state) state]
5480+ `[typ.u.found state]
6690 =/ found=(unit itype)
5481 =/ found=(unit itype)
6691 (find-imported-mold i.t.names.sh n externals.state surs.state)
5482 (find-imported-mold i.t.names.sh n externals.state surs.state)
6692 ?~ found ~
5483 ?~ found ~
@@ -6698,20 +5489,11 @@
6698 `[u.imported state]
5489 `[u.imported state]
6699 ?: (lien active.state |=(x=term =(x n))) ~
5490 ?: (lien active.state |=(x=term =(x n))) ~
6700 =/ found=(unit shape) (find-simple-mold n molds.state)
5491 =/ found=(unit shape) (find-simple-mold n molds.state)
6701− ?~ found
5492+ ?~ found ~
6702− ?: (lien molds.state |=(m=[name=term body=shape] =(name.m n))) ~
6704− =/ prelude-entry=(unit ischeme) (find-jibb-mold n u.prelude.state)
6706− ?^ vars.u.prelude-entry ~
6707− `[typ.u.prelude-entry state]
6708− =/ direct=(unit itype) (simple-source-recursive n u.found state)
6709− ?^ direct `[u.direct state]
6710 =/ out=(unit [typ=itype state=istate])
5493 =/ out=(unit [typ=itype state=istate])
6711 $(sh u.found, state state(active [n active.state], in-mold &, params ~))
5494 $(sh u.found, state state(active [n active.state], in-mold &, params ~))
6712 ?~ out ~
5495 ?~ out ~
6713− ?^ (unresolved-hole holes.state.u.out holes.state state.u.out) ~
6714− `[(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)]
5496+ `[typ.u.out state.u.out(active active.state, in-mold in-mold.state, params params.state)]
6716 ?~ ref.sh ~
5498 ?~ ref.sh ~
6717 =/ args=(unit [types=(list itype) state=istate]) (infer-shape-args args.sh state)
5499 =/ args=(unit [types=(list itype) state=istate]) (infer-shape-args args.sh state)
@@ -6726,18 +5508,10 @@
6726 ?~ vars.u.template ~
5508 ?~ vars.u.template ~
6727 =/ applied=(unit itype) (template-apply u.template types.u.args)
5509 =/ applied=(unit itype) (template-apply u.template types.u.args)
6728 ?~ applied ~
5510 ?~ applied ~
6729− `[(itype-in-import u.applied u.iface i.t.ref.sh prelude.state.u.args) state.u.args]
5511+ `[u.applied state.u.args]
6730 ?: (lien active.state.u.args |=(x=term =(x n))) ~
5512 ?: (lien active.state.u.args |=(x=term =(x n))) ~
6731 =/ found=(unit shape) (find-simple-mold n molds.state.u.args)
5513 =/ found=(unit shape) (find-simple-mold n molds.state.u.args)
6732− ?~ found
5514+ ?~ found ~
6733− ?: (lien molds.state.u.args |=(m=[name=term body=shape] =(name.m n))) ~
6734− ?~ prelude.state.u.args ~
6735− =/ prelude-entry=(unit ischeme) (find-jibb-mold n u.prelude.state.u.args)
6737− ?~ vars.u.prelude-entry ~
6738− =/ applied=(unit itype) (template-apply u.prelude-entry types.u.args)
6740− `[u.applied state.u.args]
6741 ?. ?=(%generic -.u.found) ~
5515 ?. ?=(%generic -.u.found) ~
6742 ?. (distinct-params vars.u.found) ~
5516 ?. (distinct-params vars.u.found) ~
6743 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
5517 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
@@ -6745,19 +5519,14 @@
6745 =/ out=(unit [typ=itype state=istate])
5519 =/ out=(unit [typ=itype state=istate])
6746 $(sh body.u.found, state state.u.args(active [n active.state.u.args], in-mold &, params u.params))
5520 $(sh body.u.found, state state.u.args(active [n active.state.u.args], in-mold &, params u.params))
6747 ?~ out ~
5521 ?~ out ~
6748− ?^ (unresolved-hole holes.state.u.out holes.state.u.args state.u.out) ~
6749− ?: &(?=(%union -.typ.u.out) !?=(%union -.body.u.found) ?=(~ origin.typ.u.out)) ~
6750− ?: &(?=(%union -.typ.u.out) ?=(%union -.body.u.found) !(lien top-molds.state.u.args |=(x=term =(x n)))) ~
6751− =? typ.u.out &(?=(%union -.typ.u.out) ?=(%union -.body.u.found))
6752− (label-direct-union typ.u.out(args types.u.args) u.found n state.u.args)
6753− `[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)]
5522+ `[typ.u.out state.u.out(active active.state.u.args, in-mold in-mold.state.u.args, params params.state.u.args)]
6755 =/ param=(unit itype) (iparam-lookup name.sh params.state)
5524 =/ param=(unit itype) (iparam-lookup name.sh params.state)
6756 ?^ param `[u.param state]
5525 ?^ param `[u.param state]
6757 ?: in-mold.state ~
5526 ?: in-mold.state ~
6758 =/ n=(unit @ud) (icap-lookup name.sh caps.state)
5527 =/ n=(unit @ud) (icap-lookup name.sh caps.state)
6759 ?^ n `[[%var u.n] state]
5528 ?^ n `[[%var u.n] state]
6760− `[[%var next.state] state(next +(next.state), caps [[name.sh next.state at.sh] caps.state])]
5529+ `[[%var next.state] state(next +(next.state), caps [[name.sh next.state] caps.state])]
@@ -6790,12 +5559,12 @@
6790 ^- isample-result
5559 ^- isample-result
6793− ?: |(=(name.s %proj) ?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
5562+ ?: |(?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
6794 [%| "sample shadows a name"]
5563 [%| "sample shadows a name"]
6795 =/ t=itype [%var next.state]
5564 =/ t=itype [%var next.state]
6796 [%& t [[name.s [t ~]] env] state(next +(next.state), binders [next.state binders.state])]
5565 [%& t [[name.s [t ~]] env] state(next +(next.state), binders [next.state binders.state])]
6798− ?: |(=(name.s %proj) ?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
5567+ ?: |(?=(^ (ienv-lookup name.s env)) (lien globals.state |=(x=term =(x name.s))))
6799 [%| "sample shadows a name"]
5568 [%| "sample shadows a name"]
6800 =/ t=(unit [typ=itype state=istate]) (infer-simple-shape shape.s state)
5569 =/ t=(unit [typ=itype state=istate]) (infer-simple-shape shape.s state)
6801 ?~ t [%| "sample mold is not supported by partial inference"]
5570 ?~ t [%| "sample mold is not supported by partial inference"]
@@ -6833,8 +5602,8 @@
6833 [%& [%cell ht typ.p.tail] env.p.tail state.p.tail]
5602 [%& [%cell ht typ.p.tail] env.p.tail state.p.tail]
6835:: Local definitions generalize only variables outside their enclosing
5604:: Local definitions generalize only variables outside their enclosing
6836−:: environment and explicit-capital scope. Recursive gate groups use
5605+:: environment and explicit-capital scope. Unresolved groups stay
6837−:: monomorphic placeholders while their bodies are checked.
5606+:: unsupported: this fragment does not infer recursive definitions.
6839+$ ilocal-result (each [env=ienv state=istate] idiag)
5608+$ ilocal-result (each [env=ienv state=istate] idiag)
6840++ free-env-vars
5609++ free-env-vars
@@ -6863,7 +5632,6 @@
6865 ?: ?=(%mold -.i.ds) $(ds t.ds)
5634 ?: ?=(%mold -.i.ds) $(ds t.ds)
6866− ?: =(name.i.ds %proj) |
6867 ?. (unique-value-name name.i.ds names) |
5635 ?. (unique-value-name name.i.ds names) |
6868 ?: ?=(^ (ienv-lookup name.i.ds env)) |
5636 ?: ?=(^ (ienv-lookup name.i.ds env)) |
6869 ?: (lien globals.state |=(n=term =(n name.i.ds))) |
5637 ?: (lien globals.state |=(n=term =(n name.i.ds))) |
@@ -6887,7 +5655,6 @@
6888 ?~ locals &
5656 ?~ locals &
6889 =/ n=term name.i.locals
5657 =/ n=term name.i.locals
6891 ?. (unique-value-name n names) |
5658 ?. (unique-value-name n names) |
6892 ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) |
5659 ?: (lien molds.state |=(m=[name=term body=shape] =(n name.m))) |
6893 ?: (lien marks.state |=(m=term =(n m))) |
5660 ?: (lien marks.state |=(m=term =(n m))) |
@@ -6905,145 +5672,6 @@
6905 ?~ inferred |
5672 ?~ inferred |
6906 $(locals t.locals)
5673 $(locals t.locals)
6908−:: Gather written capitals belonging to one ++. Nested local definitions
6909−:: establish their own scopes; inline gates remain in the enclosing scope.
6910−+$ icap-site [name=@t at=span]
6913− ^- (list icap-site)
6915− %tvar ~[[name.s at.s]]
6916− %apply (zing (turn args.s scope-shape))
6917− %cell (zing (turn fields.s scope-field))
6918− %union (zing (turn cases.s scope-shape))
6919− %fn (weld (scope-shape sample.s) (scope-shape product.s))
6921− =/ inside=(list icap-site) (scope-shape body.s)
6922− (skim inside |=(site=icap-site !(lien vars.s |=(v=@t =(v name.site)))))
6928− ^- (list icap-site)
6930− %face (scope-shape shape.f)
6931− %bare (scope-shape shape.f)
6937− ^- (list icap-site)
6939− %face (scope-shape shape.s)
6940− %bare (scope-shape shape.s)
6941− %cell (zing (turn items.s scope-sample))
6947− ^- (list icap-site)
6949− =/ first=(list icap-site)
6951− %expr (scope-expr p.i.ps)
6954− (weld first $(ps t.ps))
6958− ^- (list icap-site)
6960− =/ first=(list icap-site)
6962− %expr (scope-expr p.i.ps)
6965− (weld first $(ps t.ps))
6969− ^- (list icap-site)
6971− =/ first=(list icap-site) (scope-expr val.i.xs)
6972− (weld first $(xs t.xs))
6976− ^- (list icap-site)
6978− =/ first=(list icap-site) (scope-expr val.i.xs)
6979− (weld first $(xs t.xs))
6983− ^- (list icap-site)
6985− =/ first=(list icap-site) (scope-expr val.i.xs)
6986− (weld first $(xs t.xs))
6990− ^- (list icap-site)
6992− =/ first=(list icap-site) (scope-expr i.xs)
6993− (weld first $(xs t.xs))
6997− ^- (list icap-site)
6999− %str (scope-pieces pieces.e)
7000− %qath (scope-qsegs segs.e)
7001− %change (scope-edits edits.e)
7002− %pair (scope-expr val.e)
7003− %unit (scope-expr val.e)
7004− %group (scope-expr inner.e)
7005− %list (scope-exprs items.e)
7006− %tuple (scope-items items.e)
7008− =/ first=(list icap-site) (scope-sample sample.e)
7009− =/ last=(list icap-site) (scope-expr body.e)
7012− =/ first=(list icap-site) (scope-sample sample.e)
7013− =/ last=(list icap-site) (scope-expr body.e)
7016− =/ first=(list icap-site) (scope-expr head.e)
7017− =/ last=(list icap-site) (scope-exprs args.e)
7020− =/ first=(list icap-site) (scope-shape shape.e)
7021− =/ last=(list icap-site) (scope-expr val.e)
7024− =/ first=(list icap-site) (scope-expr val.e)
7025− =/ last=(list icap-site) (scope-expr then.e)
7028− =/ first=(list icap-site) (scope-expr subject.e)
7029− =/ last=(list icap-site) (scope-arms arms.e)
7031− %body (scope-expr final.e)
7035−++ reserve-cap-sites
7036− |= [sites=(list icap-site) state=istate]
7039− ?: ?=(^ (icap-lookup name.i.sites caps.state)) $(sites t.sites)
7040− $(sites t.sites, state state(next +(next.state), caps [[name.i.sites next.state at.i.sites] caps.state]))
7043− |= [e=expr state=istate]
7045− (reserve-cap-sites (scope-expr e) state)
7047++ infer-local-defs
5675++ infer-local-defs
7048 |= [ds=(list def) env=ienv state=istate]
5676 |= [ds=(list def) env=ienv state=istate]
7049 ^- ilocal-result
5677 ^- ilocal-result
@@ -7052,66 +5680,26 @@
7054 ?~ remaining [%& env state]
5682 ?~ remaining [%& env state]
7056− =/ pending=(list def) (flop remaining)
7057− =/ groups=icomponents (graph-components pending (global-value-names pending))
7058− =/ grouped=(unit [rest=(list def) env=ienv state=istate])
7059− (try-local-group pending groups env state)
7060− ?~ grouped [%| ["local definitions need unsupported inference" ~]]
5683+ ?. progressed [%| ["local definitions need unsupported inference" ~]]
7061− $(ds rest.u.grouped, remaining ~, env env.u.grouped, state state.u.grouped, progressed |)
7062 $(ds (flop remaining), remaining ~, progressed |)
5684 $(ds (flop remaining), remaining ~, progressed |)
7063 =/ d=def i.ds
5685 =/ d=def i.ds
7064 ?> ?=(%value -.d)
5686 ?> ?=(%value -.d)
7065− =/ local-state=istate (reserve-def-caps val.d state)
7066− =/ inferred=iresult (infer-fragment val.d env local-state)
5687+ =/ inferred=iresult (infer-fragment val.d env state)
7067− =/ retried=? ?=(%| -.inferred)
7068− =? inferred retried (infer-recursive-gate d env local-state)
7069 ?: ?=(%| -.inferred) $(ds t.ds, remaining [d remaining])
5688 ?: ?=(%| -.inferred) $(ds t.ds, remaining [d remaining])
7070− =. state.p.inferred (promote-restricted-numbers state.p.inferred env)
7071− =. 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)))
7072− =/ hole=(unit idiag) (unresolved-hole holes.state.p.inferred holes.state state.p.inferred)
7073− ?^ hole [%| u.hole]
7074− =/ merged=(unit [first=icap second=icap])
7075− (merged-capitals caps.state.p.inferred sub.state.p.inferred)
7077− [%| ["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"]]]]
7078− ?: (constrained-capitals caps.state.p.inferred sub.state.p.inferred)
7079− [%| ["explicit capital constraints are not supported by partial inference" ~]]
7080 =/ typ=itype (itype-normalize typ.p.inferred sub.state.p.inferred)
5689 =/ typ=itype (itype-normalize typ.p.inferred sub.state.p.inferred)
7081 ?: |((pending-tags tags.state.p.inferred sub.state.p.inferred) (itype-has-tag typ))
5690 ?: |((pending-tags tags.state.p.inferred sub.state.p.inferred) (itype-has-tag typ))
7082 $(ds t.ds, remaining [d remaining])
5691 $(ds t.ds, remaining [d remaining])
7083 ?: (unsupported-atom-vars typ caps.state.p.inferred binders.state.p.inferred sub.state.p.inferred)
5692 ?: (unsupported-atom-vars typ caps.state.p.inferred binders.state.p.inferred sub.state.p.inferred)
7084 $(ds t.ds, remaining [d remaining])
5693 $(ds t.ds, remaining [d remaining])
7085 =/ free=(list @ud)
5694 =/ free=(list @ud)
7086− (weld (free-env-vars env sub.state.p.inferred) (free-cap-vars caps.state sub.state.p.inferred))
5695+ (weld (free-env-vars env sub.state.p.inferred) (free-cap-vars caps.state.p.inferred sub.state.p.inferred))
7087 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
5696 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
7088 =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
5697 =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
7089− $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred(caps caps.state, holes holes.state), progressed &)
5698+ $(ds t.ds, env [[name.d [typ vars]] env], state state.p.inferred, progressed &)
7091−:: Try complete cyclic local groups after individual definitions stall.
7092−:: Components with non-gates or unresolved constraints stay unavailable.
7095− |= [ds=(list def) groups=icomponents env=ienv state=istate]
7096− ^- (unit [rest=(list def) env=ienv state=istate])
7098− =/ names=(list term) i.groups
7099− ?. (gth (lent names) 1) $(groups t.groups)
7100− =/ members=(list def)
7101− (skim ds |=(d=def &(?=(%value -.d) (lien names |=(n=term =(n name.d))))))
7102− ?. =((lent members) (lent names)) $(groups t.groups)
7103− =/ result=ilocal-result (infer-gate-group members env state)
7104− ?: ?=(%| -.result) $(groups t.groups)
7106− (skim ds |=(d=def !(lien names |=(n=term =(n name.d)))))
7107− =/ more=(unit [rest=(list def) env=ienv state=istate])
7108− $(ds rest, groups t.groups, env env.p.result, state state.p.result)
7110− `[rest env.p.result state.p.result]
7112:: Read only fields of a known record. Unresolved field constraints and
5700:: Read only fields of a known record. Unresolved field constraints and
7113−:: ambiguous repeated faces are outside this fragment. Imported record
5701+:: ambiguous repeated faces are outside this fragment (doc question:
7114−:: spines with repeated names are unavailable when used.
5702+:: whether duplicate imported Hoon faces are valid or select a field).
7116++ record-fields-named
5704++ record-fields-named
7117 |= [name=term t=itype sub=isub]
5705 |= [name=term t=itype sub=isub]
@@ -7130,909 +5718,22 @@
7130 ^- iresult
5718 ^- iresult
7131 =/ reverse=(list term) (flop names)
5719 =/ reverse=(list term) (flop names)
7132 ?~ reverse [%| ["empty wing" ~]]
5720 ?~ reverse [%| ["empty wing" ~]]
7133− =/ iface=(unit ifile) (find-jibb-interface i.reverse jimports.state)
5721+ =/ scheme=(unit ischeme) (ienv-lookup i.reverse env)
5722+ ?~ scheme [%| ["field access is not supported by partial inference" ~]]
5723+ =/ inst=[typ=itype state=istate] (instantiate-scheme u.scheme state)
7134 =/ fields=(list term) t.reverse
5724 =/ fields=(list term) t.reverse
7135− ?~ fields [%| ["field access is not supported by partial inference" ~]]
7136− =/ scheme=(unit ischeme)
7138− (ienv-lookup i.reverse env)
7139− (ienv-lookup i.fields values.u.iface)
7141− ?^ iface [%| ["module member is not available to partial inference" ~]]
7142− [%| ["field access is not supported by partial inference" ~]]
7143− =/ inst=[typ=itype state=istate]
7144− ?~ iface (instantiate-scheme u.scheme state)
7145− =/ imported=ischeme u.scheme
7146− =. typ.imported (itype-in-import typ.imported u.iface i.reverse prelude.state)
7147− (instantiate-scheme imported state)
7148− =/ remaining=(list term) ?~(iface fields t.fields)
7149 =/ typ=itype typ.inst
5725 =/ typ=itype typ.inst
7151− ?~ remaining [%& typ state.inst]
5727+ ?~ fields [%& typ state.inst]
7152− =/ found=(list itype) (record-fields-named i.remaining typ sub.state.inst)
5728+ =/ found=(list itype) (record-fields-named i.fields typ sub.state.inst)
7153 ?~ found [%| ["field is not available to partial inference" ~]]
5729 ?~ found [%| ["field is not available to partial inference" ~]]
7154 ?^ t.found [%| ["field name is ambiguous in partial inference" ~]]
5730 ?^ t.found [%| ["field name is ambiguous in partial inference" ~]]
7155− $(remaining t.remaining, typ i.found)
5731+ $(fields t.fields, typ i.found)
7157−:: Propagate a known union or list through supported loobean, unit and list
7158−:: branches. Empty bodies and groups are transparent; bodies with definitions
7159−:: keep their normal scoping and wait for general bidirectional inference.
7161−++ context-union-branch
7166− %group $(e inner.e)
7167− %body ?~(defs.e $(e final.e) |)
7171−++ infer-union-context
7172− |= [e=expr expected=itype env=ienv state=istate context=span]
7174− ?: ?=(%group -.e) $(e inner.e)
7175− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
7176− ?: &(?=(%collection -.expected) =(%list name.expected) (context-list-expression e))
7177− (infer-list-context e expected env state context)
7179− ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
7180− ?~ t.arms.e [%| ["branch pattern is not supported by partial inference" ~]]
7181− ?^ t.t.arms.e [%| ["branch is not supported by partial inference" ~]]
7183− =/ y=arm i.t.arms.e
7184− ?: |((unit-empty-pattern pat.x) (unit-empty-pattern pat.y))
7185− (infer-unit-branch e env state `[expected context])
7186− ?. &(?=(%lit -.pat.x) ?=(%lit -.pat.y))
7187− [%| ["branch pattern is not supported by partial inference" ~]]
7188− ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y))
7189− [%| ["branch pattern is not supported by partial inference" ~]]
7190− ?: =(val.lit.pat.x val.lit.pat.y)
7191− [%| ["branch does not cover both loobeans" ~]]
7192− =/ subject=iresult (infer-fragment subject.e env state)
7193− ?: ?=(%| -.subject) subject
7194− =/ subject-type=itype (itype-normalize typ.p.subject sub.state.p.subject)
7195− ?: ?=(%union -.subject-type)
7196− [%| ["contextual union-pattern branch is not supported by partial inference" ~]]
7197− =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
7198− ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
7199− =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
7200− ?: ?=(%| -.left) left
7201− =/ right=iresult $(e val.y, state state.p.left)
7202− ?: ?=(%| -.right) right
7203− [%& expected state.p.right]
7204− =/ value=iresult (infer-fragment e env state)
7205− ?: ?=(%| -.value) value
7206− =/ fit=ifit (itype-fit typ.p.value expected sub.state.p.value next.state.p.value)
7207− ?: ?=(%unknown -.fit)
7208− ?: &(?=(%collection -.expected) =(%list name.expected))
7209− [%| ["branch list constraint is not supported by partial inference" ~]]
7210− ?: ?=(%flag -.expected) [%| ["branch loobean constraint is not supported by partial inference" ~]]
7211− [%| ["branch union constraint is not supported by partial inference" ~]]
7213− =/ missing=(unit idiag) (missing-union-tag e expected sub.state.p.value context)
7214− ?^ missing [%| u.missing]
7215− =/ nested=(unit idiag) (nested-missing-tag e typ.p.value expected sub.state.p.value next.state.p.value context)
7216− ?^ nested [%| u.nested]
7217− ?: &(?=(%collection -.expected) =(%list name.expected))
7218− [%| ["branch arm does not fit its expected list" ~[[context "expected list"] [(span-of e) "branch arm"]]]]
7219− ?: ?=(%flag -.expected)
7220− [%| ["branch arm does not fit its expected loobean" ~[[context "expected loobean"] [(span-of e) "branch arm"]]]]
7221− [%| ["branch arm does not fit its expected union" ~[[context "expected union"] [(span-of e) "branch arm"]]]]
7222− [%& expected state.p.value(sub sub.fit, next next.fit)]
7224−:: A list expression needs a known list target and the validated prelude list.
7225−:: Literal items and unfaced two-item cons cells receive that target one by
7226−:: one; pending constraints elsewhere stay in the threaded state.
7228−++ context-list-expression
7234− %lit |(=(%null form.lit.e) &(=(%term form.lit.e) =(0 val.lit.e)))
7235− %group $(e inner.e)
7236− %body ?~(defs.e $(e final.e) |)
7240−++ infer-list-context
7241− |= [e=expr expected=itype env=ienv state=istate context=span]
7243− ?: ?=(%group -.e) $(e inner.e)
7244− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
7245− ?~ prelude.state [%| ["list literal needs the standard prelude in partial inference" ~]]
7246− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
7247− [%| ["list literal needs the standard prelude in partial inference" ~]]
7248− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude.state)
7249− ?~ standard [%| ["list literal needs the standard prelude in partial inference" ~]]
7250− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]])
7251− [%| ["list literal needs the standard prelude in partial inference" ~]]
7252− =/ target=itype (itype-walk expected sub.state)
7253− ?. ?=(%collection -.target) [%| ["list context is not supported by partial inference" ~]]
7254− ?. =(%list name.target) [%| ["list context is not supported by partial inference" ~]]
7255− ?~ args.target [%| ["list context is not supported by partial inference" ~]]
7256− ?^ t.args.target [%| ["list context is not supported by partial inference" ~]]
7258− ?. |(=(%null form.lit.e) &(=(%term form.lit.e) =(0 val.lit.e)))
7259− [%| ["list expression is not supported by partial inference" ~]]
7262− =/ result=iresult (infer-list-items items.e i.args.target env state context)
7263− ?: ?=(%| -.result) result
7264− [%& target state.p.result]
7265− ?. ?=(%tuple -.e) [%| ["list expression is not supported by partial inference" ~]]
7266− ?~ items.e [%| ["cons shape is not supported by partial inference" ~]]
7267− ?~ t.items.e [%| ["cons shape is not supported by partial inference" ~]]
7268− ?^ t.t.items.e [%| ["cons shape is not supported by partial inference" ~]]
7269− ?^ face.i.items.e [%| ["faced cons is not supported by partial inference" ~]]
7270− ?^ face.i.t.items.e [%| ["faced cons is not supported by partial inference" ~]]
7271− =/ head=iresult (infer-list-items ~[val.i.items.e] i.args.target env state context)
7272− ?: ?=(%| -.head) head
7273− =/ target=itype (itype-walk target sub.state.p.head)
7275− ?: (context-list-expression val.i.t.items.e)
7276− (infer-list-context val.i.t.items.e target env state.p.head context)
7277− (infer-fragment val.i.t.items.e env state.p.head)
7278− ?: ?=(%| -.tail) tail
7279− =/ fit=ifit (itype-fit typ.p.tail target sub.state.p.tail next.state.p.tail)
7280− ?: ?=(%unknown -.fit) [%| ["list tail constraint is not supported by partial inference" ~]]
7282− [%| ["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)]]]]
7283− [%& target state.p.tail(sub sub.fit, next next.fit)]
7285−++ infer-open-list-items
7286− |= [items=(list expr) expected=itype env=ienv state=istate context=span]
7288− ?~ items [%& expected state]
7289− =/ target=itype (itype-walk expected sub.state)
7290− =/ value=iresult (infer-call-context-arg i.items target env state context)
7291− ?: ?=(%| -.value) value
7292− =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
7293− ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
7295− ?: |((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))
7296− [%| ["list item widening is not supported by partial inference" ~]]
7297− [%| ["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)]]]]
7298− ?: (itype-has-tag (itype-normalize expected sub.fit))
7299− [%| ["list item needs context in partial inference" ~]]
7300− $(items t.items, state state.p.value(sub sub.fit, next next.fit))
7303− |= [items=(list expr) expected=itype env=ienv state=istate context=span]
7305− ?~ items [%& expected state]
7306− =/ target=itype (itype-walk expected sub.state)
7307− =/ value=iresult (infer-call-context-arg i.items target env state context)
7308− ?: ?=(%| -.value) value
7309− =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
7310− ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
7312− =/ missing=(unit idiag) (missing-union-tag i.items target sub.state.p.value context)
7313− ?^ missing [%| u.missing]
7314− =/ nested=(unit idiag) (nested-missing-tag i.items typ.p.value target sub.state.p.value next.state.p.value context)
7315− ?^ nested [%| u.nested]
7316− [%| ["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)]]]]
7317− $(items t.items, state state.p.value(sub sub.fit, next next.fit))
7319−:: The supported unit pattern covers exactly an atom zero and a cell
7320−:: headed by zero, with a single binder for its payload. Unresolved
7321−:: subjects and all other pattern matrices stay outside this fragment.
7323−++ unit-empty-pattern
7327− =(%null form.lit.p)
7329−++ unit-payload-pattern
7336− ?. (unit-empty-pattern i.items.p) ~
7337− ?. ?=(%bind -.i.t.items.p) ~
7343− ?. ?=(%const -.t) |
7346−++ unit-payload-case
7350− ?. (unit-empty-case hed.t) ~
7351− =/ payload=itype tal.t
7352− =? payload ?=(%face -.payload) body.payload
7355−++ unit-union-payload
7358− ?. ?=(%union -.t) ~
7362− ?: (unit-empty-case i.cases.t) (unit-payload-case i.t.cases.t)
7363− ?: (unit-empty-case i.t.cases.t) (unit-payload-case i.cases.t)
7366−:: List matching currently covers exactly null and a cell of two binders.
7367−:: The head has the element type and the tail has the whole list type.
7368−:: Other patterns and lists whose element mold is empty remain unsupported.
7370−++ list-payload-pattern
7372− ^- (unit [head=term tail=term])
7377− ?. ?=(%bind -.i.items.p) ~
7378− ?. ?=(%bind -.i.t.items.p) ~
7379− `[name.i.items.p name.i.t.items.p]
7381−++ infer-list-branch
7382− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span]) typ=itype]
7385− ?> ?=(%collection -.typ)
7386− ?. =(%list name.typ) [%| ["list pattern is not supported by partial inference" ~]]
7387− ?~ prelude.state [%| ["list pattern needs the standard prelude in partial inference" ~]]
7388− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
7389− [%| ["list pattern needs the standard prelude in partial inference" ~]]
7390− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude.state)
7391− ?~ standard [%| ["list pattern needs the standard prelude in partial inference" ~]]
7392− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]])
7393− [%| ["list pattern needs the standard prelude in partial inference" ~]]
7394− ?~ args.typ [%| ["list pattern is not supported by partial inference" ~]]
7395− ?^ t.args.typ [%| ["list pattern is not supported by partial inference" ~]]
7396− ?~ arms.e [%| ["list branch is not supported by partial inference" ~]]
7397− ?~ t.arms.e [%| ["list branch is not supported by partial inference" ~]]
7398− ?^ t.t.arms.e [%| ["list branch is not supported by partial inference" ~]]
7400− =/ y=arm i.t.arms.e
7401− =/ first-empty=? (unit-empty-pattern pat.x)
7402− =/ first-name=(unit [head=term tail=term]) (list-payload-pattern pat.x)
7403− =/ second-name=(unit [head=term tail=term]) (list-payload-pattern pat.y)
7404− ?. |(&(first-empty ?=(^ second-name)) &((unit-empty-pattern pat.y) ?=(^ first-name)))
7405− [%| ["list branch pattern is not supported by partial inference" ~]]
7406− =/ binder=(unit [head=term tail=term]) ?:(first-empty second-name first-name)
7407− ?~ binder [%| ["list branch pattern is not supported by partial inference" ~]]
7408− ?: |(=(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)))))
7409− [%| ["pattern binder shadows a name" ~]]
7410− =/ extended=ienv [[head.u.binder [i.args.typ ~]] [tail.u.binder [typ ~]] env]
7412− ?~ expected (infer-fragment val.x ?:(first-empty env extended) state)
7413− (infer-union-context val.x typ.u.expected ?:(first-empty env extended) state context.u.expected)
7414− ?: ?=(%| -.left) left
7416− ?~ expected (infer-fragment val.y ?:(first-empty extended env) state.p.left)
7417− (infer-union-context val.y typ.u.expected ?:(first-empty extended env) state.p.left context.u.expected)
7418− ?: ?=(%| -.right) right
7419− ?^ expected [%& typ.u.expected state.p.right]
7420− =/ joined=(unit isub) (itype-unify typ.p.left typ.p.right sub.state.p.right)
7421− ?~ joined [%| ["list branch results need unsupported inference" ~]]
7422− [%& typ.p.left state.p.right(sub u.joined)]
7424−++ infer-unit-branch
7425− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
7428− ?~ arms.e [%| ["unit branch is not supported by partial inference" ~]]
7429− ?~ t.arms.e [%| ["unit branch is not supported by partial inference" ~]]
7430− ?^ t.t.arms.e [%| ["unit branch is not supported by partial inference" ~]]
7431− =/ subject=iresult (infer-fragment subject.e env state)
7432− ?: ?=(%| -.subject) subject
7433− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7434− ?: &(?=(%collection -.typ) =(%list name.typ))
7435− (infer-list-branch e env state.p.subject expected typ)
7437− =/ y=arm i.t.arms.e
7438− =/ first-empty=? (unit-empty-pattern pat.x)
7439− =/ first-name=(unit term) (unit-payload-pattern pat.x)
7440− =/ second-name=(unit term) (unit-payload-pattern pat.y)
7441− ?. |(&(first-empty ?=(^ second-name)) &((unit-empty-pattern pat.y) ?=(^ first-name)))
7442− [%| ["unit branch pattern is not supported by partial inference" ~]]
7443− =/ binder=(unit term) ?:(first-empty second-name first-name)
7444− ?~ binder [%| ["unit branch pattern is not supported by partial inference" ~]]
7445− ?: |(=(u.binder %proj) ?=(^ (ienv-lookup u.binder env)) (lien globals.state |=(n=term =(n u.binder))))
7446− [%| ["pattern binder shadows a name" ~]]
7447− =/ payload=(unit itype) (unit-union-payload typ)
7448− ?~ payload [%| ["unit branch subject is not supported by partial inference" ~]]
7449− =/ extended=ienv [[u.binder [u.payload ~]] env]
7451− ?~ expected (infer-fragment val.x ?:(first-empty env extended) state.p.subject)
7452− (infer-union-context val.x typ.u.expected ?:(first-empty env extended) state.p.subject context.u.expected)
7453− ?: ?=(%| -.left) left
7455− ?~ expected (infer-fragment val.y ?:(first-empty extended env) state.p.left)
7456− (infer-union-context val.y typ.u.expected ?:(first-empty extended env) state.p.left context.u.expected)
7457− ?: ?=(%| -.right) right
7458− ?^ expected [%& typ.u.expected state.p.right]
7459− =/ joined=(unit isub) (itype-unify typ.p.left typ.p.right sub.state.p.right)
7460− ?~ joined [%| ["unit branch results need unsupported inference" ~]]
7461− [%& typ.p.left state.p.right(sub u.joined)]
7463−:: Infer pieces in order, retaining their substitutions and pending tags.
7464−:: A bare decimal literal has no outside type constraint, so it takes its
7465−:: normal @ud default here. Other open numeric and aura variables wait for
7466−:: deferred constraints, which this fragment does not implement yet.
7467−++ infer-string-pieces
7468− |= [ps=(list piece) env=ienv state=istate]
7470− ?~ ps [%& [%atom %t] state]
7471− ?: ?=(%text -.i.ps) $(ps t.ps)
7472− =/ item=iresult (infer-fragment p.i.ps env state)
7473− ?: ?=(%| -.item) item
7474− =/ t=itype (itype-normalize typ.p.item sub.state.p.item)
7475− ?: |(?=(%atom -.t) ?=(%any-atom -.t))
7476− $(ps t.ps, state state.p.item)
7477− ?: &(|(?=(%nvar -.t) ?=(%rnvar -.t)) ?=(%lit -.p.i.ps) =(%number form.lit.p.i.ps))
7478− $(ps t.ps, state state.p.item)
7479− ?: &(?=(%collection -.t) =(%list name.t) =(~[[%atom 'tD']] args.t))
7480− $(ps t.ps, state state.p.item)
7481− ?: &(?=(%avar -.t) (atom-var-from-cap id.t caps.state.p.item sub.state.p.item))
7482− [%| ["a generic atom in interpolation needs an aura" ~[[(span-of p.i.ps) "atom with a generic aura"]]]]
7483− ?: &(?=(%rvar -.t) (atom-var-from-cap id.t caps.state.p.item sub.state.p.item))
7484− [%| ["a generic atom in interpolation needs an aura" ~[[(span-of p.i.ps) "atom with a generic aura"]]]]
7486− [%| ["a cell in interpolation needs a printer" ~[[(span-of p.i.ps) "cell without a printer"]]]]
7487− [%| ["interpolation type needs unsupported inference" ~]]
7489−:: Whole-case coverage for a known union. When a pattern may cover only
7490−:: part of a case, finite loobean refinements are tried below; other
7491−:: partial coverage stays unsupported until the general pattern matrix.
7492−+$ imatch ?(%full %none %unknown)
7493−++ union-pattern-items
7494− |= [ps=(list pattern) t=itype]
7497− ?~ t.ps (union-pattern i.ps t)
7498− =. t ?:(?=(%face -.t) body.t t)
7500− ?: |(?=(%atom -.t) ?=(%any-atom -.t) ?=(%flag -.t) ?=(%const -.t)) %none
7502− =/ a=imatch (union-pattern i.ps hed.t)
7503− =/ b=imatch $(ps t.ps, t tal.t)
7504− ?: |(=(%none a) =(%none b)) %none
7505− ?:(&(=(%full a) =(%full b)) %full %unknown)
7508− |= [p=pattern t=itype]
7510− =. t ?:(?=(%face -.t) body.t t)
7515− ?: ?=(%const -.t) ?:(=(val.literal.t val.lit.p) %full %none)
7516− ?: ?=(%cell -.t) %none
7518− ?:(|(=(0 val.lit.p) =(1 val.lit.p)) %unknown %none)
7520− %str ?:(?=(%cell -.t) %none %unknown)
7521− %cell (union-pattern-items items.p t)
7524−++ union-pattern-has-bind
7529− (lien items.p union-pattern-has-bind)
7531−++ union-pattern-bind-items
7532− |= [ps=(list pattern) t=itype env=ienv globals=(list term)]
7535− ?~ t.ps (union-pattern-bind i.ps t env globals)
7536− =. t ?:(?=(%face -.t) body.t t)
7538− =/ first=(unit ienv) (union-pattern-bind i.ps hed.t env globals)
7540− $(ps t.ps, t tal.t, env u.first)
7542−++ union-pattern-bind
7543− |= [p=pattern t=itype env=ienv globals=(list term)]
7545− =. t ?:(?=(%face -.t) body.t t)
7547− ?: |(=(name.p %proj) ?=(^ (ienv-lookup name.p env)) (lien globals |=(n=term =(n name.p)))) ~
7548− `[[name.p [t ~]] env]
7549− ?: ?=(%cell -.p) (union-pattern-bind-items items.p t env globals)
7552−:: Split loobean fields into finite refinements for partial patterns.
7553−:: Keep original cases for binder types and preserve whole-case matching
7554−:: before trying refinements. Cap products at 64; unknown, empty or opaque
7555−:: shapes stay unsupported rather than implying complete pattern checking.
7556−+$ ifinite [origin=@ud base=itype part=itype]
7558− |= [hs=(list itype) ts=(list itype) out=(list itype)]
7561− =/ rows=(list itype) (turn ts |=(t=itype [%cell i.hs t]))
7562− $(hs t.hs, out (weld rows out))
7566− ^- (unit (list itype))
7569− `~[[%const [%loobean %f 0 '%.y']] [%const [%loobean %f 1 '%.n']]]
7571− =/ body=(unit (list itype)) $(t body.t)
7573− `(turn u.body |=(x=itype [%face name.t x]))
7575− =/ hed=(unit (list itype)) $(t hed.t)
7577− =/ tal=(unit (list itype)) $(t tal.t)
7579− ?: (gth (mul (lent u.hed) (lent u.tal)) 64) ~
7580− `(finite-product u.hed u.tal ~)
7585− |= [xs=(list itype) out=(list ifinite) origin=@ud]
7586− ^- (unit (list ifinite))
7588− =/ parts=(unit (list itype)) (finite-type i.xs)
7590− ?: (gth (add (lent out) (lent u.parts)) 64) ~
7591− =/ rows=(list ifinite) (turn u.parts |=(t=itype [origin i.xs t]))
7592− $(xs t.xs, out (weld out rows), origin +(origin))
7594−++ infer-known-union-whole
7595− |= [e=expr env=ienv subject=iresult]
7598− ?: ?=(%| -.subject) `subject
7599− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7600− ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
7601− =/ cases=(list itype) cases.typ
7602− =/ remaining=(list itype) cases
7603− =/ arms=(list arm) arms.e
7604− =/ st=istate state.p.subject
7605− =/ answer=(unit itype) ~
7609− `[%| ["missing union case {(show-itype i.remaining sub.st)}" ~]]
7610− ?~ answer `[%| ["empty union branch is not supported by partial inference" ~]]
7613− ?: (lien remaining |=(c=itype =(%unknown (union-pattern pat.a c))))
7615− =/ matching=(list itype) (skim remaining |=(c=itype =(%full (union-pattern pat.a c))))
7617− ?: (lien cases |=(c=itype =(%full (union-pattern pat.a c))))
7618− `[%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7619− `[%| ["union pattern is not supported by partial inference" ~]]
7620− ?: &(?=(^ t.matching) (union-pattern-has-bind pat.a))
7621− `[%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7622− =/ bound=(unit ienv) (union-pattern-bind pat.a i.matching env globals.st)
7623− ?~ bound `[%| ["pattern binder shadows a name" ~]]
7624− =/ body=iresult (infer-fragment val.a u.bound st)
7625− ?: ?=(%| -.body) `body
7626− =/ result=itype (itype-normalize typ.p.body sub.state.p.body)
7627− =/ mismatch=? ?~(answer | !=((itype-normalize u.answer sub.state.p.body) result))
7628− ?: mismatch `[%| ["union branch result matching needs unsupported inference" ~]]
7629− $(arms t.arms, remaining (skim remaining |=(c=itype !=(%full (union-pattern pat.a c)))), st state.p.body, answer `result)
7631−++ infer-known-union-context-whole
7632− |= [e=expr expected=itype env=ienv subject=iresult context=span]
7635− ?: ?=(%| -.subject) `subject
7636− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7637− ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
7638− =/ cases=(list itype) cases.typ
7639− =/ remaining=(list itype) cases
7640− =/ arms=(list arm) arms.e
7641− =/ st=istate state.p.subject
7642− =/ answer=(unit itype) ~
7646− `[%| ["missing union case {(show-itype i.remaining sub.st)}" ~]]
7647− ?~ answer `[%| ["empty union branch is not supported by partial inference" ~]]
7650− ?: (lien remaining |=(c=itype =(%unknown (union-pattern pat.a c))))
7652− =/ matching=(list itype) (skim remaining |=(c=itype =(%full (union-pattern pat.a c))))
7654− ?: (lien cases |=(c=itype =(%full (union-pattern pat.a c))))
7655− `[%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7656− `[%| ["union pattern is not supported by partial inference" ~]]
7657− ?: &(?=(^ t.matching) (union-pattern-has-bind pat.a))
7658− `[%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7659− =/ bound=(unit ienv) (union-pattern-bind pat.a i.matching env globals.st)
7660− ?~ bound `[%| ["pattern binder shadows a name" ~]]
7661− =/ body=iresult (infer-call-context-arg val.a expected u.bound st context)
7662− ?: ?=(%| -.body) `body
7663− =/ fit=ifit (itype-fit typ.p.body expected sub.state.p.body next.state.p.body)
7664− ?: ?=(%unknown -.fit) `[%| ["union branch result constraint is not supported by partial inference" ~]]
7666− =/ missing=(unit idiag) (missing-union-tag val.a expected sub.state.p.body context)
7667− ?^ missing `[%| u.missing]
7668− =/ nested=(unit idiag) (nested-missing-tag val.a typ.p.body expected sub.state.p.body next.state.p.body context)
7669− ?^ nested `[%| u.nested]
7670− `[%| ["union branch arm does not fit its expected type" ~[[context "expected type"] [(span-of val.a) "branch arm"]]]]
7671− ?: (itype-has-tag (itype-normalize expected sub.fit))
7672− `[%| ["union branch result needs context in partial inference" ~]]
7673− $(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)
7675−++ infer-known-union-finite
7676− |= [e=expr env=ienv subject=iresult expected=(unit [typ=itype context=span])]
7679− ?: ?=(%| -.subject) subject
7680− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7681− ?. ?=(%union -.typ) [%| ["branch is not supported by partial inference" ~]]
7682− =/ expanded=(unit (list ifinite)) (finite-cases cases.typ ~ 0)
7683− ?~ expanded [%| ["union pattern expansion needs unsupported inference" ~]]
7684− =/ cases=(list ifinite) u.expanded
7685− =/ remaining=(list ifinite) cases
7686− =/ arms=(list arm) arms.e
7687− =/ st=istate state.p.subject
7688− =/ answer=(unit itype) ~
7692− [%| ["missing union case {(show-itype part.i.remaining sub.st)}" ~]]
7693− ?~ answer [%| ["empty union branch is not supported by partial inference" ~]]
7694− ?~ expected [%& u.answer st]
7695− [%& typ.u.expected st]
7697− ?: (lien remaining |=(c=ifinite =(%unknown (union-pattern pat.a part.c))))
7698− [%| ["partial union pattern is not supported by partial inference" ~]]
7699− =/ matching=(list ifinite) (skim remaining |=(c=ifinite =(%full (union-pattern pat.a part.c))))
7701− ?: (lien cases |=(c=ifinite =(%full (union-pattern pat.a part.c))))
7702− [%| ["branch arm is covered by earlier arms" ~[[at.pat.a "covered arm"]]]]
7703− [%| ["union pattern is not supported by partial inference" ~]]
7704− ?: &((union-pattern-has-bind pat.a) (lien t.matching |=(c=ifinite !=(origin.c origin.i.matching))))
7705− [%| ["a union pattern binding several cases is not supported by partial inference" ~]]
7706− =/ bound=(unit ienv) (union-pattern-bind pat.a base.i.matching env globals.st)
7707− ?~ bound [%| ["pattern binder shadows a name" ~]]
7709− ?~ expected (infer-fragment val.a u.bound st)
7710− (infer-call-context-arg val.a typ.u.expected u.bound st context.u.expected)
7711− ?: ?=(%| -.body) body
7713− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
7714− ?: ?=(%unknown -.fit) [%| ["union branch result constraint is not supported by partial inference" ~]]
7716− =/ missing=(unit idiag) (missing-union-tag val.a typ.u.expected sub.state.p.body context.u.expected)
7717− ?^ missing [%| u.missing]
7718− =/ 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)
7719− ?^ nested [%| u.nested]
7720− [%| ["union branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.a) "branch arm"]]]]
7721− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
7722− [%| ["union branch result needs context in partial inference" ~]]
7723− $(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)
7724− =/ result=itype (itype-normalize typ.p.body sub.state.p.body)
7725− =/ mismatch=? ?~(answer | !=((itype-normalize u.answer sub.state.p.body) result))
7726− ?: mismatch [%| ["union branch result matching needs unsupported inference" ~]]
7727− $(arms t.arms, remaining (skim remaining |=(c=ifinite !=(%full (union-pattern pat.a part.c)))), st state.p.body, answer `result)
7729−:: Prove a one-arm record pattern covers a known, non-union subject.
7730−:: Variable or partial matches stay unsupported; binding uses the same
7731−:: scope and original payload types as the existing union matcher.
7732−++ single-structured-pattern
7735− ?. ?=(%branch -.e) |
7738− =/ p=pattern pat.i.arms.e
7740− !(levy items.p |=(x=pattern ?=(%bind -.x)))
7742−++ infer-single-case-branch
7743− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
7745− ?> (single-structured-pattern e)
7749− =/ subject=iresult (infer-fragment subject.e env state)
7750− ?: ?=(%| -.subject) subject
7751− =/ st=istate state.p.subject
7752− =/ typ=itype (itype-normalize typ.p.subject sub.st)
7753− ?: ?=(%union -.typ) [%| ["single-case pattern needs unsupported inference" ~]]
7754− ?. =(%full (union-pattern pat.a typ))
7755− [%| ["single-case pattern needs unsupported inference" ~]]
7756− =/ bound=(unit ienv) (union-pattern-bind pat.a typ env globals.st)
7757− ?~ bound [%| ["pattern binder shadows a name" ~]]
7758− ?~ expected (infer-fragment val.a u.bound st)
7759− =/ body=iresult (infer-call-context-arg val.a typ.u.expected u.bound st context.u.expected)
7760− ?: ?=(%| -.body) body
7761− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
7762− ?: ?=(%unknown -.fit) [%| ["single-case branch result constraint is not supported by partial inference" ~]]
7764− =/ missing=(unit idiag) (missing-union-tag val.a typ.u.expected sub.state.p.body context.u.expected)
7765− ?^ missing [%| u.missing]
7766− =/ 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)
7767− ?^ nested [%| u.nested]
7768− [%| ["single-case branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.a) "branch arm"]]]]
7769− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
7770− [%| ["single-case branch result needs context in partial inference" ~]]
7771− [%& typ.u.expected state.p.body(sub sub.fit, next next.fit)]
7773−:: This view is used only by pattern analysis, never exported or bound as
7774−:: the subject. Only null plus a two-binder/wildcard cell is supported; its
7775−:: tail keeps the original recursive type. Other patterns fail closed.
7777− |= [e=expr subject=iresult]
7779− ?: ?=(%| -.subject) subject
7780− ?. ?=(%branch -.e) subject
7781− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7782− ?. ?=(%jrec -.typ) subject
7784− ?~ t.arms.e subject
7785− ?^ t.t.arms.e subject
7786− =/ x=pattern pat.i.arms.e
7787− =/ y=pattern pat.i.t.arms.e
7788− =/ empty=? &(?=(%lit -.x) =(%null form.lit.x))
7789− =/ full=pattern ?:(empty y x)
7790− ?. |(empty &(?=(%lit -.y) =(%null form.lit.y))) subject
7791− ?. ?=(%cell -.full) subject
7792− ?~ items.full subject
7793− ?~ t.items.full subject
7794− ?^ t.t.items.full subject
7795− ?. |(?=(%bind -.i.items.full) ?=(%any -.i.items.full)) subject
7796− ?. |(?=(%bind -.i.t.items.full) ?=(%any -.i.t.items.full)) subject
7797− ?: =(0 jrec-fuel.state.p.subject)
7798− [%| ["recursive mold unfolding needs unsupported inference" ~]]
7799− =/ nil=itype [%const [%null %n 0 '~']]
7800− =/ cell=itype [%cell [%face head.typ [%atom aura.typ]] [%face tail.typ typ]]
7801− [%& [%union ~[nil cell] ~ ~ ~] state.p.subject(jrec-fuel (dec jrec-fuel.state.p.subject))]
7803−++ infer-known-union-branch-subject
7804− |= [e=expr env=ienv subject=iresult]
7806− =. subject (jrec-match-view e subject)
7807− =/ whole=(unit iresult) (infer-known-union-whole e env subject)
7808− ?~ whole (infer-known-union-finite e env subject ~)
7811−++ infer-known-union-branch
7812− |= [e=expr env=ienv state=istate]
7815− (infer-known-union-branch-subject e env (infer-fragment subject.e env state))
7817−++ infer-known-union-context-subject
7818− |= [e=expr expected=itype env=ienv subject=iresult context=span]
7820− =. subject (jrec-match-view e subject)
7821− =/ whole=(unit iresult) (infer-known-union-context-whole e expected env subject context)
7822− ?~ whole (infer-known-union-finite e env subject `[expected context])
7825−:: Limit speculative subject inference to wings and shallow calls;
7826−:: grouping is peeled linearly and cannot introduce a nested branch.
7827−++ simple-union-subject-arg
7833− %str !(lien pieces.e |=(p=piece ?=(%expr -.p)))
7837−++ safe-union-subject
7840− ?: ?=(%group -.e) $(e inner.e)
7843− ?. ?=(%wing -.head.e) |
7844− (levy args.e simple-union-subject-arg)
7846−++ duplicate-loobean-arms
7849− ?. ?=(%branch -.e) |
7853− =/ x=pattern pat.i.arms.e
7854− =/ y=pattern pat.i.t.arms.e
7855− ?. &(?=(%lit -.x) ?=(%lit -.y)) |
7856− ?. &(=(%loobean form.lit.x) =(%loobean form.lit.y)) |
7857− =(val.lit.x val.lit.y)
7859−++ union-subject-call
7862− ?: ?=(%group -.e) $(e inner.e)
7865−++ known-union-subject
7866− |= [e=expr env=ienv state=istate]
7868− ?. (safe-union-subject e) ~
7869− =/ subject=iresult (infer-fragment e env state)
7870− ?: ?=(%| -.subject) ?:((union-subject-call e) `subject ~)
7871− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
7872− ?. |(?=(%union -.typ) ?=(%jrec -.typ)) ~
7876−:: Infer changes only against a fully known record spine. Retain the
7877−:: target type; unknown spines and repeated edits remain unsupported.
7878−++ change-spine-known
7879− |= [t=itype sub=isub]
7881− =. t (itype-walk t sub)
7884− =/ first=itype (itype-walk hed.t sub)
7885− ?. ?=(%face -.first) |
7888−++ infer-change-edits
7889− |= [edits=(list edit) target=itype env=ienv state=istate seen=(list term)]
7891− ?~ edits [%& target state]
7892− =/ entry=edit i.edits
7893− ?: (lien seen |=(name=term =(name name.entry)))
7894− [%| ["repeated change fields are not supported by partial inference" ~]]
7895− ?. (change-spine-known target sub.state)
7896− [%| ["change target needs a known record in partial inference" ~]]
7897− =/ found=(list itype) (record-fields-named name.entry target sub.state)
7899− [%| ["record has no field `{(trip name.entry)}`" ~[[at.entry "unknown field"]]]]
7900− ?^ t.found [%| ["change field is ambiguous in partial inference" ~]]
7901− =/ expected=itype i.found
7902− =/ value=iresult (infer-call-context-arg val.entry expected env state at.entry)
7903− ?: ?=(%| -.value) value
7904− =/ fit=ifit (itype-fit typ.p.value expected sub.state.p.value next.state.p.value)
7905− ?: ?=(%unknown -.fit) [%| ["change field constraint is not supported by partial inference" ~]]
7907− [%| ["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)]]]]
7908− $(edits t.edits, state state.p.value(sub sub.fit, next next.fit), seen [name.entry seen])
7910−:: Backtick constructs the canonical prelude unit, after checking its
7911−:: prepared template has the standard null and [~ u=A] cases.
7912−++ standard-unit-template
7913− |= [template=ischeme at=path]
7915− ?. =(at /lib/jibb/prelude/jibb) |
7917− ?^ t.vars.template |
7918− =/ v=@ud i.vars.template
7919− =/ nil=itype [%const [%null %n 0 '~']]
7921− [%union ~[nil [%cell nil [%face %u [%var v]]]] `[at %unit] `%unit ~[[%var v]]]
7922− =(typ.template expected)
7924−:: A named missing-case diagnostic needs more than a failed fit: a case
7925−:: with that tag but the wrong payload is not a missing case. Unknown
7926−:: shapes and atom types that accept terms keep the proof conservative.
7927−+$ itag-presence ?(%yes %no %maybe)
7928−++ tag-presence-cases
7929− |= [cases=(list itype) value=@ sub=isub]
7932− =/ first=itag-presence (tag-presence i.cases value sub)
7933− ?: =(%yes first) %yes
7934− =/ rest=itag-presence $(cases t.cases)
7935− ?: =(%yes rest) %yes
7936− ?: |(=(%maybe first) =(%maybe rest)) %maybe
7940− |= [t=itype value=@ sub=isub]
7942− =. t (itype-walk t sub)
7944− %const ?:(=(value val.literal.t) %yes %no)
7945− %flag ?:(|(=(value 0) =(value 1)) %yes %no)
7946− %atom ?:(|(=(%tas aura.t) =(%ta aura.t)) %maybe %no)
7949− =/ first=itag-presence $(t hed.t)
7950− ?: =(%yes first) %yes
7951− =/ rest=itag-presence $(t tal.t)
7952− ?: =(%yes rest) %yes
7953− ?: |(=(%maybe first) =(%maybe rest)) %maybe
7955− %union (tag-presence-cases cases.t value sub)
7959−++ missing-union-tag
7960− |= [e=expr expected=itype sub=isub context=span]
7963− ?. =(%term form.lit.e) ~
7964− =. expected (itype-walk expected sub)
7966− ?: ?=(%face -.expected) $(expected (itype-walk body.expected sub))
7967− ?. ?=(%union -.expected) ~
7968− ?. =(%no (tag-presence-cases cases.expected val.lit.e sub)) ~
7970− ?~ label.expected "union {(show-itype expected sub)}"
7971− (show-itype expected sub)
7972− `["{label} has no case `{(trip txt.lit.e)}`" ~[[context "expected union"] [(span-of e) "tag"]]]
7974−:: Locate a missing tag inside a syntactic tuple only by replaying the
7975−:: directional fit in source order. Uncertain or earlier failures stop
7976−:: the walk, preserving the generic diagnostic rather than guessing.
7977−++ nested-missing-tag
7978− |= [e=expr actual=itype expected=itype sub=isub next=@ud context=span]
7980− =/ original=[left=itype right=itype] [actual expected]
7981− ?: |(?=(%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))) ~
7982− =/ fit=ifit (itype-fit actual expected sub next)
7983− ?. ?=(%bad -.fit) ~
7984− =. actual (itype-walk actual sub)
7985− =. expected (itype-walk expected sub)
7986− ?: &(?=(%face -.actual) ?=(%face -.expected))
7987− ?. =(name.actual name.expected) ~
7988− $(actual body.actual, expected body.expected)
7989− ?: ?=(%face -.actual) $(actual body.actual)
7990− ?: ?=(%face -.expected) $(expected body.expected)
7991− =/ direct=(unit idiag) (missing-union-tag e expected sub context)
7993− ?. ?=(%tuple -.e) ~
7994− (nested-missing-items items.e actual expected sub next context)
7996−++ nested-missing-items
7997− |= [items=(list item) actual=itype expected=itype sub=isub next=@ud context=span]
8000− ?~ t.items (nested-missing-tag val.i.items actual expected sub next context)
8001− =/ original=[left=itype right=itype] [actual expected]
8002− ?: |(?=(%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))) ~
8003− =. actual (itype-walk actual sub)
8004− =. expected (itype-walk expected sub)
8005− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8006− =/ first=ifit (itype-fit hed.actual hed.expected sub next)
8007− ?: ?=(%bad -.first)
8008− (nested-missing-tag val.i.items hed.actual hed.expected sub next context)
8009− ?. ?=(%ok -.first) ~
8010− $(items t.items, actual tal.actual, expected tal.expected, sub sub.first, next next.first)
8012−:: A term-headed pair is the same noun as a two-item cell. Preserve the
8013−:: whole pair span for the synthetic head and the value's own span for
8014−:: the payload; unresolved term constraints follow ordinary cell inference.
8019− =/ head=expr [%lit at.e [%term %tas tag.e (crip ['%' (trip tag.e)])]]
8020− [%tuple at.e ~[[at.e ~ head] [(span-of val.e) ~ val.e]]]
8022−:: A segment costs one shared step; dynamic segments are not handled yet.
8024− |= [segs=(list qseg) fuel=@ud]
8028− ?. ?=(%knot -.i.segs) ~
8029− $(segs t.segs, fuel (dec fuel))
8031++ infer-fragment
5733++ infer-fragment
8032 |= [e=expr env=ienv state=istate]
5734 |= [e=expr env=ienv state=istate]
8033 ^- iresult
5735 ^- iresult
8035− %pair $(e (pair-as-cell e))
8037 ?- form.lit.e
5738 ?- form.lit.e
8038 %number ?: =(%ud aura.lit.e)
5739 %number ?: =(%ud aura.lit.e)
@@ -8043,48 +5744,13 @@
8043 %duration [%& [%atom %dr] state]
5744 %duration [%& [%atom %dr] state]
8044 %knot [%& [%atom %ta] state]
5745 %knot [%& [%atom %ta] state]
8045 %loobean [%& [%flag ~] state]
5746 %loobean [%& [%flag ~] state]
8046− %term [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
5747+ %term [%& [%tag next.state lit.e |] state(next +(next.state), tags [next.state tags.state])]
8047− %null [%& [%tag next.state lit.e |] state(next +(next.state), tags [[next.state lit.e] tags.state])]
5748+ * [%| ["literal needs contextual inference" ~]]
8050− ?~ prelude.state [%| ["unit construction needs the standard prelude in partial inference" ~]]
5751+ =/ interpolated=? (lien pieces.e |=(p=piece ?=(%expr -.p)))
8051− =/ standard=(unit ischeme) (find-jibb-mold %unit u.prelude.state)
8052− ?~ standard [%| ["unit construction needs the standard prelude in partial inference" ~]]
8053− ?. (standard-unit-template u.standard at.u.prelude.state)
8054− [%| ["unit construction needs the standard prelude in partial inference" ~]]
8055− =/ value=iresult $(e val.e)
8056− ?: ?=(%| -.value) value
8057− =/ result=(unit itype) (template-apply u.standard ~[typ.p.value])
8058− ?~ result [%| ["unit construction is not supported by partial inference" ~]]
5752+ ?: interpolated [%| ["interpolation is not supported by partial inference" ~]]
8059− [%& u.result state.p.value]
5753+ [%& [%atom %t] state]
8061− ?~ prelude.state [%| ["list literal needs the standard prelude in partial inference" ~]]
8062− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
8063− [%| ["list literal needs the standard prelude in partial inference" ~]]
8064− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude.state)
8065− ?~ standard [%| ["list literal needs the standard prelude in partial inference" ~]]
8066− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]])
8067− [%| ["list literal needs the standard prelude in partial inference" ~]]
8068− =/ element=itype [%var next.state]
8069− =/ result=iresult (infer-open-list-items items.e element env state(next +(next.state)) at.e)
8070− ?: ?=(%| -.result) result
8071− [%& [%collection %list ~[element]] state.p.result]
8072− %str (infer-string-pieces pieces.e env state)
8074− ?~ prelude.state [%| ["application path needs the standard prelude in partial inference" ~]]
8075− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb)
8076− [%| ["application path needs the standard prelude in partial inference" ~]]
8077− =/ standard=(unit ischeme) (find-jibb-mold %qath u.prelude.state)
8078− ?~ standard [%| ["application path needs the standard prelude in partial inference" ~]]
8079− ?. ?=(~ vars.u.standard) [%| ["application path mold needs unsupported inference" ~]]
8080− =/ typ=itype typ.u.standard
8081− ?. ?=(%jrec -.typ) [%| ["application path mold needs unsupported inference" ~]]
8082− ?. &(=(at.typ /lib/jibb/internal/jibb) =(%qath name.typ) =(%i head.typ) =(%ta aura.typ) =(%t tail.typ))
8083− [%| ["application path mold needs unsupported inference" ~]]
8084− ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
8085− =/ remain=(unit @ud) (qath-static-fuel segs.e (dec jrec-fuel.state))
8086− ?~ remain [%| ["application path segments need unsupported inference" ~]]
8087− [%& typ state(jrec-fuel u.remain)]
8089 ?~ names.e [%| ["empty wing" ~]]
5755 ?~ names.e [%| ["empty wing" ~]]
8090 ?^ t.names.e
5756 ?^ t.names.e
@@ -8093,25 +5759,14 @@
8093 ?~ iface (infer-field-wing names.e env state)
5759 ?~ iface (infer-field-wing names.e env state)
8094 =/ member=(unit ischeme) (ienv-lookup i.names.e values.u.iface)
5760 =/ member=(unit ischeme) (ienv-lookup i.names.e values.u.iface)
8095 ?~ member [%| ["module member is not available to partial inference" ~]]
5761 ?~ member [%| ["module member is not available to partial inference" ~]]
8096− =. typ.u.member (itype-in-import typ.u.member u.iface i.t.names.e prelude.state)
8097 =/ instance=[typ=itype state=istate] (instantiate-scheme u.member state)
5762 =/ instance=[typ=itype state=istate] (instantiate-scheme u.member state)
8098 [%& typ.instance state.instance]
5763 [%& typ.instance state.instance]
8099 =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
5764 =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
8101− ?~ prelude.state [%| ["name is not available to partial inference" ~]]
5765+ ?~ scheme [%| ["name is not available to partial inference" ~]]
8102− =/ prelude-entry=(unit ischeme) (ienv-lookup i.names.e values.u.prelude.state)
8103− ?~ prelude-entry [%| ["name is not available to partial inference" ~]]
8104− =/ inst=[typ=itype state=istate] (instantiate-scheme u.prelude-entry state)
8105− [%& typ.inst state.inst]
8106 =/ instance=[typ=itype state=istate] (instantiate-scheme u.scheme state)
5766 =/ instance=[typ=itype state=istate] (instantiate-scheme u.scheme state)
8107 [%& typ.instance state.instance]
5767 [%& typ.instance state.instance]
8108 %group $(e inner.e)
5768 %group $(e inner.e)
8110− ?~ edits.e [%| ["a change takes at least one field" ~[[at.e "empty change"]]]]
8111− =/ target=iresult $(e [%wing at.e target.e])
8112− ?: ?=(%| -.target) target
8113− (infer-change-edits edits.e typ.p.target env state.p.target ~)
8114− %ctor [%& [%tag next.state tag.e &] state(next +(next.state), tags [[next.state tag.e] tags.state])]
5769+ %ctor [%& [%tag next.state tag.e &] state(next +(next.state), tags [next.state tags.state])]
8116 =/ traced=iresult $(e val.e)
5771 =/ traced=iresult $(e val.e)
8117 ?: ?=(%| -.traced) traced
5772 ?: ?=(%| -.traced) traced
@@ -8127,9 +5782,6 @@
8127 [%| ["local molds shadow a name" ~]]
5782 [%| ["local molds shadow a name" ~]]
8128 =/ local-state=istate
5783 =/ local-state=istate
8129 state(globals (weld local-names globals.state), molds (weld local-molds molds.state))
5784 state(globals (weld local-names globals.state), molds (weld local-molds molds.state))
8130− =/ mold-hole=(unit span) (simple-local-mold-hole defs.e)
8132− [%| ["type hole needs a determined type" ~[[u.mold-hole "unresolved type hole"]]]]
8133 ?. (local-molds-supported local-molds local-state)
5785 ?. (local-molds-supported local-molds local-state)
8134 [%| ["local molds need unsupported inference" ~]]
5786 [%| ["local molds need unsupported inference" ~]]
8135 =/ values=(list def) (local-value-defs defs.e)
5787 =/ values=(list def) (local-value-defs defs.e)
@@ -8140,30 +5792,18 @@
8140 [%& typ.p.result state.p.result(globals globals.state, molds molds.state)]
5792 [%& typ.p.result state.p.result(globals globals.state, molds molds.state)]
8142 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
5794 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
8144− ?: (single-structured-pattern e) (infer-single-case-branch e env state ~)
8145− (infer-cell-branch e env state ~)
5795+ ?~ t.arms.e (infer-cell-branch e env state)
8146− ?^ t.t.arms.e (infer-known-union-branch e env state)
5796+ ?^ t.t.arms.e [%| ["branch is not supported by partial inference" ~]]
8147− =/ known=(unit iresult) (known-union-subject subject.e env state)
8148− ?: &(?=(^ known) ?=(%| -.u.known) !(duplicate-loobean-arms e)) u.known
8149− ?: &(?=(^ known) ?=(%& -.u.known) ?=(~ (unit-union-payload (itype-normalize typ.p.u.known sub.state.p.u.known))))
8150− (infer-known-union-branch-subject e env u.known)
8151 =/ x=arm i.arms.e
5797 =/ x=arm i.arms.e
8152 =/ y=arm i.t.arms.e
5798 =/ y=arm i.t.arms.e
8153− ?: |((unit-empty-pattern pat.x) (unit-empty-pattern pat.y))
5799+ ?. ?=(%lit -.pat.x) [%| ["branch pattern is not supported by partial inference" ~]]
8154− (infer-unit-branch e env state ~)
5800+ ?. ?=(%lit -.pat.y) [%| ["branch pattern is not supported by partial inference" ~]]
8155− ?. ?=(%lit -.pat.x) (infer-known-union-branch e env state)
8156− ?. ?=(%lit -.pat.y) (infer-known-union-branch e env state)
8157 ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y))
5801 ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y))
8158− (infer-known-union-branch e env state)
5802+ [%| ["branch pattern is not supported by partial inference" ~]]
8159− ?: &(?=(^ known) ?=(%& -.u.known)) (infer-known-union-branch-subject e env u.known)
8160 ?: =(val.lit.pat.x val.lit.pat.y)
5803 ?: =(val.lit.pat.x val.lit.pat.y)
8161 [%| ["branch does not cover both loobeans" ~]]
5804 [%| ["branch does not cover both loobeans" ~]]
8162 =/ subject=iresult $(e subject.e)
5805 =/ subject=iresult $(e subject.e)
8163 ?: ?=(%| -.subject) subject
5806 ?: ?=(%| -.subject) subject
8164− =/ subject-type=itype (itype-normalize typ.p.subject sub.state.p.subject)
8165− ?: ?=(%union -.subject-type)
8166− [%| ["union-pattern branch subject is not supported by partial inference" ~]]
8167 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
5807 =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
8168 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
5808 ?~ su [%| ["loobean branch subject does not unify with ?" ~]]
8169 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
5809 =/ left=iresult $(e val.x, state state.p.subject(sub u.su))
@@ -8176,8 +5816,6 @@
8176 [%| ["branch widening is not supported by partial inference" ~]]
5816 [%| ["branch widening is not supported by partial inference" ~]]
8177 =/ joined=(unit isub) (itype-unify typ.p.left typ.p.right sub.state.p.right)
5817 =/ joined=(unit isub) (itype-unify typ.p.left typ.p.right sub.state.p.right)
8178 ?~ joined
5818 ?~ joined
8179− ?: |((itype-has-recursive ltype) (itype-has-recursive rtype))
8180− [%| ["recursive branch matching is not supported by partial inference" ~]]
8181 ?: |((itype-has-tag ltype) (itype-has-tag rtype) (itype-has-union ltype) (itype-has-union rtype))
5819 ?: |((itype-has-tag ltype) (itype-has-tag rtype) (itype-has-union ltype) (itype-has-union rtype))
8182 [%| ["branch tag or union context is not supported by partial inference" ~]]
5820 [%| ["branch tag or union context is not supported by partial inference" ~]]
8183 =/ common=(unit itype) (itype-concrete-join typ.p.left typ.p.right sub.state.p.right)
5821 =/ common=(unit itype) (itype-concrete-join typ.p.left typ.p.right sub.state.p.right)
@@ -8190,509 +5828,53 @@
8190 [%& typ.p.left state.p.right(sub u.joined)]
5828 [%& typ.p.left state.p.right(sub u.joined)]
8192 =/ target=(unit [typ=itype state=istate]) (infer-simple-shape shape.e state)
5830 =/ target=(unit [typ=itype state=istate]) (infer-simple-shape shape.e state)
8194− =/ diag=(unit idiag) (nested-import-invalid shape.e state)
8195− ?^ diag [%| u.diag]
8196− [%| ["cast mold is not supported by partial inference" ~]]
5831+ ?~ target [%| ["cast mold is not supported by partial inference" ~]]
8197− =/ value=iresult
5832+ =/ value=iresult $(e val.e, state state.u.target)
8198− (infer-call-context-arg val.e typ.u.target env state.u.target at.shape.e)
8199 ?: ?=(%| -.value) value
5833 ?: ?=(%| -.value) value
8200− =/ shape=(unit [source=iwfields target=iwfields])
8201− (width-shape typ.p.value typ.u.target sub.state.p.value)
8202− ?^ shape [%| ["record width constraint needs unsupported inference" ~]]
8203 =/ fit=ifit (itype-fit typ.p.value typ.u.target sub.state.p.value next.state.p.value)
5834 =/ fit=ifit (itype-fit typ.p.value typ.u.target sub.state.p.value next.state.p.value)
8204 ?: ?=(%unknown -.fit) [%| ["cast constraint is not supported by partial inference" ~]]
5835 ?: ?=(%unknown -.fit) [%| ["cast constraint is not supported by partial inference" ~]]
8205 ?: ?=(%bad -.fit)
5836 ?: ?=(%bad -.fit)
8206− =/ missing=(unit idiag) (missing-union-tag val.e typ.u.target sub.state.p.value at.shape.e)
8207− ?^ missing [%| u.missing]
8208− =/ 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)
8209− ?^ nested [%| u.nested]
8210 [%| ["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)]]]]
5837 [%| ["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)]]]]
8211 =/ merged=itype (itype-merge-faces typ.p.value typ.u.target sub.fit)
5838 =/ merged=itype (itype-merge-faces typ.p.value typ.u.target sub.fit)
8212 [%& merged state.p.value(sub sub.fit, next next.fit)]
5839 [%& merged state.p.value(sub sub.fit, next next.fit)]
8213 %crash [%& [%var next.state] state(next +(next.state))]
5840 %crash [%& [%var next.state] state(next +(next.state))]
8215 =/ sam=isample-result (infer-sample sample.e env state)
5842 =/ sam=isample-result (infer-sample sample.e env state)
8217− =/ diag=(unit idiag) (sample-import-invalid sample.e env state)
8218− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
8219− [%| [p.sam ~]]
5843+ ?: ?=(%| -.sam) [%| [p.sam ~]]
8220 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
5844 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
8221 ?: ?=(%| -.body) body
5845 ?: ?=(%| -.body) body
8222 [%& [%fn typ.p.sam typ.p.body] state.p.body]
5846 [%& [%fn typ.p.sam typ.p.body] state.p.body]
8223 %gate-wide
5847 %gate-wide
8224 =/ sam=isample-result (infer-sample sample.e env state)
5848 =/ sam=isample-result (infer-sample sample.e env state)
8226− =/ diag=(unit idiag) (sample-import-invalid sample.e env state)
8227− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
8228− [%| [p.sam ~]]
5849+ ?: ?=(%| -.sam) [%| [p.sam ~]]
8229 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
5850 =/ body=iresult $(e body.e, env env.p.sam, state state.p.sam)
8230 ?: ?=(%| -.body) body
5851 ?: ?=(%| -.body) body
8231 [%& [%fn typ.p.sam typ.p.body] state.p.body]
5852 [%& [%fn typ.p.sam typ.p.body] state.p.body]
8233 ?~ args.e [%| ["call has no argument" ~]]
5854 ?~ args.e [%| ["call has no argument" ~]]
8234− ?: (explicit-proj-call e env state)
5855+ ?^ t.args.e [%| ["multiple arguments are not supported by partial inference" ~]]
8235− [%| ["proj needs an expected record type" ~]]
5856+ =/ head=iresult $(e head.e)
8236− (infer-call-with-head e env state (infer-fragment head.e env state))
5857+ ?: ?=(%| -.head) head
5858+ =/ arg=iresult $(e i.args.e, state state.p.head)
5859+ ?: ?=(%| -.arg) arg
5860+ =/ st=istate state.p.arg
5861+ =/ ht=itype (itype-walk typ.p.head sub.st)
5863+ =/ fit=ifit (itype-fit typ.p.arg sample.ht sub.st next.st)
5864+ ?: ?=(%unknown -.fit) [%| ["call constraint is not supported by partial inference" ~]]
5866+ [%| ["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)]]]]
5867+ ?: &((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))
5868+ [%| ["call result face propagation is not supported by partial inference" ~]]
5869+ [%& product.ht st(sub sub.fit, next next.fit)]
5870+ =/ result=itype [%var next.st]
5871+ =/ uni=(unit isub) (itype-unify ht [%fn typ.p.arg result] sub.st)
5873+ [%| ["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)]]]]
5874+ [%& result st(next +(next.st), sub u.uni)]
8237 * [%| ["expression is not supported by partial inference" ~]]
5875 * [%| ["expression is not supported by partial inference" ~]]
8240−:: Locate a definite failing argument after the complete sample fit has
8241−:: failed. If an intermediate fit is uncertain, retain the whole argument
8242−:: span rather than assigning blame to a particular argument.
8244−:: Check a call using the head already inferred in this state. Keeping
8245−:: this shared avoids evaluating or instantiating a contextual head twice.
8246−++ width-has-projections
8247− |= ps=(list iwprojection)
8252−+$ iwidth-elaboration [original=expr typ=itype sub=isub projections=(list iwprojection)]
8253−++ infer-width-elaboration
8254− |= [e=expr env=ienv state=istate]
8255− ^- (each iwidth-elaboration idiag)
8256− =/ out=iresult (infer-fragment e env state)
8257− ?: ?=(%| -.out) [%| p.out]
8258− [%& [e typ.p.out sub.state.p.out (flop projections.state.p.out)]]
8260−++ infer-call-with-head
8261− |= [e=expr env=ienv state=istate head=iresult]
8264− ?~ args.e [%| ["call has no argument" ~]]
8265− ?: ?=(%| -.head) head
8266− =/ head-type=itype (itype-walk typ.p.head sub.state.p.head)
8269− ?: ?=(%fn -.head-type)
8270− (infer-call-context-args args.e sample.head-type env state.p.head (span-of head.e))
8271− (infer-simple-items (turn args.e |=(a=expr [(span-of a) ~ a])) env state.p.head)
8272− ?: ?=(%fn -.head-type)
8273− (infer-call-context-arg i.args.e sample.head-type env state.p.head (span-of head.e))
8274− (infer-fragment i.args.e env state.p.head)
8275− ?: ?=(%| -.arg) arg
8276− =/ st=istate state.p.arg
8277− =/ ht=itype (itype-walk typ.p.head sub.st)
8279− =/ shape=(unit [source=iwfields target=iwfields])
8281− (width-shape typ.p.arg sample.ht sub.st)
8282− ?^ shape [%| ["record width constraint needs unsupported inference" ~]]
8284− ?^ t.args.e (itype-fit-inner typ.p.arg sample.ht sub.st next.st & |)
8285− (itype-fit typ.p.arg sample.ht sub.st next.st)
8286− ?: ?=(%unknown -.fit) [%| ["call constraint is not supported by partial inference" ~]]
8289− =/ missing=(unit idiag) (missing-union-tag i.args.e sample.ht sub.st (span-of head.e))
8290− ?^ missing [%| u.missing]
8291− =/ nested=(unit idiag) (nested-missing-tag i.args.e typ.p.arg sample.ht sub.st next.st (span-of head.e))
8292− ?^ nested [%| u.nested]
8293− [%| ["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)]]]]
8294− =/ bad=(unit [at=span typ=itype])
8295− (call-error-site args.e typ.p.arg sample.ht sub.st next.st)
8297− [beg:(span-of i.args.e) end:(span-of (rear args.e))]
8298− =/ arg-at=span ?~(bad whole-args at.u.bad)
8299− =/ arg-type=itype ?~(bad typ.p.arg typ.u.bad)
8300− [%| ["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)]]]]
8302− ?^ t.args.e (itype-positional-face-asym args.e typ.p.arg sample.ht sub.fit)
8303− (itype-face-asym typ.p.arg sample.ht sub.fit)
8304− ?: &((itype-has-face typ.p.arg sub.fit) face-asym (itype-output-may-be-cell product.ht sub.fit))
8305− [%| ["call result face propagation is not supported by partial inference" ~]]
8306− [%& product.ht st(sub sub.fit, next next.fit)]
8307− =/ result=itype [%var next.st]
8308− =/ uni=(unit isub) (itype-unify ht [%fn typ.p.arg result] sub.st)
8310− [%| ["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)]]]]
8311− [%& result st(next +(next.st), sub u.uni)]
8314− |= [args=(list expr) actual=itype expected=itype sub=isub next=@ud]
8315− ^- (unit [at=span typ=itype])
8317− =/ original=[left=itype right=itype] [actual expected]
8318− ?: |(?=(%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))) ~
8319− =. actual (itype-walk actual sub)
8320− =. expected (itype-walk expected sub)
8321− ?: &(?=(%face -.expected) !?=(%face -.actual))
8322− $(expected body.expected)
8324− =/ fit=ifit (itype-fit actual expected sub next)
8325− ?. ?=(%bad -.fit) ~
8326− `[(span-of i.args) (itype-normalize actual sub)]
8327− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8328− =/ first=ifit (itype-fit hed.actual hed.expected sub next)
8329− ?: ?=(%bad -.first) `[(span-of i.args) (itype-normalize hed.actual sub)]
8330− ?: ?=(%unknown -.first) ~
8331− $(args t.args, actual tal.actual, expected tal.expected, sub sub.first, next next.first)
8333−:: Context can help a call argument or cast value while the final fit
8334−:: checks the complete right-nested type, including any written faces.
8336−:: Context can resolve the payload of a canonical prelude unit, but an
8337−:: unrelated union with a similar noun shape is not the same mold.
8338−++ infer-unit-context
8339− |= [e=expr expected=itype env=ienv state=istate context=span]
8342− ?> ?=(%union -.expected)
8343− ?~ prelude.state (infer-fragment e env state)
8344− =/ standard=(unit ischeme) (find-jibb-mold %unit u.prelude.state)
8345− ?~ standard (infer-fragment e env state)
8346− ?. (standard-unit-template u.standard at.u.prelude.state) (infer-fragment e env state)
8347− ?. =(origin.expected `[at.u.prelude.state %unit]) (infer-fragment e env state)
8348− ?~ args.expected (infer-fragment e env state)
8349− ?^ t.args.expected (infer-fragment e env state)
8350− =/ payload=itype i.args.expected
8351− =/ canonical=(unit itype) (template-apply u.standard ~[payload])
8352− ?~ canonical (infer-fragment e env state)
8353− ?> ?=(%union -.u.canonical)
8354− ?. =((itype-normalize expected(label ~) sub.state) (itype-normalize u.canonical(label ~) sub.state))
8355− (infer-fragment e env state)
8356− =/ value=iresult (infer-call-context-arg val.e payload env state context)
8357− ?: ?=(%| -.value) value
8358− =/ fit=ifit (itype-fit typ.p.value payload sub.state.p.value next.state.p.value)
8359− ?: ?=(%unknown -.fit) [%| ["unit payload constraint is not supported by partial inference" ~]]
8361− =/ missing=(unit idiag) (missing-union-tag val.e payload sub.state.p.value context)
8362− ?^ missing [%| u.missing]
8363− =/ nested=(unit idiag) (nested-missing-tag val.e typ.p.value payload sub.state.p.value next.state.p.value context)
8364− ?^ nested [%| u.nested]
8365− [%| ["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)]]]]
8366− [%& expected state.p.value(sub sub.fit, next next.fit)]
8368−:: A known gate may receive an enclosing target before its argument is
8369−:: inferred when its result is open or a direct, matching named generic
8370−:: union. Opaque, recursive, tag-constrained and variable-bound union
8371−:: results keep the existing directional path.
8372−++ infer-contextual-call
8373− |= [e=expr expected=itype env=ienv state=istate]
8376− ?~ args.e [%| ["call has no argument" ~]]
8377− =/ head=iresult (infer-fragment head.e env state)
8378− ?: ?=(%| -.head) head
8379− =/ ht=itype (itype-walk typ.p.head sub.state.p.head)
8380− ?. ?=(%fn -.ht) (infer-call-with-head e env state head)
8381− =/ result=itype (itype-walk product.ht sub.state.p.head)
8383− ?: ?=(%var -.result) &
8384− :: A direct known generic union may receive the same nominal result
8385− :: context before its arguments are checked. Variable-bound origins,
8386− :: pending tags, recursive identities and unknown atoms stay open.
8387− ?. &(?=(%union -.product.ht) ?=(%union -.result) ?=(%union -.expected)) |
8389− ?. =(origin.result origin.expected) |
8391− ?. =((lent args.result) (lent args.expected)) |
8392− ?: |((itype-has-tag (itype-normalize result sub.state.p.head)) (itype-has-tag (itype-normalize expected sub.state.p.head))) |
8393− ?: |((itype-has-recursive (itype-normalize result sub.state.p.head)) (itype-has-recursive (itype-normalize expected sub.state.p.head))) |
8394− ?: |((itype-has-any-atom result sub.state.p.head) (itype-has-any-atom expected sub.state.p.head)) |
8396− ?. eligible (infer-call-with-head e env state head)
8397− ?: |(?=(%var -.expected) ?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected)) (itype-has-tag (itype-normalize expected sub.state.p.head)))
8398− (infer-call-with-head e env state head)
8399− =/ sub=(unit isub) (itype-unify result expected sub.state.p.head)
8400− ?~ sub (infer-call-with-head e env state head)
8401− (infer-call-with-head e env state [%& typ.p.head state.p.head(sub u.sub)])
8403−:: An eligible fully faced literal receives context by name, in source order.
8404−++ width-literal-fields
8405− |= [items=(list item) axis=@ud fuel=@ud]
8407− =/ order=(list iwfield) ~
8408− =/ index=(map term iwfield) *(map term iwfield)
8413− =/ at-axis=@ud ?~(t.items axis (mul 2 axis))
8414− =/ entry=iwfield [u.face.i.items at-axis [%noun ~]]
8415− ?: ?=(^ (~(get by index) name.entry)) ~
8416− =. index (~(put by index) name.entry entry)
8417− =. order [entry order]
8418− ?~ t.items `[(flop order) index]
8419− $(items t.items, axis +((mul 2 axis)), fuel (dec fuel))
8420−++ width-infer-items
8421− |= [items=(list item) expected=(map term iwfield) env=ienv state=istate context=span]
8423− ?~ items [%| ["empty record is not supported" ~]]
8424− ?~ face.i.items [%| ["record face needs unsupported inference" ~]]
8425− =/ field=(unit iwfield) (~(get by expected) u.face.i.items)
8427− ?~ field (infer-fragment val.i.items env state)
8428− (infer-call-context-arg val.i.items typ.u.field env state context)
8429− ?: ?=(%| -.head) head
8430− =/ typ=itype [%face u.face.i.items typ.p.head]
8431− ?~ t.items [%& typ state.p.head]
8432− =/ tail=iresult $(items t.items, state state.p.head)
8433− ?: ?=(%| -.tail) tail
8434− [%& [%cell typ typ.p.tail] state.p.tail]
8435−++ width-infer-literal
8436− |= [e=expr expected=itype env=ienv state=istate context=span]
8438− ?. ?=(%tuple -.e) ~
8439− ?. |(?=(%cell -.expected) ?=(%face -.expected)) ~
8440− =/ source=(unit iwfields) (width-literal-fields items.e 1 4.096)
8441− =/ target=(unit iwfields) (width-scan expected sub.state 1 4.096)
8444− ?: (lth (lent order.u.source) (lent order.u.target)) ~
8445− ?. (width-in-order order.u.source order.u.target)
8446− `(infer-simple-items items.e env state)
8447− `(width-infer-items items.e index.u.target env state context)
8449−:: Experimental intrinsic recognition; real bindings retain normal calls.
8450−++ explicit-proj-call
8451− |= [e=expr env=ienv state=istate]
8454− ?. ?=([* ~] args.e) |
8455− ?. ?=(%wing -.head.e) |
8456− ?. =(names.head.e ~[%proj]) |
8457− ?: ?=(^ (ienv-lookup %proj env)) |
8458− ?: (lien globals.state |=(n=term =(n %proj))) |
8460− ?:(?=(^ (ienv-lookup %proj values.u.prelude.state)) | &)
8461−++ infer-proj-source
8462− |= [e=expr expected=itype env=ienv state=istate context=span]
8464− ?: ?=(%group -.e) $(e inner.e)
8465− =/ literal=(unit iresult) (width-infer-literal e expected env state context)
8466− ?^ literal u.literal
8467− (infer-fragment e env state)
8468−++ infer-proj-context
8469− |= [e=expr expected=itype env=ienv state=istate context=span]
8472− ?~ args.e [%| ["proj needs one record" ~]]
8473− ?. |(?=(%cell -.expected) ?=(%face -.expected)) [%| ["proj needs an expected record type" ~]]
8474− =/ value=iresult (infer-proj-source i.args.e expected env state context)
8475− ?: ?=(%| -.value) value
8476− =/ shape=(unit [source=iwfields target=iwfields])
8477− (width-proj-shape typ.p.value expected sub.state.p.value)
8478− ?~ shape [%| ["proj needs a known record containing its expected fields" ~]]
8479− =/ project=(unit iwidth-result) (width-project u.shape sub.state.p.value next.state.p.value)
8480− ?~ project [%| ["proj constraint needs unsupported inference" ~]]
8481− =/ st=istate state.p.value(sub sub.u.project, next next.u.project)
8482− [%& expected st(projections [[at.e e typ.p.value expected steps.u.project] projections.st])]
8484−:: A known literal singleton in a direct union can contextualize a
8485−:: loobean literal of the same noun. Only explicit singleton and cell
8486−:: competitors are considered; opaque or variable cases stay unknown.
8487−++ explicit-singleton-in-union
8488− |= [t=itype noun=@]
8490− ?. ?=(%union -.t) |
8491− =/ cases=(list itype) cases.t
8496− ?: ?=(%cell -.c) $(cases t.cases)
8497− ?. ?=(%const -.c) |
8498− ?: =(noun val.literal.c)
8500− $(cases t.cases, found &)
8503−:: Select a written literal-headed case only when every competing case is
8504−:: also an explicit singleton-headed cell and exactly one matches. Opaque,
8505−:: variable-bound and differently shaped cases keep inference unchanged.
8506−:: This first slice supplies context to a directly called payload. Plain
8507−:: literal data and other expressions retain their existing inference path.
8508−++ contextual-atomic-arguments
8509− |= args=(list expr)
8512− ?. ?=(?(%lit %wing %ctor) -.i.args) |
8514−++ contextual-direct-payload-call
8517− ?: ?=(%group -.e) $(e inner.e)
8519− ?. ?=(%wing -.head.e) |
8521− (contextual-atomic-arguments args.e)
8523−:: A walked variable may have concealed a union inside a substituted
8524−:: structure before this arm was called. Decline in that case rather than
8525−:: deriving provenance from the already-walked type.
8526−++ contextual-simple-sub
8530− ?: ?=(?(%cell %face %fn %union %collection) -.val.i.sub) |
8533−++ contextual-direct-union
8536− ?: ?=(%face -.target) $(target body.target)
8537− ?=(%union -.target)
8538−++ contextual-tagged-case
8539− |= [target=itype tag=@ sub=isub]
8541− ?. ?=(%union -.target) ~
8542− =/ remaining=(list itype) cases.target
8543− =/ found=(unit itype) ~
8544− =/ seen=(set @) *(set @)
8547− =/ c=itype i.remaining
8549− =/ head=itype hed.c
8550− ?. ?=(%const -.head) ~
8551− ?: (~(has in:..zuse seen) val.literal.head) ~
8552− =. seen (~(put in:..zuse seen) val.literal.head)
8553− ?: =(tag val.literal.head)
8554− $(remaining t.remaining, found `c)
8555− $(remaining t.remaining)
8557−++ infer-call-context-arg
8558− |= [e=expr expected=itype env=ienv state=istate context=span]
8560− ?: ?=(%pair -.e) $(e (pair-as-cell e))
8561− ?: ?=(%group -.e) $(e inner.e)
8562− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
8564− =/ traced=iresult (infer-fragment val.e env state)
8565− ?: ?=(%| -.traced) traced
8566− $(e then.e, state state.p.traced)
8567− =/ target=itype (itype-walk expected sub.state)
8569− ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
8570− ?: (explicit-proj-call e env state)
8571− (infer-proj-context e expected env state context)
8572− :: Only the source-proven one-layer cell is exposed. Each recursive
8573− :: descent consumes one written tuple; named values use ordinary fit.
8574− ?: &(?=(%jrec -.target) ?=(%lit -.e) =(%null form.lit.e))
8575− ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
8576− [%& target state(jrec-fuel (dec jrec-fuel.state))]
8577− ?: &(?=(%jrec -.target) ?=(%tuple -.e))
8578− ?: =(0 jrec-fuel.state) [%| ["recursive mold unfolding needs unsupported inference" ~]]
8579− =. state state(jrec-fuel (dec jrec-fuel.state))
8581− [%cell [%face head.target [%atom aura.target]] [%face tail.target target]]
8582− =/ value=iresult (infer-call-context-items items.e shape env state context)
8583− ?: ?=(%| -.value) value
8584− =/ fit=ifit (itype-fit typ.p.value shape sub.state.p.value next.state.p.value)
8585− ?: ?=(%unknown -.fit) [%| ["recursive mold cell constraint needs unsupported inference" ~]]
8586− ?: ?=(%bad -.fit) [%| ["recursive mold cell does not fit its source shape" ~]]
8587− [%& target state.p.value(sub sub.fit, next next.fit)]
8588− ?: ?=(%call -.e) (infer-contextual-call e target env state)
8589− ?: (single-structured-pattern e)
8590− (infer-single-case-branch e env state `[target context])
8591− ?: (cell-binder-pattern e)
8592− (infer-cell-branch e env state `[target context])
8593− :: In an explicit singleton context retain the written loobean noun;
8594− :: the ordinary singleton fit compares its noun, not its spelling.
8595− =/ singleton=(unit itype)
8597− ?. =(%loobean form.lit.e) ~
8598− ?. |(?=(%const -.target) &(?=(%union -.expected) (explicit-singleton-in-union expected val.lit.e))) ~
8600− ?^ singleton [%& u.singleton state]
8601− =/ known=(unit iresult)
8602− ?: ?=(%branch -.e) (known-union-subject subject.e env state)
8604− ?: &(?=(^ known) ?=(%| -.u.known) !(duplicate-loobean-arms e)) u.known
8605− ?: &(?=(^ known) ?=(%& -.u.known) ?=(~ (unit-union-payload (itype-normalize typ.p.u.known sub.state.p.u.known))))
8606− (infer-known-union-context-subject e target env u.known context)
8607− ?: &(?=(%union -.target) ?=(%unit -.e))
8608− (infer-unit-context e target env state context)
8609− ?: &(?=(%flag -.target) (context-union-branch e))
8610− (infer-union-context e target env state context)
8611− ?: &(?=(%union -.target) (context-union-branch e))
8612− (infer-union-context e target env state context)
8613− ?: &(?=(%collection -.target) =(%list name.target) (context-union-branch e))
8614− (infer-union-context e target env state context)
8615− ?: &(?=(%collection -.target) =(%list name.target) (context-list-expression e))
8616− (infer-list-context e target env state context)
8617− :: A literal-headed tuple can receive the unique case's payload
8618− :: context. The ordinary final fit still checks the complete union.
8619− =/ selected=(unit itype)
8620− ?. &((contextual-simple-sub sub.state) (contextual-direct-union expected) ?=(%union -.target) ?=(%tuple -.e) ?=(^ items.e)) ~
8623− ?. (contextual-direct-payload-call val.i.t.items.e) ~
8624− =/ first=item i.items.e
8625− ?. &(?=(~ face.first) ?=(%lit -.val.first) |(=(%term form.lit.val.first) =(%null form.lit.val.first) =(%loobean form.lit.val.first))) ~
8626− (contextual-tagged-case target val.lit.val.first sub.state)
8629− :: On this bounded shallow-call shape, preserve any inference that
8630− :: already fits before trying the new contextual path. Neither pass
8631− :: can recursively select a nested tuple from the atomic arguments.
8632− =/ ordinary=(unit iresult)
8633− =/ initial=iresult (infer-fragment e env state)
8634− ?: ?=(%| -.initial) ~
8635− =/ fit=ifit (itype-fit typ.p.initial target sub.state.p.initial next.state.p.initial)
8638− ?^ ordinary u.ordinary
8639− =/ value=iresult (infer-call-context-items items.e u.selected env state context)
8640− ?: ?=(%| -.value) value
8641− =/ fit=ifit (itype-fit typ.p.value u.selected sub.state.p.value next.state.p.value)
8642− ?: ?=(%unknown -.fit) [%| ["tagged case needs unsupported inference" ~]]
8643− ?: ?=(%bad -.fit) [%| ["tagged case does not fit its expected type" ~[[context "expected union case"] [(span-of e) "value"]]]]
8644− [%& typ.p.value state.p.value(sub sub.fit, next next.fit)]
8645− ?: &(?=(%cell -.target) ?=(%tuple -.e))
8646− (infer-call-context-items items.e target env state context)
8647− (infer-fragment e env state)
8649−:: Preserve each written face; the final complete sample fit checks faces.
8650−:: A tuple or positional field face belongs to the enclosing sample,
8651−:: not to the expression at that position. A second face, if present,
8652−:: is part of the value's own expected type.
8653−++ projection-field-target
8656− ?:(?=(%face -.expected) body.expected expected)
8658−++ infer-call-context-items
8659− |= [items=(list item) expected=itype env=ienv state=istate context=span]
8661− ?~ items [%| ["empty cell is not supported by partial inference" ~]]
8663− =/ last=iresult (infer-call-context-arg val.i.items (projection-field-target expected) env state context)
8664− ?: ?=(%| -.last) last
8665− =/ typ=itype typ.p.last
8666− =. typ ?~(face.i.items typ [%face u.face.i.items typ])
8667− [%& typ state.p.last]
8668− =/ target=itype (itype-walk expected sub.state)
8670− ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
8671− ?. ?=(%cell -.target) (infer-simple-items items env state)
8672− =/ head=iresult (infer-call-context-arg val.i.items (projection-field-target hed.target) env state context)
8673− ?: ?=(%| -.head) head
8674− =/ typ=itype typ.p.head
8675− =. typ ?~(face.i.items typ [%face u.face.i.items typ])
8676− =/ tail=iresult (infer-call-context-items t.items tal.target env state.p.head context)
8677− ?: ?=(%| -.tail) tail
8678− [%& [%cell typ typ.p.tail] state.p.tail]
8680−++ infer-call-context-args
8681− |= [args=(list expr) expected=itype env=ienv state=istate context=span]
8683− ?~ args [%| ["call has no argument" ~]]
8684− ?~ t.args (infer-call-context-arg i.args (projection-field-target expected) env state context)
8685− =/ target=itype (itype-walk expected sub.state)
8687− ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
8688− ?. ?=(%cell -.target)
8689− (infer-simple-items (turn args |=(a=expr [(span-of a) ~ a])) env state)
8690− =/ head=iresult (infer-call-context-arg i.args (projection-field-target hed.target) env state context)
8691− ?: ?=(%| -.head) head
8692− =/ tail=iresult (infer-call-context-args t.args tal.target env state.p.head context)
8693− ?: ?=(%| -.tail) tail
8694− [%& [%cell typ.p.head typ.p.tail] state.p.tail]
8696:: Tuple and record expressions preserve their explicitly written faces.
5878:: Tuple and record expressions preserve their explicitly written faces.
8698++ infer-simple-items
5880++ infer-simple-items
@@ -8708,55 +5890,11 @@
8708 ?: ?=(%| -.tail) tail
5890 ?: ?=(%| -.tail) tail
8709 [%& [%cell ht typ.p.tail] state.p.tail]
5891 [%& [%cell ht typ.p.tail] state.p.tail]
8711−:: A single all-binder cell pattern covers a known cell spine; the final
5893+:: A single two-binder cell pattern covers every value of a cell type.
8712−:: binder captures the remaining noun. Other pattern matrices stay partial.
5894+:: No other pattern matrix is implemented here.
8714−:: Validate binders before reading the subject, preserving shadow-error
8715−:: precedence. The last binder receives the entire remaining tail.
8716−++ cell-pattern-names
8717− |= [pats=(list pattern) env=ienv globals=(list term) seen=(list term)]
8718− ^- (each (list term) @t)
8720− ?. ?=(%bind -.i.pats) [%| 'branch pattern is not supported by partial inference']
8721− =/ name=term name.i.pats
8722− ?: |(=(name %proj) ?=(^ (ienv-lookup name env)) (lien globals |=(n=term =(n name))) (lien seen |=(n=term =(n name))))
8723− [%| 'pattern shadows a name']
8724− =/ rest=(each (list term) @t) $(pats t.pats, seen [name seen])
8725− ?: ?=(%| -.rest) rest
8728−++ cell-pattern-types
8729− |= [names=(list term) env=ienv next=@ud]
8730− ^- [typ=itype env=ienv next=@ud]
8732− =/ head=itype [%var next]
8733− =/ scope=ienv [[i.names [head ~]] env]
8734− ?~ t.names [head scope +(next)]
8735− =/ tail=[typ=itype env=ienv next=@ud] $(names t.names, env scope, next +(next))
8736− [[%cell head typ.tail] env.tail next.tail]
8738−:: At every position that must be a cell, opaque or sum types may still
8739−:: contain cells. Do not report a definite mismatch without unfolding them.
8740−++ cell-pattern-spine-unknown
8741− |= [typ=itype names=(list term) sub=isub]
8745− =. typ (itype-walk typ sub)
8746− ?: ?=(%cell -.typ) $(typ tal.typ, names t.names)
8747− |(?=(%union -.typ) ?=(%collection -.typ) ?=(%recursive -.typ) ?=(%jrec -.typ) ?=(%noun -.typ) ?=(%fn -.typ) ?=(%tag -.typ))
8749−++ cell-binder-pattern
8752− ?. ?=(%branch -.e) |
8755− ?. ?=(%cell -.pat.i.arms.e) |
8756− !(single-structured-pattern e)
8758++ infer-cell-branch
5896++ infer-cell-branch
8759− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
5897+ |= [e=expr env=ienv state=istate]
8760 ^- iresult
5898 ^- iresult
8761 ?> ?=(%branch -.e)
5899 ?> ?=(%branch -.e)
8762 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
5900 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
@@ -8765,31 +5903,23 @@
8765 =/ pats=(list pattern) items.pat.arm
5903 =/ pats=(list pattern) items.pat.arm
8766 ?~ pats [%| ["branch pattern is not supported by partial inference" ~]]
5904 ?~ pats [%| ["branch pattern is not supported by partial inference" ~]]
8767 ?~ t.pats [%| ["branch pattern is not supported by partial inference" ~]]
5905 ?~ t.pats [%| ["branch pattern is not supported by partial inference" ~]]
8768− =/ names=(each (list term) @t) (cell-pattern-names pats env globals.state ~)
5906+ ?^ t.t.pats [%| ["branch pattern is not supported by partial inference" ~]]
8769− ?: ?=(%| -.names) [%| [(trip p.names) ~]]
5907+ ?. ?=(%bind -.i.pats) [%| ["branch pattern is not supported by partial inference" ~]]
5908+ ?. ?=(%bind -.i.t.pats) [%| ["branch pattern is not supported by partial inference" ~]]
5909+ =/ one=term name.i.pats
5910+ =/ two=term name.i.t.pats
5911+ ?: |(=(one two) ?=(^ (ienv-lookup one env)) ?=(^ (ienv-lookup two env)) (lien globals.state |=(x=term |(=(x one) =(x two)))))
5912+ [%| ["pattern shadows a name" ~]]
8770 =/ subject=iresult (infer-fragment subject.e env state)
5913 =/ subject=iresult (infer-fragment subject.e env state)
8771 ?: ?=(%| -.subject) subject
5914 ?: ?=(%| -.subject) subject
8772 =/ st=istate state.p.subject
5915 =/ st=istate state.p.subject
8773− =/ subject-type=itype (itype-normalize typ.p.subject sub.st)
8774− ?: (itype-has-recursive subject-type)
8775− [%| ["recursive pattern is not supported by partial inference" ~]]
8776 ?: (itype-has-face typ.p.subject sub.st)
5916 ?: (itype-has-face typ.p.subject sub.st)
8777 [%| ["record patterns are not supported by partial inference" ~]]
5917 [%| ["record patterns are not supported by partial inference" ~]]
8778− ?: (cell-pattern-spine-unknown subject-type p.names sub.st)
5918+ =/ head=itype [%var next.st]
8779− [%| ["cell pattern subject is not supported by partial inference" ~]]
5919+ =/ tail=itype [%var +(next.st)]
8780− =/ binders=[typ=itype env=ienv next=@ud] (cell-pattern-types p.names env next.st)
8781− =/ sub=(unit isub) (itype-unify typ.p.subject typ.binders sub.st)
5920+ =/ sub=(unit isub) (itype-unify typ.p.subject [%cell head tail] sub.st)
8782 ?~ sub [%| ["cell pattern does not match the subject type" ~]]
5921 ?~ sub [%| ["cell pattern does not match the subject type" ~]]
8783− =. st st(next next.binders, sub u.sub)
5922+ (infer-fragment val.arm [[one [head ~]] [two [tail ~]] env] st(next (add 2 next.st), sub u.sub))
8784− ?~ expected (infer-fragment val.arm env.binders st)
8785− =/ body=iresult (infer-call-context-arg val.arm typ.u.expected env.binders st context.u.expected)
8786− ?: ?=(%| -.body) body
8787− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
8788− ?: ?=(%unknown -.fit) [%| ["cell branch result constraint is not supported by partial inference" ~]]
8789− ?: ?=(%bad -.fit) [%| ["cell branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.arm) "branch arm"]]]]
8790− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
8791− [%| ["cell branch result needs context in partial inference" ~]]
8792− [%& typ.u.expected state.p.body(sub sub.fit, next next.fit)]
8794++ show-itype
5924++ show-itype
8795 |= [t=itype sub=isub]
5925 |= [t=itype sub=isub]
@@ -8802,30 +5932,17 @@
8803 ?: (lth id.t 26) [(add 65 id.t) ~]
5933 ?: (lth id.t 26) [(add 65 id.t) ~]
8804 "T{<id.t>}"
5934 "T{<id.t>}"
8806− ?: (lth id.t 26) [(add 65 id.t) ~]
8809 ?: (lth id.t 26) [(add 65 id.t) ~]
5936 ?: (lth id.t 26) [(add 65 id.t) ~]
8810 "T{<id.t>}"
5937 "T{<id.t>}"
8812− ?: (lth id.t 26) [(add 65 id.t) ~]
8814 %atom "@{(trip aura.t)}"
5938 %atom "@{(trip aura.t)}"
8815 %any-atom "@"
5939 %any-atom "@"
8816 %flag "?"
5940 %flag "?"
8818 %tag (trip txt.literal.t)
5941 %tag (trip txt.literal.t)
8819 %const (trip txt.literal.t)
5942 %const (trip txt.literal.t)
8820− %union
5943+ %union "<union>"
8821− ?~ label.t (show-itype-cases cases.t sub)
8822− ?~ args.t (trip u.label.t)
8823− "({(trip u.label.t)} {(show-itype-cases args.t sub)})"
8824− %recursive ?~(label.t "recursive mold" (trip u.label.t))
8825− %jrec ?~(label.t "recursive mold" (trip u.label.t))
8826− %collection "({(trip name.t)} {(show-itype-cases args.t sub)})"
8827− %face "[{(trip name.t)}={(show-itype-context body.t sub)}]"
5944+ %face "[{(trip name.t)}={$(t body.t)}]"
8828− %fn "$-({(show-itype-context sample.t sub)} {(show-itype-context product.t sub)})"
5945+ %fn "$-({$(t sample.t)} {$(t product.t)})"
8829 %cell "[{(show-itype-item hed.t sub)} {(show-itype-item tal.t sub)}]"
5946 %cell "[{(show-itype-item hed.t sub)} {(show-itype-item tal.t sub)}]"
@@ -8833,23 +5950,9 @@
8833 |= [t=itype sub=isub]
5950 |= [t=itype sub=isub]
8835 =. t (itype-walk t sub)
5952 =. t (itype-walk t sub)
8836− ?: ?=(%face -.t) "{(trip name.t)}={(show-itype-context body.t sub)}"
5953+ ?: ?=(%face -.t) "{(trip name.t)}={(show-itype body.t sub)}"
8837− (show-itype-context t sub)
8839−++ show-itype-context
8840− |= [t=itype sub=isub]
8842− =. t (itype-walk t sub)
8843− ?: &(?=(%union -.t) ?=(~ label.t)) "({(show-itype t sub)})"
8844 (show-itype t sub)
5954 (show-itype t sub)
8847− |= [cases=(list itype) sub=isub]
8850− ?~ t.cases (show-itype-context i.cases sub)
8851− "{(show-itype-context i.cases sub)} {$(cases t.cases)}"
8853:: Include the type at a conflicting site where it can be printed.
5956:: Include the type at a conflicting site where it can be printed.
8854:: A lone unresolved variable or decimal variable keeps the neutral label.
5957:: A lone unresolved variable or decimal variable keeps the neutral label.
@@ -8858,20 +5961,14 @@
8859 ?- -.typ
5962 ?- -.typ
8866 %any-atom |
5967 %any-atom |
8870 %const |
5970 %const |
8871− %union |((lien cases.typ |=(c=itype (itype-has-nvar c))) (lien args.typ |=(c=itype (itype-has-nvar c))))
5971+ %union (lien cases.typ |=(c=itype (itype-has-nvar c)))
8874− %collection (lien args.typ |=(c=itype (itype-has-nvar c)))
8875 %face $(typ body.typ)
5972 %face $(typ body.typ)
8876 %fn |($(typ sample.typ) $(typ product.typ))
5973 %fn |($(typ sample.typ) $(typ product.typ))
8877 %cell |($(typ hed.typ) $(typ tal.typ))
5974 %cell |($(typ hed.typ) $(typ tal.typ))
@@ -8881,8 +5978,7 @@
8881 |= [label=tape typ=itype sub=isub]
5978 |= [label=tape typ=itype sub=isub]
8883 =/ normalized=itype (itype-normalize typ sub)
5980 =/ normalized=itype (itype-normalize typ sub)
8884− ?: |(?=(%var -.normalized) ?=(%avar -.normalized) ?=(%rvar -.normalized) (itype-has-nvar normalized) (itype-has-tag normalized) (itype-has-union normalized)) label
5981+ ?: |(?=(%var -.normalized) ?=(%avar -.normalized) (itype-has-nvar normalized) (itype-has-tag normalized) (itype-has-union normalized)) label
8885− ?: (itype-has-hidden-recursive normalized) label
8886 =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
5982 =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
8887 ?: (gth (lent vars) 26) label
5983 ?: (gth (lent vars) 26) label
8888 =/ printable=itype (canonical-itype normalized vars)
5984 =/ printable=itype (canonical-itype normalized vars)
@@ -8891,68 +5987,13 @@
8891:: A capital in a written mold is generalized with its enclosing ++.
5987:: A capital in a written mold is generalized with its enclosing ++.
8892:: Atom constraints may remain generic; until full rigidity checking
5988:: Atom constraints may remain generic; until full rigidity checking
8893:: is implemented, do not report a type if one became more specific.
5989:: is implemented, do not report a type if one became more specific.
8894−:: Distinct written capitals cannot be forced equal; use the same
8895−:: capital where a type must be shared (Decisions 2026-10-30).
8898− |= [n=@ud caps=icaps sub=isub]
8901− =/ resolved=itype (itype-walk [%var id.i.caps] sub)
8902− =/ ident=(unit @ud)
8908− ?~ ident $(caps t.caps)
8913− |= [n=@ud caps=icaps sub=isub]
8916− =/ resolved=itype (itype-walk [%var id.i.caps] sub)
8917− =/ ident=(unit @ud)
8923− ?~ ident $(caps t.caps)
8924− ?: =(n u.ident) `i.caps
8928− |= [caps=icaps sub=isub]
8929− ^- (unit [first=icap second=icap])
8931− =/ resolved=itype (itype-walk [%var id.i.caps] sub)
8932− =/ ident=(unit @ud)
8938− ?~ ident $(caps t.caps)
8939− =/ found=(unit icap) (cap-with-id u.ident t.caps sub)
8940− ?^ found `[u.found i.caps]
8943++ constrained-capitals
5991++ constrained-capitals
8944 |= [caps=icaps sub=isub]
5992 |= [caps=icaps sub=isub]
8946 ?~ caps |
5994 ?~ caps |
8947 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
5995 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
8948− =/ ident=(unit @ud)
8950− %var `id.resolved
5996+ ?. |(?=(%var -.resolved) ?=(%avar -.resolved)) &
8955− ?: (cap-id-in u.ident t.caps sub) &
8956 $(caps t.caps)
5997 $(caps t.caps)
8958:: An atom variable may be generalized when an explicit capital, sample
5999:: An atom variable may be generalized when an explicit capital, sample
@@ -8964,8 +6005,8 @@
8965 ?~ caps |
6006 ?~ caps |
8966 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
6007 =/ resolved=itype (itype-walk [%var id.i.caps] sub)
8967− ?: |(?=(%avar -.resolved) ?=(%rvar -.resolved))
6008+ ?: ?=(%avar -.resolved)
8968− ?: =(n +.resolved) &
6009+ ?: =(n id.resolved) &
8969 $(caps t.caps)
6010 $(caps t.caps)
8970 $(caps t.caps)
6011 $(caps t.caps)
@@ -8975,19 +6016,13 @@
8977 %avar =(n id.t)
6018 %avar =(n id.t)
8982 %any-atom |
6021 %any-atom |
8986 %const |
6024 %const |
8987− %union |((lien cases.t |=(c=itype (has-atom-var n c))) (lien args.t |=(c=itype (has-atom-var n c))))
6025+ %union (lien cases.t |=(c=itype (has-atom-var n c)))
8990− %collection (lien args.t |=(c=itype (has-atom-var n c)))
8991 %face $(t body.t)
6026 %face $(t body.t)
8992 %fn |($(t sample.t) $(t product.t))
6027 %fn |($(t sample.t) $(t product.t))
8993 %cell |($(t hed.t) $(t tal.t))
6028 %cell |($(t hed.t) $(t tal.t))
@@ -9026,10 +6061,6 @@
9026 =/ out=tape ""
6061 =/ out=tape ""
9028 ?~ vars out
6063 ?~ vars out
9029− ?: (itype-var-is-restricted i.vars t)
9030− =/ sep=tape ?:(printed ", " " where ")
9031− =/ clause=tape "{sep}{(show-itype [%rvar i.vars] ~)} is an atom other than ?"
9032− $(vars t.vars, printed &, out (weld out clause))
9033 ?: (itype-var-is-atom i.vars t)
6064 ?: (itype-var-is-atom i.vars t)
9034 =/ sep=tape ?:(printed ", " " where ")
6065 =/ sep=tape ?:(printed ", " " where ")
9035 =/ clause=tape "{sep}{(show-itype [%avar i.vars] ~)} is an atom"
6066 =/ clause=tape "{sep}{(show-itype [%avar i.vars] ~)} is an atom"
@@ -9038,9 +6069,9 @@
9039:: Build the supported part of the value environment in dependency order.
6070:: Build the supported part of the value environment in dependency order.
9040:: Each pass adds successful definitions. Forward references become
6071:: Each pass adds successful definitions. Forward references become
9041−:: available on a later pass; unsupported syntax does not enter the
6072+:: available on a later pass; recursive groups and unsupported syntax do
9042−:: environment. Generalized definitions are closed, so a use instantiates
6073+:: not enter the environment. Generalized definitions are closed, so a
9043−:: its variables afresh.
6074+:: use instantiates its variables afresh.
9045++ global-value-names
6076++ global-value-names
9046 |= ds=(list def)
6077 |= ds=(list def)
@@ -9058,619 +6089,32 @@
9058 ?~ t.hits &
6089 ?~ t.hits &
9061−:: A top-level gate may refer to itself through one monomorphic placeholder.
9062−:: Its declared sample is inferred first and preserves its field faces.
9063−:: Unify the completed body with that placeholder before generalization;
9064−:: reporting repeats the same check instead of instantiating the gate's
9065−:: generalized interface inside its own body. Mutual groups stay unsupported.
9068− |= [e=expr name=term]
9070− ?: ?=(%group -.e) $(e inner.e)
9071− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
9073− ?. ?=(%wing -.head.e) |
9074− =(names.head.e ~[name])
9077− |= [e=expr name=term]
9079− ?: ?=(%group -.e) $(e inner.e)
9080− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
9081− ?. ?=(%branch -.e) ~
9086− =/ y=arm i.t.arms.e
9087− ?. &(?=(%lit -.pat.x) ?=(%lit -.pat.y)) ~
9088− ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y)) ~
9089− ?: =(val.lit.pat.x val.lit.pat.y) ~
9090− =/ first=? (direct-self-call val.x name)
9091− =/ second=? (direct-self-call val.y name)
9092− ?: =(first second) ~
9093− `?:(first val.y val.x)
9095−:: Infer the base arm independently, with the self binding removed. Only
9096−:: a closed type whose constraints resolved can seed the recursive result.
9097−:: The regular body inference then checks both arms with shared state.
9099−++ recursive-branch-seed
9100− |= [d=def env=ienv state=istate]
9102− ?. ?=(%value -.d) ~
9103− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) ~
9108− %gate-wide body.gate
9111− =/ base=(unit expr) (branch-base-arm body name.d)
9113− =/ outer=ienv (skim env |=(entry=[name=term scheme=ischeme] !=(name.entry name.d)))
9114− =/ sam=isample-result
9116− %gate (infer-sample sample.gate outer state)
9117− %gate-wide (infer-sample sample.gate outer state)
9121− =/ inferred=iresult (infer-fragment u.base env.p.sam state.p.sam)
9122− ?: ?=(%| -.inferred) ~
9123− ?: (pending-tags tags.state.p.inferred sub.state.p.inferred) ~
9124− ?: (constrained-capitals caps.state.p.inferred sub.state.p.inferred) ~
9125− =/ typ=itype (itype-normalize typ.p.inferred sub.state.p.inferred)
9126− ?: ?=(^ (itype-vars typ)) ~
9127− ?: (itype-has-tag typ) ~
9130−++ infer-recursive-gate
9131− |= [d=def env=ienv state=istate]
9133− ?. ?=(%value -.d) [%| ["recursive definition is not a gate" ~]]
9134− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
9135− [%| ["recursive definition is not a gate" ~]]
9136− =/ result=(unit itype) (recursive-branch-seed d env state)
9138− =/ sam=isample-result
9140− %gate (infer-sample sample.gate env state)
9141− %gate-wide (infer-sample sample.gate env state)
9145− =/ diag=(unit idiag)
9147− %gate (sample-import-invalid sample.gate env state)
9148− %gate-wide (sample-import-invalid sample.gate env state)
9151− ?: &(=(p.sam "sample mold is not supported by partial inference") ?=(^ diag)) [%| u.diag]
9153− =/ id=@ud next.state.p.sam
9154− =/ product=itype ?~(result [%var id] u.result)
9155− =/ st=istate state.p.sam(next +(id))
9156− =/ seed=itype [%fn typ.p.sam product]
9157− =/ seeded=ienv [[name.d [seed ~]] env.p.sam]
9161− %gate-wide body.gate
9164− =/ out=iresult (infer-fragment body seeded st)
9165− ?: ?=(%| -.out) out
9166− =/ uni=(unit isub) (itype-unify product typ.p.out sub.state.p.out)
9167− ?~ uni [%| ["recursive gate constraint is not supported by partial inference" ~]]
9168− [%& [%fn typ.p.sam typ.p.out] state.p.out(sub u.uni)]
9171− |= names=(list term)
9180− =/ first=(list term) (dependency-expr i.xs)
9181− (weld first $(xs t.xs))
9183−++ dependency-pieces
9187− =/ first=(list term)
9189− %expr (dependency-expr p.i.xs)
9192− (weld first $(xs t.xs))
9198− =/ first=(list term)
9200− %expr (dependency-expr p.i.xs)
9203− (weld first $(xs t.xs))
9209− =/ first=(list term) (dependency-expr val.i.xs)
9210− (weld first $(xs t.xs))
9216− =/ first=(list term) (dependency-expr val.i.xs)
9217− (weld first $(xs t.xs))
9223− =/ first=(list term) (dependency-expr val.i.xs)
9224− (weld first $(xs t.xs))
9230− =/ first=(list term)
9231− ?: ?=(%value -.i.xs) (dependency-expr val.i.xs)
9233− (weld first $(xs t.xs))
9239− %str (dependency-pieces pieces.e)
9240− %qath (dependency-qsegs segs.e)
9241− %wing (dependency-root names.e)
9243− =/ first=(list term) (dependency-root target.e)
9244− =/ last=(list term) (dependency-edits edits.e)
9246− %pair (dependency-expr val.e)
9247− %unit (dependency-expr val.e)
9248− %group (dependency-expr inner.e)
9249− %list (dependency-exprs items.e)
9250− %tuple (dependency-items items.e)
9251− %gate (dependency-expr body.e)
9252− %gate-wide (dependency-expr body.e)
9254− =/ first=(list term) (dependency-expr head.e)
9255− =/ last=(list term) (dependency-exprs args.e)
9257− %cast (dependency-expr val.e)
9259− =/ first=(list term) (dependency-expr val.e)
9260− =/ last=(list term) (dependency-expr then.e)
9263− =/ first=(list term) (dependency-expr subject.e)
9264− =/ last=(list term) (dependency-arms arms.e)
9267− =/ first=(list term) (dependency-defs defs.e)
9268− =/ last=(list term) (dependency-expr final.e)
9273−:: Infer a cyclic component with one monomorphic seed per gate. All members
9274−:: must succeed before any scheme is available; pending constraints and
9275−:: unresolved branch joins remain partial.
9276−+$ igate-entry [name=term typ=itype body=expr env=ienv caps=icaps]
9277−+$ igate-seeds (each [entries=(list igate-entry) state=istate] idiag)
9279− |= [ds=(list def) env=ienv state=istate]
9281− ?~ ds [%& [~ state]]
9283− ?. ?=(%value -.d) [%| ["recursive group contains a non-gate" ~]]
9285− ?. |(?=(%gate -.gate) ?=(%gate-wide -.gate))
9286− [%| ["recursive group contains a non-gate" ~]]
9287− =/ initial=istate (reserve-def-caps gate state)
9288− =/ sam=isample-result
9290− %gate (infer-sample sample.gate env initial)
9291− %gate-wide (infer-sample sample.gate env initial)
9294− ?: ?=(%| -.sam) [%| [p.sam ~]]
9298− %gate-wide body.gate
9301− =/ seed=itype [%fn typ.p.sam [%var next.state.p.sam]]
9302− =/ entry=igate-entry [name.d seed body env.p.sam caps.state.p.sam]
9303− =/ after=istate state.p.sam(next +(next.state.p.sam), caps caps.state)
9304− =/ rest=igate-seeds $(ds t.ds, state after)
9305− ?: ?=(%| -.rest) rest
9306− [%& [[entry entries.p.rest] state.p.rest]]
9309− |= [entries=(list igate-entry) env=ienv]
9312− [[name.i.entries [typ.i.entries ~]] $(entries t.entries)]
9314−++ infer-gate-group-bodies
9315− |= [entries=(list igate-entry) seeds=ienv state=istate]
9317− ?~ entries [%& [~ state]]
9318− =/ entry=igate-entry i.entries
9319− ?> ?=(%fn -.typ.entry)
9320− =/ scope=ienv (weld seeds env.entry)
9321− =/ out=iresult (infer-fragment body.entry scope state(caps caps.entry))
9322− ?: ?=(%| -.out) out
9323− =/ uni=(unit isub) (itype-unify product.typ.entry typ.p.out sub.state.p.out)
9324− ?~ uni [%| ["recursive group constraint is not supported by partial inference" ~]]
9325− =. caps.entry caps.state.p.out
9326− =/ after=istate state.p.out(sub u.uni, caps caps.state)
9327− =/ rest=igate-seeds $(entries t.entries, state after)
9328− ?: ?=(%| -.rest) rest
9329− [%& [[entry entries.p.rest] state.p.rest]]
9332− |= [entries=(list igate-entry) env=ienv outer=istate state=istate]
9333− ^- (each ienv idiag)
9335− =/ entry=igate-entry i.entries
9336− =/ merged=(unit [first=icap second=icap]) (merged-capitals caps.entry sub.state)
9338− [%| ["distinct type variables must not be forced equal" ~[[at.first.u.merged "first type variable"] [at.second.u.merged "second type variable"]]]]
9339− ?: (constrained-capitals caps.entry sub.state)
9340− [%| ["explicit capital constraints are not supported by partial inference" ~]]
9341− =/ typ=itype (itype-normalize typ.entry sub.state)
9342− ?: (itype-has-nvar typ) [%| ["recursive group needs unsupported inference" ~]]
9343− ?: |((itype-has-tag typ) (itype-has-hidden-generic typ) (itype-has-hidden-recursive typ) (unsupported-atom-vars typ caps.entry binders.state sub.state))
9344− [%| ["recursive group needs unsupported inference" ~]]
9345− =/ free=(list @ud) (weld (free-env-vars env sub.state) (free-cap-vars caps.outer sub.state))
9346− =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
9347− =. vars (skim vars |=(n=@ud !(lien free |=(f=@ud =(f n)))))
9348− ?: (gth (lent vars) 26) [%| ["recursive group needs too many type variables" ~]]
9349− =/ rest=(each ienv idiag) $(entries t.entries)
9350− ?: ?=(%| -.rest) rest
9351− [%& [[name.entry [typ vars]] p.rest]]
9354− |= [ds=(list def) env=ienv state=istate]
9356− =/ names=(list term) (global-value-names ds)
9357− ?. (levy names |=(n=term (unique-value-name n names)))
9358− [%| ["recursive group contains duplicate names" ~]]
9359− ?: (lien names |=(n=term ?=(^ (ienv-lookup n env))))
9360− [%| ["recursive group shadows a name" ~]]
9361− =/ scoped=istate state(globals (weld names globals.state))
9362− =/ seeded=igate-seeds (seed-gate-group ds env scoped)
9363− ?: ?=(%| -.seeded) seeded
9364− =/ seeds=ienv (group-seed-env entries.p.seeded ~)
9365− =/ body=igate-seeds (infer-gate-group-bodies entries.p.seeded seeds state.p.seeded)
9366− ?: ?=(%| -.body) body
9367− :: Per-member ownership through mutual recursion is not implemented.
9368− ?: !=(projections.state.p.body projections.state)
9369− [%| ["record projection in recursive groups needs unsupported inference" ~]]
9370− ?: !=(holes.state.p.body holes.state)
9371− [%| ["holes in recursive groups need unsupported inference" ~]]
9372− ?: (pending-tags tags.state.p.body sub.state.p.body)
9373− [%| ["recursive group has unresolved literal constraints" ~]]
9374− =/ schemes=(each ienv idiag) (group-schemes entries.p.body env state state.p.body)
9375− ?: ?=(%| -.schemes) schemes
9376− [%& [(weld p.schemes env) state.p.body(globals globals.state)]]
9379− |= [ps=(list iwprojection) sub=isub visible=(list @ud)]
9380− ^- (unit (list iwprojection))
9382− ?: (lien t.ps |=(p=iwprojection =(at.p at.i.ps))) ~
9383− =/ src=itype (default-decimals (itype-normalize source.i.ps sub))
9384− =/ dst=itype (default-decimals (itype-normalize target.i.ps sub))
9385− ?: |((itype-has-nvar src) (itype-has-nvar dst) (itype-has-tag src) (itype-has-tag dst)) ~
9386− =/ vars=(list @ud) (weld (itype-vars src) (itype-vars dst))
9387− ?. (levy vars |=(n=@ud (lien visible |=(v=@ud =(n v))))) ~
9388− =/ rest=(unit (list iwprojection)) $(ps t.ps)
9390− =/ entry=iwprojection i.ps
9391− =. entry entry(source src, target dst)
9394++ add-supported-defs
6092++ add-supported-defs
9395− |= [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) artifacts=(list iwidth-definition)]
6093+ |= [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)]
9396− ^- [env=ienv artifacts=(list iwidth-definition)]
6094+ ^- ienv
9397− ?~ ds [env artifacts]
6095+ ?~ ds env
9398 =/ d=def i.ds
6096 =/ d=def i.ds
9399 ?: ?=(%mold -.d) $(ds t.ds)
6097 ?: ?=(%mold -.d) $(ds t.ds)
9400 ?. (unique-value-name name.d globals) $(ds t.ds)
6098 ?. (unique-value-name name.d globals) $(ds t.ds)
9401 ?^ (ienv-lookup name.d env) $(ds t.ds)
6099 ?^ (ienv-lookup name.d env) $(ds t.ds)
9402− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9403− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~]
6100+ =/ result=iresult (infer-fragment val.d env [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ |])
9404− =. initial (reserve-def-caps val.d initial)
9405− =/ result=iresult (infer-fragment val.d env initial)
9406− =? result ?=(%| -.result) (infer-recursive-gate d env initial)
9407 ?: ?=(%| -.result) $(ds t.ds)
6101 ?: ?=(%| -.result) $(ds t.ds)
9408− =. state.p.result (promote-restricted-numbers state.p.result env)
9409− =. 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)))
9410− ?^ (unresolved-hole holes.state.p.result holes.initial state.p.result) $(ds t.ds)
9411 ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
6102 ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
9412 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
6103 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
9413 ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
6104 ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
9414 ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
6105 ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
9415 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
6106 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
9416 ?: (gth (lent vars) 26) $(ds t.ds)
6107 ?: (gth (lent vars) 26) $(ds t.ds)
9417− =/ finalized=(unit (list iwprojection))
9418− (width-finalize projections.state.p.result sub.state.p.result vars)
9419− ?~ finalized $(ds t.ds)
9420− =? artifacts ?=(^ u.finalized)
9421− [[name.d val.d typ sub.state.p.result (flop u.finalized)] artifacts]
9422 $(ds t.ds, env [[name.d [typ vars]] env])
6108 $(ds t.ds, env [[name.d [typ vars]] env])
9424−+$ iresolved [env=ienv grouped=(list term) artifacts=(list iwidth-definition)]
9425−+$ iadj (map term (list term))
9426−+$ ivisited (map term ?)
9427−+$ iwork (list [name=term done=?])
9428−+$ iwresult [seen=ivisited order=(list term)]
9429−+$ icresult [seen=ivisited component=(list term)]
9430−+$ icomponents (list (list term))
9432− |= [names=(list term) seen=ivisited]
9435− $(names t.names, seen (~(put by seen) i.names &))
9438− |= [name=term graph=iadj]
9440− =/ found=(unit (list term)) (~(get by graph) name)
9444−++ graph-make-forward
9445− |= [ds=(list def) names=ivisited graph=iadj]
9448− ?. ?=(%value -.i.ds) $(ds t.ds)
9449− =/ deps=(list term) (dependency-expr val.i.ds)
9450− =. deps (skim deps |=(n=term ?=(^ (~(get by names) n))))
9451− $(ds t.ds, graph (~(put by graph) name.i.ds deps))
9453−++ graph-add-reverse
9454− |= [name=term edges=(list term) reverse=iadj]
9457− =/ prior=(list term) (graph-edges i.edges reverse)
9458− $(edges t.edges, reverse (~(put by reverse) i.edges [name prior]))
9461− |= [names=(list term) graph=iadj reverse=iadj]
9464− =. reverse (graph-add-reverse i.names (graph-edges i.names graph) reverse)
9468− |= [todo=iwork seen=ivisited order=(list term) graph=iadj]
9470− ?~ todo [seen order]
9471− =/ event=[name=term done=?] i.todo
9472− ?: done.event $(todo t.todo, order [name.event order])
9473− ?: ?=(^ (~(get by seen) name.event)) $(todo t.todo)
9474− =. seen (~(put by seen) name.event &)
9475− =/ children=iwork (turn (graph-edges name.event graph) |=(n=term [n |]))
9476− $(todo (weld children [[name.event &] t.todo]))
9479− |= [todo=(list term) seen=ivisited component=(list term) graph=iadj]
9481− ?~ todo [seen component]
9482− ?: ?=(^ (~(get by seen) i.todo)) $(todo t.todo)
9483− =. seen (~(put by seen) i.todo &)
9484− $(todo (weld (graph-edges i.todo graph) t.todo), component [i.todo component])
9486−++ graph-collect-all
9487− |= [order=(list term) seen=ivisited graph=iadj comps=icomponents]
9490− ?: ?=(^ (~(get by seen) i.order)) $(order t.order)
9491− =/ found=icresult (graph-collect ~[i.order] seen ~ graph)
9492− $(order t.order, seen seen.found, comps [component.found comps])
9494−:: Two depth-first passes find components before group inference. Maps
9495−:: preserve the graph identity; duplicate global names fail closed.
9497− |= [ds=(list def) names=(list term)]
9499− =/ nameset=ivisited ~
9500− =/ pending=(list term) names
9503− ?: ?=(^ (~(get by nameset) i.pending)) ~
9504− $(pending t.pending, nameset (~(put by nameset) i.pending &))
9505− =/ graph=iadj (graph-make-forward ds nameset ~)
9506− =/ reverse=iadj (graph-reverse names graph ~)
9507− =/ order=iwresult (graph-order (turn names |=(n=term [n |])) ~ ~ graph)
9508− (graph-collect-all order.order ~ reverse ~)
9511− |= [component=(list term) graph=iadj]
9515− (lien (graph-edges i.component graph) |=(x=term =(x i.component)))
9518− |= [ds=(list def) components=icomponents graph=iadj env=ienv grouped=(list term) artifacts=(list iwidth-definition) state=istate]
9520− ?~ components [env grouped artifacts]
9521− =/ component=(list term) i.components
9522− ?. (graph-cycle component graph) $(components t.components)
9523− ?: (lien component |=(n=term ?=(^ (ienv-lookup n env)))) $(components t.components)
9524− =/ members=(list def)
9527− &(?=(%value -.d) (lien component |=(n=term =(n name.d))))
9528− ?. =((lent members) (lent component)) $(components t.components)
9529− ?. (levy component |=(n=term (unique-value-name n globals.state))) $(components t.components)
9530− =/ result=ilocal-result (infer-gate-group members env state)
9531− ?: ?=(%| -.result) $(components t.components)
9532− $(components t.components, env env.p.result, grouped (weld component grouped))
9535− |= [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)]
9538− =/ grouped=(list term) ~
9539− =/ artifacts=(list iwidth-definition) ~
9540− =/ names=(list term) (global-value-names ds)
9541− =/ nameset=ivisited (graph-nameset names ~)
9542− =/ graph=iadj (graph-make-forward ds nameset ~)
9543− =/ components=icomponents (graph-components ds names)
9544− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9546− =/ next=[env=ienv artifacts=(list iwidth-definition)]
9547− (add-supported-defs ds env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts)
9548− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~]
9549− =/ out=iresolved (add-groups ds components graph env.next grouped artifacts.next initial)
9550− ?: =(env env.out) out
9551− $(env env.out, grouped grouped.out, artifacts artifacts.out)
9553++ resolve-supported-defs
6110++ resolve-supported-defs
9554− |= [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)]
6111+ |= [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)]
9556− env:(resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude)
6113+ =/ env=ienv ~
9558−:: A diagnostic-only proof for a narrow syntactic value cycle. Every
9559−:: edge is an unqualified wing in a supported expression, and samples
9560−:: may not shadow global bindings. Unknown forms yield no conclusion.
9561−+$ icyclesite [name=term at=span]
9562−+$ icycle [name=term first=span next=span]
9564− |= [xs=(list expr) globals=(list term) locals=(list term)]
9565− ^- (unit (list icyclesite))
9567− =/ first=(unit (list icyclesite)) (cycle-sites i.xs globals locals)
9569− =/ tail=(unit (list icyclesite)) $(xs t.xs)
9571− `(weld u.first u.tail)
9573−++ cycle-sample-name
9574− |= [sam=sample globals=(list term) locals=(list term)]
9575− ^- (unit (unit term))
9578− ?: (lien (weld globals locals) |=(n=term =(n name.sam))) ~
9581− ?: (lien (weld globals locals) |=(n=term =(n name.sam))) ~
9588− |= [e=expr globals=(list term) locals=(list term)]
9589− ^- (unit (list icyclesite))
9592− ?. ?=([@ ~] names.e) ~
9593− `~[[i.names.e at.e]]
9596− ?: (lien pieces.e |=(p=piece ?=(%expr -.p))) ~
9598− %group $(e inner.e)
9599− %body ?~(defs.e $(e final.e) ~)
9602− =/ binder=(unit (unit term)) (cycle-sample-name sample.e globals locals)
9604− =/ nested=(list term) ?~(u.binder locals [u.u.binder locals])
9605− $(e body.e, locals nested)
9607− =/ binder=(unit (unit term)) (cycle-sample-name sample.e globals locals)
9609− =/ nested=(list term) ?~(u.binder locals [u.u.binder locals])
9610− $(e body.e, locals nested)
9612− =/ first=(unit (list icyclesite)) $(e head.e)
9614− =/ tail=(unit (list icyclesite)) (cycle-sites-list args.e globals locals)
9616− `(weld u.first u.tail)
9620−++ cycle-definitely-atom
9623− ?: ?=(%group -.e) $(e inner.e)
9624− ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
9626− |(?=(%aura -.shape.e) ?=(%flag -.shape.e))
9628−++ cycle-proof-group
9629− |= [members=(list def) globals=(list term)]
9632− ?. ?=(%value -.i.members) |
9633− ?. (unique-value-name name.i.members globals) |
9634− ?. ?=(^ (cycle-sites val.i.members globals ~)) |
9635− $(members t.members)
9638− |= [sites=(list icyclesite) component=(list term)]
9641− ?: (lien component |=(n=term =(n name.i.sites))) `at.i.sites
9644−++ cycle-group-errors
9645− |= [members=(list def) component=(list term) globals=(list term)]
9650− =/ tail=(list icycle) $(members t.members)
9651− ?. (cycle-definitely-atom val.d) tail
9652− =/ sites=(unit (list icyclesite)) (cycle-sites val.d globals ~)
9654− =/ found=(unit span) (cycle-find-site u.sites component)
9656− [[name.d at.d u.found] tail]
9658−++ definite-value-cycles
9659− |= [ds=(list def) globals=(list term)]
9661− =/ names=(list term) (global-value-names ds)
9662− =/ graph=iadj (graph-make-forward ds (graph-nameset names ~) ~)
9663− =/ components=icomponents (graph-components ds names)
9664− =/ out=(list icycle) ~
9666− ?~ components out
6115+ =/ next=ienv (add-supported-defs ds env molds globals externals surs mark-externals marks jimports reserved-molds)
9667− =/ component=(list term) i.components
6116+ ?: =(next env) env
9668− ?. (graph-cycle component graph) $(components t.components)
6117+ $(env next)
9669− =/ members=(list def)
9670− (skim ds |=(d=def &(?=(%value -.d) (lien component |=(n=term =(n name.d))))))
9671− ?. =((lent members) (lent component)) $(components t.components)
9672− ?. (cycle-proof-group members globals) $(components t.components)
9673− $(components t.components, out (weld (cycle-group-errors members component globals) out))
9675+| %union-analysis
6119+| %union-analysis
@@ -9807,142 +6251,11 @@
9807 [at.first at.second (union-relate a (project-union-mold second molds ~))]
6251 [at.first at.second (union-relate a (project-union-mold second molds ~))]
9808 (weld pairs $(cases t.cases))
6252 (weld pairs $(cases t.cases))
9810−:: A closed structural mold supplies no equation to determine a hole.
9811−:: Applications, references, unbound capitals and unions are unproved.
9814− ^- (unit (unit span))
9815− ?: ?=(%generic -.sh)
9817− ?. (distinct-params vars.sh) ~
9818− (simple-mold-hole-in body.sh vars.sh)
9819− (simple-mold-hole-in sh ~)
9820−++ simple-mold-hole-in
9821− |= [sh=shape vars=(list @t)]
9822− ^- (unit (unit span))
9825− ?(%aura %noun %void %flag %const) `~
9826− %tvar ?:((lien vars |=(v=@t =(v name.sh))) `~ ~)
9827− %cell (simple-mold-field-holes fields.sh vars)
9829− =/ a=(unit (unit span)) $(sh sample.sh)
9831− =/ b=(unit (unit span)) $(sh product.sh)
9837−++ simple-mold-field-holes
9838− |= [fields=(list field) vars=(list @t)]
9839− ^- (unit (unit span))
9841− =/ f=field i.fields
9842− =/ first=(unit (unit span))
9844− %face (simple-mold-hole-in shape.f vars)
9845− %bare (simple-mold-hole-in shape.f vars)
9849− =/ rest=(unit (unit span)) $(fields t.fields)
9851− `?~(u.first u.rest u.first)
9852−++ simple-local-mold-hole
9856− ?. ?=(%mold -.i.defs) $(defs t.defs)
9857− =/ found=(unit (unit span)) (simple-mold-hole shape.i.defs)
9858− ?~ found $(defs t.defs)
9862−:: A partial prelude may omit unsupported declarations, but may not
9863−:: publish an interface while a named mold's hole remains unchecked.
9869− %path (lien segs.sh |=(s=pseg ?=(%inferred -.s)))
9870− %apply (lien args.sh shape-has-hole)
9871− %union (lien cases.sh shape-has-hole)
9872− %cell (lien fields.sh field-has-hole)
9873− %fn |($(sh sample.sh) $(sh product.sh))
9874− %generic $(sh body.sh)
9881− %face (shape-has-hole shape.f)
9882− %bare (shape-has-hole shape.f)
9885−++ named-mold-has-hole
9889− ?: &(?=(%mold -.i.ds) (shape-has-hole shape.i.ds)) &
9896− %face (shape-has-hole shape.sam)
9897− %bare (shape-has-hole shape.sam)
9898− %cell (lien items.sam sample-has-hole)
9905− %mold (shape-has-hole shape.d)
9906− %value (expr-has-hole val.d)
9912− %str (lien pieces.e |=(p=piece ?:(?=(%expr -.p) (expr-has-hole p.p) |)))
9913− %qath (lien segs.e |=(p=qseg ?:(?=(%expr -.p) (expr-has-hole p.p) |)))
9914− %change (lien edits.e |=(p=edit (expr-has-hole val.p)))
9917− %group $(e inner.e)
9918− %list (lien items.e expr-has-hole)
9919− %tuple (lien items.e |=(i=item (expr-has-hole val.i)))
9920− ?(%gate %gate-wide) |((sample-has-hole sample.e) $(e body.e))
9921− %cast |((shape-has-hole shape.e) $(e val.e))
9922− %call |($(e head.e) (lien args.e expr-has-hole))
9923− %trace |($(e val.e) $(e then.e))
9924− %branch |($(e subject.e) (lien arms.e |=(a=arm (expr-has-hole val.a))))
9925− %body |((lien defs.e def-has-hole) $(e final.e))
9928−++ hole-values-present
9929− |= [ds=(list def) env=ienv]
9932− ?. ?=(%value -.i.ds) $(ds t.ds)
9933− ?: (expr-has-hole val.i.ds)
9934− ?. ?=(^ (ienv-lookup name.i.ds env)) |
9937++ show-partial-mold
6254++ show-partial-mold
9938 |= [file=path src=@t d=def molds=imolds]
6255 |= [file=path src=@t d=def molds=imolds]
9940 ?> ?=(%mold -.d)
6257 ?> ?=(%mold -.d)
9941 =/ sh=shape shape.d
6258 =/ sh=shape shape.d
9942− =/ hole=(unit (unit span)) (simple-mold-hole sh)
9943− ?: &(?=(^ hole) ?=(^ u.hole))
9944− =/ text=@t (show-error src [file line.beg.u.u.hole col.beg.u.u.hole "unresolved type hole"])
9945− (of-wain:format ~[(crip "+$ {(trip name.d)}: type hole needs a determined type") text])
9946 =? sh ?=(%generic -.sh) body.sh
6259 =? sh ?=(%generic -.sh) body.sh
9947 ?. ?=(%union -.sh) (crip "+$ {(trip name.d)}: not checked")
6260 ?. ?=(%union -.sh) (crip "+$ {(trip name.d)}: not checked")
9948 =/ pairs=(list upair) (union-pairs cases.sh molds)
6261 =/ pairs=(list upair) (union-pairs cases.sh molds)
@@ -9969,21 +6282,6 @@
9969 (show-error src [file line.beg.at.site col.beg.at.site note.site])
6282 (show-error src [file line.beg.at.site col.beg.at.site note.site])
9970 (of-wain:format [summary excerpts])
6283 (of-wain:format [summary excerpts])
9972−:: Both written field sites are shown in the source that declares them.
9973−++ show-duplicate-fields
9974− |= [file=path src=@t diagnostic=idiag]
9976− =/ excerpts=(list @t)
9977− %+ turn sites.diagnostic
9978− |= site=[at=span note=tape]
9979− (show-error src [file line.beg.at.site col.beg.at.site note.site])
9980− (of-wain:format [(crip msg.diagnostic) excerpts])
9982−++ duplicate-fields-report
9983− |= [file=path src=@t diagnostic=idiag]
9985− (of-wain:format ~['partial inference; module not checked' (show-duplicate-fields file src diagnostic)])
9987:: +golden-types: a partial report; it does not claim the module checks
6285:: +golden-types: a partial report; it does not claim the module checks
9989++ golden-types
6287++ golden-types
@@ -10013,180 +6311,6 @@
10013+$ jfile-result (each [iface=ifile cache=jcache] @t)
6311+$ jfile-result (each [iface=ifile cache=jcache] @t)
10014+$ jimports-result (each [resolved=ijimports cache=jcache] @t)
6312+$ jimports-result (each [resolved=ijimports cache=jcache] @t)
10016−:: Written record fields each have their own lexical record scope.
10017−+$ written-fields (map term span)
10018−++ duplicate-written-field
10019− |= [name=term at=span seen=written-fields]
10021− =/ prior=(unit span) (~(get by seen) name)
10023− `["record field `{(trip name)}` is repeated" ~[[u.prior "first field"] [at "repeated field"]]]
10024−++ duplicate-shapes
10025− |= xs=(list shape)
10028− =/ first (duplicate-shape i.xs)
10031−++ duplicate-fields
10032− |= [fields=(list field) seen=written-fields]
10035− =/ f=field i.fields
10042− =/ dup=(unit idiag) ?~(n ~ (duplicate-written-field u.n at.f seen))
10044− =/ inner=(unit idiag)
10046− %face (duplicate-shape shape.f)
10048− %bare (duplicate-shape shape.f)
10051− $(fields t.fields, seen ?~(n seen (~(put by seen) u.n at.f)))
10056− %cell (duplicate-fields fields.s ~)
10057− %apply (duplicate-shapes args.s)
10058− %union (duplicate-shapes cases.s)
10060− =/ left (duplicate-shape sample.s)
10062− (duplicate-shape product.s)
10063− %generic (duplicate-shape body.s)
10066−++ duplicate-samples
10067− |= [items=(list sample) seen=written-fields]
10070− =/ a=sample i.items
10078− =/ dup=(unit idiag) ?~(n ~ (duplicate-written-field u.n at.a seen))
10080− =/ inner (duplicate-sample a)
10082− $(items t.items, seen ?~(n seen (~(put by seen) u.n at.a)))
10083−++ duplicate-sample
10087− %cell (duplicate-samples items.s ~)
10088− %face (duplicate-shape shape.s)
10089− %bare (duplicate-shape shape.s)
10096− =/ first (duplicate-expr i.xs)
10100− |= [items=(list item) seen=written-fields]
10104− =/ dup=(unit idiag) ?~(face.a ~ (duplicate-written-field u.face.a at.a seen))
10106− =/ inner (duplicate-expr val.a)
10108− $(items t.items, seen ?~(face.a seen (~(put by seen) u.face.a at.a)))
10109−++ duplicate-pieces
10110− |= pieces=(list piece)
10113− =/ first=(unit idiag) ?:(?=(%expr -.i.pieces) (duplicate-expr p.i.pieces) ~)
10115− $(pieces t.pieces)
10117− |= segs=(list qseg)
10120− =/ first=(unit idiag) ?:(?=(%expr -.i.segs) (duplicate-expr p.i.segs) ~)
10124− |= edits=(list edit)
10127− =/ first (duplicate-expr val.i.edits)
10131− |= arms=(list arm)
10134− =/ first (duplicate-expr val.i.arms)
10138− |= defs=(list def)
10141− =/ first=(unit idiag)
10143− %mold (duplicate-shape shape.i.defs)
10144− %value (duplicate-expr val.i.defs)
10152− %str (duplicate-pieces pieces.e)
10153− %qath (duplicate-qsegs segs.e)
10154− %change (duplicate-edits edits.e)
10155− %pair (duplicate-expr val.e)
10156− %unit (duplicate-expr val.e)
10157− %group (duplicate-expr inner.e)
10158− %list (duplicate-exprs items.e)
10159− %tuple (duplicate-items items.e ~)
10161− =/ first (duplicate-sample sample.e)
10163− (duplicate-expr body.e)
10165− =/ first (duplicate-sample sample.e)
10167− (duplicate-expr body.e)
10169− =/ first (duplicate-shape shape.e)
10171− (duplicate-expr val.e)
10173− =/ first (duplicate-expr head.e)
10175− (duplicate-exprs args.e)
10177− =/ first (duplicate-expr val.e)
10179− (duplicate-expr then.e)
10181− =/ first (duplicate-expr subject.e)
10183− (duplicate-arms arms.e)
10185− =/ first (duplicate-defs defs.e)
10187− (duplicate-expr final.e)
10190++ import-binding-names
6314++ import-binding-names
10191 |= imports=(list import)
6315 |= imports=(list import)
10192 ^- (list term)
6316 ^- (list term)
@@ -10199,60 +6323,6 @@
10200 [n $(imports t.imports)]
6324 [n $(imports t.imports)]
10202−++ reserved-proj-sample
10206− %bind =(name.sam %proj)
10207− %face =(name.sam %proj)
10208− %pun =(name.sam %proj)
10209− %cell (lien items.sam reserved-proj-sample)
10212−++ reserved-proj-pattern
10216− %bind =(name.p %proj)
10217− %cell (lien items.p reserved-proj-pattern)
10220−++ reserved-proj-def
10223− ?: =(name.d %proj) &
10224− ?: ?=(%value -.d) (reserved-proj-expr val.d)
10226−++ reserved-proj-expr
10230− %str (lien pieces.e |=(p=piece ?:(?=(%expr -.p) (reserved-proj-expr p.p) |)))
10231− %qath (lien segs.e |=(p=qseg ?:(?=(%expr -.p) (reserved-proj-expr p.p) |)))
10232− %change (lien edits.e |=(p=edit (reserved-proj-expr val.p)))
10235− %group $(e inner.e)
10236− %list (lien items.e reserved-proj-expr)
10237− %tuple (lien items.e |=(i=item (reserved-proj-expr val.i)))
10238− ?(%gate %gate-wide) |((reserved-proj-sample sample.e) $(e body.e))
10240− %call |($(e head.e) (lien args.e reserved-proj-expr))
10241− %trace |($(e val.e) $(e then.e))
10242− %branch |($(e subject.e) (lien arms.e |=(a=arm |((reserved-proj-pattern pat.a) (reserved-proj-expr val.a)))))
10243− %body |((lien defs.e reserved-proj-def) $(e final.e))
10247−++ module-has-reserved-proj
10250− =/ imported=(list term) (import-binding-names imports.mod)
10251− =/ vals=(list term) (global-value-names defs.mod)
10252− =/ molds=imolds (collect-simple-molds defs.mod)
10253− =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10254− |((lien (weld imported (weld vals mold-names)) |=(n=term =(n %proj))) (lien defs.mod reserved-proj-def))
10256++ module-scope-valid
6326++ module-scope-valid
10257 |= [mod=module prelude-values=(list term) prelude-molds=(list term)]
6327 |= [mod=module prelude-values=(list term) prelude-molds=(list term)]
@@ -10260,7 +6330,6 @@
10260 =/ vals=(list term) (global-value-names defs.mod)
6330 =/ vals=(list term) (global-value-names defs.mod)
10261 =/ molds=imolds (collect-simple-molds defs.mod)
6331 =/ molds=imolds (collect-simple-molds defs.mod)
10262 =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
6332 =/ mold-names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10263− ?: (module-has-reserved-proj mod) |
10264 ?. %+ levy imported
6333 ?. %+ levy imported
10265 |= n=term
6334 |= n=term
10266 &((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))))
6335 &((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))))
@@ -10268,22 +6337,6 @@
10268 ?. (levy vals |=(n=term &((unique-value-name n vals) !(lien prelude-values |=(v=term =(n v)))))) |
6337 ?. (levy vals |=(n=term &((unique-value-name n vals) !(lien prelude-values |=(v=term =(n v)))))) |
10269 (levy mold-names |=(n=term &((unique-value-name n mold-names) !(lien prelude-molds |=(m=term =(n m))))))
6338 (levy mold-names |=(n=term &((unique-value-name n mold-names) !(lien prelude-molds |=(m=term =(n m))))))
10271−:: In an API file or before main's kind is known, a lone `+$ poke`
10272−:: may be a declaration rather than a mold that shadows the prelude. Do not call
10273−:: that one collision definite, and do not hide unrelated scope errors.
10274−++ pending-declared-poke
10275− |= [at=path mod=module prelude-values=(list term) prelude-molds=(list term)]
10277− ?. (lien prelude-molds |=(n=term =(%poke n))) |
10278− ?. |(?=([%ui %api @ %jibb ~] at) (lien defs.mod |=(d=def &(?=(%value -.d) =(%main name.d))))) |
10279− =/ pokes=(list def)
10280− (skim defs.mod |=(d=def &(?=(%mold -.d) =(%poke name.d))))
10283− =/ remaining=(list def)
10284− (skim defs.mod |=(d=def !&(?=(%mold -.d) =(%poke name.d))))
10285− (module-scope-valid mod(defs remaining) prelude-values prelude-molds)
10287++ module-mold-types
6340++ module-mold-types
10288 |= [molds=imolds state=istate]
6341 |= [molds=imolds state=istate]
10289 ^- (each imold-types @t)
6342 ^- (each imold-types @t)
@@ -10292,260 +6345,10 @@
10292 =/ t=(unit [template=ischeme state=istate])
6345 =/ t=(unit [template=ischeme state=istate])
10293 (infer-mold-template body.m state(active [name.m active.state], in-mold &))
6346 (infer-mold-template body.m state(active [name.m active.state], in-mold &))
10294 ?~ t [%| 'module mold needs unsupported inference']
6347 ?~ t [%| 'module mold needs unsupported inference']
10295− =. typ.template.u.t (label-direct-union typ.template.u.t body.m name.m state)
10296 =/ rest=(each imold-types @t) $(molds t.molds)
6348 =/ rest=(each imold-types @t) $(molds t.molds)
10297 ?: ?=(%| -.rest) rest
6349 ?: ?=(%| -.rest) rest
10298 [%& [[name.m template.u.t] p.rest]]
6350 [%& [[name.m template.u.t] p.rest]]
10300−:: Prepare a provisional interface from the trusted vendored source.
10301−:: Every declared name remains reserved, but only molds and values this
10302−:: fragment can infer are usable. Unsupported bodies are not validated.
10303−:: An optional internal source supplies the prelude's one supported import;
10304−:: clients cannot import that path directly. Named unions retain their origin.
10306−:: Recognize only the complete standard prelude list shape. Its recursive
10307−:: tail uses the same parameter and the unqualified list name. The reader
10308−:: verifies Hoon's list provenance before producing the same collection type.
10309−:: The prelude source and reader output are trusted caller inputs.
10311−++ standard-prelude-list
10314− ?. ?=(%generic -.sh) |
10317− =/ var=@t i.vars.sh
10318− ?. ?=(%union -.body.sh) |
10319− =/ cs=(list shape) cases.body.sh
10323− ?. ?=(%const -.i.cs) |
10324− ?. =(%null form.lit.i.cs) |
10325− ?. ?=(%cell -.i.t.cs) |
10326− =/ fs=(list field) fields.i.t.cs
10330− ?. ?=(%face -.i.fs) |
10331− ?. =(%i name.i.fs) |
10332− ?. ?=(%tvar -.shape.i.fs) |
10333− ?. =(var name.shape.i.fs) |
10334− ?. ?=(%face -.i.t.fs) |
10335− ?. =(%t name.i.t.fs) |
10336− =/ tail=shape shape.i.t.fs
10337− ?. ?=(%apply -.tail) |
10338− ?. =(~[%list] ref.tail) |
10341− ?. ?=(%tvar -.i.args.tail) |
10342− =(var name.i.args.tail)
10345− |= [typ=itype name=term vars=(list @ud)]
10347− ?: ?=(%jrec -.typ) typ(label `name)
10348− ?. ?=(%union -.typ) typ
10349− ?. (identity-union-parameters vars args.typ)
10351− ?: =(at.u.origin.typ /lib/jibb/internal/jibb) typ(label ~)
10355−++ partial-prelude-molds
10356− |= [molds=imolds state=istate]
10359− =/ m=[name=term body=shape] i.molds
10360− ?: &(=(at.state /lib/jibb/prelude/jibb) =(%list name.m))
10361− ?. (standard-prelude-list body.m) $(molds t.molds)
10362− [[%list [[%collection %list ~[[%var 0]]] ~[0]]] $(molds t.molds)]
10363− =/ out=(unit [template=ischeme state=istate])
10364− (infer-mold-template body.m state(active [name.m active.state], in-mold &))
10365− ?~ out $(molds t.molds)
10366− =. typ.template.u.out (label-direct-union typ.template.u.out body.m name.m state)
10367− =. typ.template.u.out (prelude-label typ.template.u.out name.m vars.template.u.out)
10368− [[name.m template.u.out] $(molds t.molds)]
10370−:: A compiler-owned interface available only to the dedicated
10371−:: internal-prelude preparation path, never the ordinary module resolver.
10372−++ private-primitive-interface
10374− =/ a=itype [%avar 0]
10375− =/ pair=itype [%cell a a]
10376− =/ b=itype [%rvar 0]
10377− =/ plus=ischeme [[%fn [%cell b b] b] ~[0]]
10378− =/ minus=ischeme [[%fn b b] ~[0]]
10379− =/ greater=ischeme [[%fn pair [%flag ~]] ~[0]]
10380− [~[[%raw-add plus] [%raw-dec minus] [%raw-gth greater]] ~ /lib/jibb/primitives/jibb ~ ~ ~ ~ ~]
10382−++ infer-private-internal
10383− |= [src=@t public-source=@t]
10385− =/ at=path /lib/jibb/internal/jibb
10386− =/ parsed (parse at src)
10387− ?: ?=(%| -.parsed) ~
10388− =/ mod=module p.parsed
10389− ?^ (duplicate-defs defs.mod) ~
10391− =/ built=jfile-result (infer-jibb-file at src ~ ~ ~ ~[at] ~ ~ ~ ~)
10392− ?: ?=(%| -.built) ~
10394− ?. ?=([[%jibb *] ~] imports.mod) ~
10395− ?. =(path.i.imports.mod /lib/jibb/primitives) ~
10396− ?. (module-scope-valid mod ~ ~) ~
10397− =/ vals=(list term) (global-value-names defs.mod)
10398− ?: (lien vals |=(n=term =(n %main))) ~
10399− =/ molds=imolds (collect-simple-molds defs.mod)
10400− =/ globals=(list term) (weld (import-binding-names imports.mod) vals)
10401− :: The private source can use the public list and unit molds before the
10402− :: prelude is otherwise prepared. Re-read the trusted public source here
10403− :: and admit only its validated canonical templates; do not accept schemes
10404− :: supplied independently by the caller.
10405− =/ public=(each module error) (parse /lib/jibb/prelude/jibb public-source)
10406− ?: ?=(%| -.public) ~
10407− ?^ (duplicate-defs defs.p.public) ~
10408− ?. (module-scope-valid p.public ~ ~) ~
10409− =/ source-molds=imolds (collect-simple-molds defs.p.public)
10410− =/ written-list=(unit shape) (find-simple-mold %list source-molds)
10411− =/ source-list=(unit ischeme)
10413− ?. (standard-prelude-list u.written-list) ~
10414− `[[%collection %list ~[[%var 0]]] ~[0]]
10415− :: Derive the public unit template from its actual source, then compare
10416− :: the complete nominal template before making it available privately.
10417− =/ unit-decl=(unit shape) (find-simple-mold %unit source-molds)
10418− =/ source-unit=(unit ischeme)
10420− =/ unit-molds=imolds ~[[%unit u.unit-decl]]
10421− =/ unit-state=istate [0 ~ ~ ~ unit-molds ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | /lib/jibb/prelude/jibb ~[%unit] ~ ~ 256 ~]
10422− =/ unit-types=imold-types (partial-prelude-molds unit-molds unit-state)
10423− =/ unit-iface=ifile [~ unit-types /lib/jibb/prelude/jibb ~ ~ ~ ~ ~]
10424− =/ found=(unit ischeme) (find-jibb-mold %unit unit-iface)
10426− ?. (standard-unit-template u.found /lib/jibb/prelude/jibb) ~
10428− =/ primitive=ifile private-primitive-interface
10429− =? primitive ?=(^ source-list)
10430− primitive(molds [[%list u.source-list] molds.primitive])
10431− =? primitive ?=(^ source-unit)
10432− primitive(molds [[%unit u.source-unit] molds.primitive])
10433− =/ js=ijimports ~[[face.i.imports.mod primitive]]
10434− =/ reserved=(list term) ~[face.i.imports.mod]
10435− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10436− =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ js reserved ~ ~ ~ | at top ~ ~ 256 ~]
10437− =/ mts=(each imold-types @t) (module-mold-types molds state)
10438− =/ usable=(unit imold-types)
10439− ?: ?=(%& -.mts) `p.mts
10440− :: Missing public templates may make an unrelated internal mold
10441− :: unavailable. Validate all molds once with isolated canonical
10442− :: templates before admitting only those inferred using the actual
10443− :: source-backed templates. The proof interface is never exported.
10444− ?. |(?=(~ source-list) ?=(~ source-unit)) ~
10445− =/ nil=itype [%const [%null %n 0 '~']]
10446− =/ canonical-unit=ischeme
10447− [[%union ~[nil [%cell nil [%face %u [%var 0]]]] `[/lib/jibb/prelude/jibb %unit] `%unit ~[[%var 0]]] ~[0]]
10448− =/ canonical-list=ischeme [[%collection %list ~[[%var 0]]] ~[0]]
10449− =/ proof-primitive=ifile private-primitive-interface
10450− =. molds.proof-primitive ~[[%list canonical-list] [%unit canonical-unit]]
10451− =/ proof-imports=ijimports ~[[face.i.imports.mod proof-primitive]]
10452− =/ proof=(each imold-types @t) (module-mold-types molds state(jimports proof-imports))
10453− ?: ?=(%| -.proof) ~
10454− `(partial-prelude-molds molds state)
10456− =/ resolution=iresolved (resolve-groups defs.mod molds globals ~ ~ ~ ~ js reserved at ~)
10457− =/ env=ienv env.resolution
10458− ?. (module-values-complete defs.mod env) ~
10459− `[env u.usable at ~ artifacts.resolution ~ `src ~]
10461−++ partial-prelude-interface-with-internal
10462− |= [src=@t internal-source=(unit @t)]
10465− =/ at=path /lib/jibb/prelude/jibb
10466− =/ parsed (parse at src)
10467− ?: ?=(%| -.parsed) ~
10468− ?: (named-mold-has-hole defs.p.parsed) ~
10469− ?^ (duplicate-defs defs.p.parsed) ~
10470− =/ private=(unit ijimports)
10471− ?~ imports.p.parsed `~
10472− ?. ?=([[%jibb *] ~] imports.p.parsed) ~
10473− ?. =(path.i.imports.p.parsed /lib/jibb/internal) ~
10474− ?~ internal-source ~
10475− =/ built=(unit ifile) (infer-private-internal u.internal-source src)
10477− `~[[face.i.imports.p.parsed u.built]]
10479− ?~ defs.p.parsed ~
10480− ?. (module-scope-valid p.parsed ~ ~) ~
10481− =/ ds=(list def) defs.p.parsed
10482− =/ molds=imolds (collect-simple-molds ds)
10483− =/ names=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10484− =/ globals=(list term) (weld (import-binding-names imports.p.parsed) (global-value-names ds))
10485− :: Remove raw list before inferring any template, so an altered list
10486− :: cannot leak through an alias. Its name remains reserved either way.
10487− =/ declared=? (lien names |=(name=term =(%list name)))
10488− =/ env-molds=imolds molds
10489− =? env-molds declared
10490− (skim molds |=(m=[name=term body=shape] !=(%list name.m)))
10491− =/ reserved=(list term) ?:(declared ~[%list] ~)
10492− =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ u.private reserved ~ ~ ~ | at names ~ ~ 256 ~]
10493− :: Other prelude molds may use list only after its source has passed
10494− :: the standard-list check. The raw declaration remains removed.
10495− =/ declared-list=(unit shape) (find-simple-mold %list molds)
10496− =/ mold-prelude=(unit ifile)
10497− ?~ declared-list ~
10498− ?. (standard-prelude-list u.declared-list) ~
10499− `[~ ~[[%list [[%collection %list ~[[%var 0]]] ~[0]]]] at ~ ~ ~ ~ ~]
10500− =/ mt=imold-types (partial-prelude-molds molds state(prelude mold-prelude))
10501− =/ partial=ifile [~ mt at ~ ~ ~ ~ ~]
10502− :: An explicitly qualified re-export must resolve. Other unsupported
10503− :: prelude declarations remain reserved but absent from the interface.
10504− =/ required=imolds
10506− |= m=[name=term body=shape]
10507− =/ sh=shape body.m
10508− ?. ?=(%ref -.sh) |
10511− ?. (levy required |=(m=[name=term body=shape] ?=(^ (find-jibb-mold name.m partial)))) ~
10512− =/ resolution=iresolved (resolve-groups ds env-molds globals ~ ~ ~ ~ u.private reserved at `partial)
10513− =/ env=ienv env.resolution
10514− ?. (hole-values-present ds env) ~
10515− =/ deps=(list iwidth-dependency)
10517− ~[[at.interface.i.u.private source.interface.i.u.private elaborations.interface.i.u.private]]
10518− `[env mt at ~ artifacts.resolution deps `src ~]
10520−++ partial-prelude-interface
10523− (partial-prelude-interface-with-internal src ~)
10525−+$ iprelude [iface=ifile values=(list term) molds=(list term)]
10529− ^- (unit iprelude)
10530− =/ iface=(unit ifile) (partial-prelude-interface src)
10532− =/ parsed (parse /lib/jibb/prelude/jibb src)
10533− ?: ?=(%| -.parsed) ~
10534− =/ vals=(list term) (global-value-names defs.p.parsed)
10535− =/ ms=(list term) (turn (collect-simple-molds defs.p.parsed) |=(m=[name=term body=shape] name.m))
10536− `[u.iface vals ms]
10538−++ prepare-prelude-with-internal
10539− |= [src=@t internal-source=@t]
10540− ^- (unit iprelude)
10541− =/ iface=(unit ifile) (partial-prelude-interface-with-internal src `internal-source)
10543− =/ parsed (parse /lib/jibb/prelude/jibb src)
10544− ?: ?=(%| -.parsed) ~
10545− =/ vals=(list term) (global-value-names defs.p.parsed)
10546− =/ ms=(list term) (turn (collect-simple-molds defs.p.parsed) |=(m=[name=term body=shape] name.m))
10547− `[u.iface vals ms]
10549++ module-values-complete
6352++ module-values-complete
10550 |= [ds=(list def) env=ienv]
6353 |= [ds=(list def) env=ienv]
@@ -10566,76 +6369,12 @@
10566 ?: =(at at.i.cache) `iface.i.cache
6369 ?: =(at at.i.cache) `iface.i.cache
10567 $(cache t.cache)
6370 $(cache t.cache)
10569−:: These certificates retain the complete checked source closure. The
10570−:: trusted host must supply the identical prepared prelude and reader nouns.
10571−:: Exact bundle equality binds all source paths and versions; the set
10572−:: retains transitive paths for active-cycle checks. Request-bearing graphs
10573−:: alone have a size limit; incompatible diamond evidence fails closed.
10574−++ request-graph-requests-add
10575− |= [pending=(list irequest-evidence) acc=(list irequest-evidence) fuel=@ud]
10576− ^- (unit (list irequest-evidence))
10579− =/ hit=(list irequest-evidence)
10580− (skim acc |=(x=irequest-evidence &(=(api-at.x api-at.i.pending) =(name.x name.i.pending))))
10582− ?. ?=([* ~] hit) ~
10583− ?. =(i.hit i.pending) ~
10584− $(pending t.pending, fuel (dec fuel))
10585− $(pending t.pending, acc [i.pending acc], fuel (dec fuel))
10586−++ request-graph-inputs-match
10587− |= [g=irequest-graph externals=iexternals marks=imark-externals modules=jbundle values=(list term) molds=(list term) prelude=(unit ifile)]
10589− ?& =(bundle-input.g modules)
10590− =(prelude-input.g prelude)
10591− =(prelude-values.g values)
10592− =(prelude-molds.g molds)
10593− =(externals.g externals)
10596−++ request-graph-merge
10597− |= [imports=ijimports g=irequest-graph fuel=@ud]
10598− ^- (unit irequest-graph)
10601− =/ child=ifile interface.i.imports
10603− =/ cg=irequest-graph u.graph.child
10604− ?. ?& =(bundle-input.g bundle-input.cg)
10605− =(prelude-input.g prelude-input.cg)
10606− =(prelude-values.g prelude-values.cg)
10607− =(prelude-molds.g prelude-molds.cg)
10608− =(externals.g externals.cg)
10609− =(marks.g marks.cg)
10612− =/ merged=(set path) (~(uni in:..zuse paths.g) paths.cg)
10613− =/ rs=(unit (list irequest-evidence))
10614− (request-graph-requests-add requests.cg requests.g (add 1 (lent requests.cg)))
10616− ?: &(?=(^ u.rs) |((gth (lent ~(tap in:..zuse merged)) 256) (gth (lent u.rs) 256))) ~
10617− $(imports t.imports, g g(paths merged, requests u.rs), fuel (dec fuel))
10618−++ request-graph-reusable
10619− |= [f=ifile src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) values=(list term) molds=(list term) prelude=(unit ifile)]
10622− ?. =(u.source.f src) |
10624− =/ g=irequest-graph u.graph.f
10625− ?. (request-graph-inputs-match g externals marks modules values molds prelude) |
10626− ?. (~(has in:..zuse paths.g) at.f) |
10627− !(lien active |=(p=path (~(has in:..zuse paths.g) p)))
10629++ resolve-jibb-imports
6372++ resolve-jibb-imports
10630− |= [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)]
6373+ |= [imports=(list import) externals=iexternals mark-externals=imark-externals modules=jbundle active=(list path) prelude-values=(list term) prelude-molds=(list term) cache=jcache]
10631 ^- jimports-result
6374 ^- jimports-result
10632 ?~ imports [%& [~ cache]]
6375 ?~ imports [%& [~ cache]]
10633 ?. ?=(%jibb -.i.imports) $(imports t.imports)
6376 ?. ?=(%jibb -.i.imports) $(imports t.imports)
10634 =/ at=path (weld path.i.imports `path`~[%jibb])
6377 =/ at=path (weld path.i.imports `path`~[%jibb])
10635− ?: =(at /lib/jibb/internal/jibb)
10636− [%| 'the prelude internal module is private']
10637− ?: =(at /lib/jibb/primitives/jibb)
10638− [%| 'the prelude primitive interface is private']
10639 ?: (lien active |=(p=path =(p at)))
6378 ?: (lien active |=(p=path =(p at)))
10640 [%| (crip "import cycle at {(spud at)}")]
6379 [%| (crip "import cycle at {(spud at)}")]
10641 =/ found=jbundle (skim modules |=(m=jsource =(at at.m)))
6380 =/ found=jbundle (skim modules |=(m=jsource =(at at.m)))
@@ -10643,863 +6382,38 @@
10643 ?^ t.found [%| (crip "duplicate module sources: {(spud at)}")]
6382 ?^ t.found [%| (crip "duplicate module sources: {(spud at)}")]
10644 =/ cached=(unit ifile) (find-jibb-cache at cache)
6383 =/ cached=(unit ifile) (find-jibb-cache at cache)
10645 =/ iface=jfile-result
6384 =/ iface=jfile-result
10647− ?. =(at.u.cached at) [%| 'cached module identity needs unsupported inference']
10649− :: A detached legacy interface has unknown evidence. Rebuild it
10650− :: against the current graph, without retaining any stale entry.
10651− =/ clean=jcache (skim cache |=(x=[at=path iface=ifile] !=(at.x at)))
10652− (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds clean prelude)
10653− ?. (request-graph-reusable u.cached source.i.found externals mark-externals modules active prelude-values prelude-molds prelude)
10654− [%| 'cached module evidence needs unsupported inference']
10655− [%& [u.cached cache]]
6385+ ?^ cached [%& [u.cached cache]]
10656− (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
6386+ (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache)
10657 ?: ?=(%| -.iface) [%| p.iface]
6387 ?: ?=(%| -.iface) [%| p.iface]
10658 =/ rest=jimports-result $(imports t.imports, cache cache.p.iface)
6388 =/ rest=jimports-result $(imports t.imports, cache cache.p.iface)
10659 ?: ?=(%| -.rest) rest
6389 ?: ?=(%| -.rest) rest
10660 [%& [[[face.i.imports iface.p.iface] resolved.p.rest] cache.p.rest]]
6390 [%& [[[face.i.imports iface.p.iface] resolved.p.rest] cache.p.rest]]
10662−:: Provisional declaration extraction only; this does not derive asks,
10663−:: validate imported types, or claim that an API module has checked.
10664−+$ iapi-path [at=span name=term segments=(list pseg) full=term diffs=(list term) scry=(unit (list pseg))]
10666− |= [sh=shape marks=(list term)]
10668− ?. ?=(%ref -.sh) ~
10669− ?. ?=([@ ~] names.sh) ~
10670− ?. (unique-value-name i.names.sh marks) ~
10674− |= [shapes=(list shape) marks=(list term) used=(list term)]
10675− ^- (unit (list term))
10677− =/ n=(unit term) (api-path-mark i.shapes marks)
10679− ?: (lien used |=(x=term =(x u.n))) ~
10680− =/ rest=(unit (list term)) $(shapes t.shapes, used [u.n used])
10684−++ api-path-payload
10685− |= [sh=shape marks=(list term)]
10686− ^- (unit [full=term diffs=(list term)])
10687− =/ direct=(unit term) (api-path-mark sh marks)
10688− ?^ direct `[u.direct ~]
10689− ?. ?=(%apply -.sh) ~
10690− ?. =(~[%facts] ref.sh) ~
10693− =/ full=(unit term) (api-path-mark i.args.sh marks)
10695− =/ diffs=(unit (list term)) (api-path-diffs t.args.sh marks ~[u.full])
10699−+$ iapi-parameter [name=term aura=@ta at=span]
10700−++ api-path-parameters
10701− |= [segments=(list pseg) seen=(list term)]
10702− ^- (unit (list iapi-parameter))
10704− ?: ?=(%knot -.i.segments) $(segments t.segments)
10705− =/ seg=pseg i.segments
10706− ?. ?=(%typed -.seg) ~
10707− ?: =(0 aura.seg) ~
10708− ?: (lien seen |=(n=term =(n name.seg))) ~
10709− =/ rest=(unit (list iapi-parameter)) $(segments t.segments, seen [name.seg seen])
10711− `[[name.seg aura.seg at.seg] u.rest]
10713−++ api-scry-parameters-compatible
10714− |= [scry=(list iapi-parameter) watch=(list iapi-parameter)]
10717− ?. (lien watch |=(p=iapi-parameter &(=(name.p name.i.scry) =(aura.p aura.i.scry)))) |
10721− |= [sh=shape marks=(list term)]
10722− ^- (unit iapi-path)
10723− ?. ?=(%cell -.sh) ~
10724− =/ fs=(list field) fields.sh
10728− ?: (gth (lent fs) 4) ~
10729− ?. ?=(%bare -.i.fs) ~
10730− =/ tag=shape shape.i.fs
10731− ?. ?=(%const -.tag) ~
10732− ?. =(%term form.lit.tag) ~
10733− =/ name=term val.lit.tag
10734− ?. (jibb-face-name name) ~
10735− ?. ?=(%bare -.i.t.fs) ~
10736− =/ path-shape=shape shape.i.t.fs
10737− ?. ?=(%path -.path-shape) ~
10738− ?. ?=(%bare -.i.t.t.fs) ~
10739− =/ payload=(unit [full=term diffs=(list term)]) (api-path-payload shape.i.t.t.fs marks)
10741− =/ scry=(unit (unit (list pseg)))
10743− =/ entry=field i.t.t.t.fs
10744− ?. ?=(%face -.entry) ~
10745− ?. =(%scry name.entry) ~
10746− ?. ?=(%path -.shape.entry) ~
10747− ``segs.shape.entry
10749− =/ params=(unit (list iapi-parameter)) (api-path-parameters segs.path-shape ~)
10752− =/ scry-params=(unit (list iapi-parameter)) (api-path-parameters u.u.scry ~)
10754− ?. (api-scry-parameters-compatible u.scry-params u.params) ~
10755− `[at.sh name segs.path-shape full.u.payload diffs.u.payload u.scry]
10756− `[at.sh name segs.path-shape full.u.payload diffs.u.payload u.scry]
10759− |= [shapes=(list shape) marks=(list term) seen=(list term)]
10760− ^- (unit (list iapi-path))
10762− =/ one=(unit iapi-path) (api-path-one i.shapes marks)
10764− ?: (lien seen |=(n=term =(n name.u.one))) ~
10765− =/ rest=(unit (list iapi-path)) $(shapes t.shapes, seen [name.u.one seen])
10769−++ api-path-declaration
10770− |= [sh=shape marks=(list term)]
10771− ^- (unit (list iapi-path))
10772− ?: ?=(%union -.sh) (api-path-many cases.sh marks ~)
10773− (api-path-many ~[sh] marks ~)
10775−:: Derived gates share the value namespace. /% marks name molds; /- and
10776−:: /= also introduce faces that cannot be shadowed by a derived value.
10777−++ api-import-faces
10778− |= imports=(list import)
10782− %mark $(imports t.imports)
10783− %sur [name.i.imports $(imports t.imports)]
10784− %jibb [face.i.imports $(imports t.imports)]
10787−++ api-derived-names-valid
10788− |= [paths=(list iapi-path) poke-names=(list term) mod=module prelude-values=(list term)]
10790− =/ path-names=(list term) (turn paths |=(p=iapi-path name.p))
10791− =/ derived=(list term) (weld path-names poke-names)
10792− ?: (lien derived |=(n=term =(n %proj))) |
10793− =/ outer=(list term) (weld prelude-values (weld (global-value-names defs.mod) (api-import-faces imports.mod)))
10794− (levy derived |=(n=term &((unique-value-name n derived) !(lien outer |=(x=term =(n x))))))
10796−:: Analysis only. Successful external entries must be unchanged results
10797−:: produced for the declared marks; no request interface is produced.
10798−+$ iapi-mark-type [name=term typ=itype]
10799−+$ iapi-path-typed [path=iapi-path full=itype diffs=(list iapi-mark-type)]
10801− |= [names=(list term) externals=imark-externals declared=(list term)]
10802− ^- (unit (list iapi-mark-type))
10804− =/ typ=(unit itype) (find-imported-mark i.names externals declared)
10806− =/ tail=(unit (list iapi-mark-type)) $(names t.names)
10808− `[[i.names u.typ] u.tail]
10811− |= [paths=(list iapi-path) externals=imark-externals declared=(list term)]
10812− ^- (unit (list iapi-path-typed))
10814− =/ full=(unit itype) (find-imported-mark full.i.paths externals declared)
10816− =/ diffs=(unit (list iapi-mark-type)) (api-diff-types diffs.i.paths externals declared)
10818− =/ tail=(unit (list iapi-path-typed)) $(paths t.paths)
10820− `[[i.paths u.full u.diffs] u.tail]
10822−++ api-poke-mark-names
10823− |= [pokes=(list def) declared=(list term)]
10824− ^- (unit (list term))
10828− ?. ?=(%mold -.d) ~
10829− =/ sh=shape shape.d
10830− ?: ?=(%union -.sh) (api-path-diffs cases.sh declared ~)
10831− =/ name=(unit term) (api-path-mark sh declared)
10835−++ api-path-analysis
10836− |= [mod=module externals=imark-externals prelude-values=(list term) prelude-molds=(list term)]
10837− ^- (unit (list iapi-path-typed))
10838− ?: (lien defs.mod def-has-hole) ~
10839− ?^ (duplicate-defs defs.mod) ~
10840− =/ ds=(list def) defs.mod
10841− =/ declarations=(list def)
10842− (skim ds |=(d=def &(?=(%mold -.d) =(%paths name.d))))
10843− ?. ?=([* ~] declarations) ~
10844− =/ pokes=(list def)
10845− (skim ds |=(d=def &(?=(%mold -.d) =(%poke name.d))))
10846− ?: (gth (lent pokes) 1) ~
10847− =/ ordinary=(list def)
10848− (skim ds |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
10849− ?. (module-scope-valid mod(defs ordinary) prelude-values prelude-molds) ~
10850− =/ declared=(list term) (collect-mark-imports imports.mod)
10851− =/ poke-names=(unit (list term)) (api-poke-mark-names pokes declared)
10853− =/ decl=def i.declarations
10854− ?> ?=(%mold -.decl)
10855− =/ paths=(unit (list iapi-path)) (api-path-declaration shape.decl declared)
10857− ?. (api-derived-names-valid u.paths u.poke-names mod prelude-values) ~
10858− (api-path-types u.paths externals declared)
10860−:: Source/graph entry for path analysis only. The returned paths retain
10861−:: reader-derived mark types and import resolution has checked reachable
10862−:: Jibb dependencies. This is not an API interface or a module check.
10863−++ api-path-analysis-source
10864− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
10865− ^- (each (list iapi-path-typed) @t)
10866− ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path analysis requires /ui/api/<agent>.jibb']
10867− =/ parsed (parse file src)
10868− ?: ?=(%| -.parsed) [%| 'API path source does not parse']
10869− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
10870− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
10871− ?~ prepared [%| 'API path analysis needs the prepared prelude']
10872− =/ prelude=(unit ifile) `iface.u.prepared
10873− =/ deps=jimports-result
10874− (resolve-jibb-imports imports.p.parsed externals marks modules ~[file] values.u.prepared molds.u.prepared ~ prelude)
10875− ?: ?=(%| -.deps) [%| p.deps]
10876− =/ paths=(unit (list iapi-path-typed))
10877− (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
10878− ?~ paths [%| 'API path declaration needs unsupported analysis']
10881−:: Analysis evidence retains the API source, the prepared interface, the
10882−:: caller's reader results and the resolved Jibb dependency cache alongside
10883−:: the typed path declarations. Reader results and prepared interfaces are
10884−:: trusted inputs: this does not verify their underlying Hoon source/version,
10885−:: create requests or check the provenance of arbitrary values.
10886−+$ iapi-path-evidence
10887− [at=path source=@t prepared=iprelude externals=iexternals marks=imark-externals dependencies=jcache paths=(list iapi-path-typed)]
10888−++ api-path-evidence-source
10889− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
10890− ^- (each iapi-path-evidence @t)
10891− ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path evidence requires /ui/api/<agent>.jibb']
10892− =/ parsed (parse file src)
10893− ?: ?=(%| -.parsed) [%| 'API path evidence source does not parse']
10894− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
10895− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
10896− ?~ prepared [%| 'API path evidence needs the prepared prelude']
10897− =/ public=ifile iface.u.prepared
10898− =/ deps=jimports-result
10899− (resolve-jibb-imports imports.p.parsed externals marks modules ~[file] values.u.prepared molds.u.prepared ~ `public)
10900− ?: ?=(%| -.deps) [%| p.deps]
10901− =/ paths=(unit (list iapi-path-typed))
10902− (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
10903− ?~ paths [%| 'API path declaration needs unsupported analysis']
10904− [%& [file src u.prepared externals marks cache.p.deps u.paths]]
10905−:: Graph-aware variant preserves the caller active stack and cache.
10906−++ api-path-evidence-graph
10907− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
10908− ^- (each iapi-path-evidence @t)
10909− ?~ active [%| 'API analysis needs an active graph']
10910− ?. =(i.active file) [%| 'API analysis active graph does not start at the source']
10911− ?: (lien t.active |=(p=path =(p file))) [%| 'API analysis active graph contains a cycle']
10912− ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path evidence requires /ui/api/<agent>.jibb']
10913− =/ parsed (parse file src)
10914− ?: ?=(%| -.parsed) [%| 'API path evidence source does not parse']
10915− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
10916− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
10917− ?~ prepared [%| 'API path evidence needs the prepared prelude']
10918− =/ public=ifile iface.u.prepared
10919− =/ deps=jimports-result
10920− (resolve-jibb-imports imports.p.parsed externals marks modules active values.u.prepared molds.u.prepared cache `public)
10921− ?: ?=(%| -.deps) [%| p.deps]
10922− =/ paths=(unit (list iapi-path-typed))
10923− (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
10924− ?~ paths [%| 'API path declaration needs unsupported analysis']
10925− [%& [file src u.prepared externals marks cache.p.deps u.paths]]
10927−:: This query classifies a unique path declaration only. Missing evidence
10928−:: or a nonunique name is unknown; it proves nothing about an ask value.
10929−:: Like prepared interfaces, the supplied evidence is a trusted host input.
10930−++ api-path-watchability
10931− |= [evidence=(unit iapi-path-evidence) case-name=term]
10932− ^- ?(%watchable %not-watchable %unknown)
10933− ?~ evidence %unknown
10934− =/ found=(list iapi-path-typed)
10935− (skim paths.u.evidence |=(p=iapi-path-typed =(name.path.p case-name)))
10936− ?. ?=([* ~] found) %unknown
10937− ?~ scry.path.i.found %watchable
10940−:: These are declaration-derived request components, not a callable gate,
10941−:: an ask value, or proof of a value's provenance. Keep the exact trusted
10942−:: source/reader evidence until a later checked interface and lowerer can
10943−:: attach it to a generated request. No argument ordering is claimed here.
10944−+$ iapi-request-parameter [name=term typ=itype at=span]
10945−+$ iapi-request-parts
10946− [evidence=iapi-path-evidence path=iapi-path-typed parameters=(list iapi-request-parameter) reply-sample=itype fold=(unit itype) watchability=?(%watchable %not-watchable)]
10947−++ api-request-parameter-types
10948− |= params=(list iapi-parameter)
10949− ^- (unit (list iapi-request-parameter))
10951− =/ aura=@ta aura.i.params
10952− ?. |(?=(?(%u %ud %ux %uv %t %ta %tas %p %da %dr) aura) =('tD' aura)) ~
10953− =/ rest=(unit (list iapi-request-parameter)) $(params t.params)
10955− `[[name.i.params [%atom aura] at.i.params] u.rest]
10957−:: A single diff's fold consumes the tagged diff and the previous full value.
10958−:: Multiple-diff unions need a checked union representation and remain open.
10959−++ api-request-fold-type
10960− |= p=iapi-path-typed
10961− ^- (unit (unit itype))
10964− =/ d=iapi-mark-type i.diffs.p
10965− =/ literal=lit [%term %tas name.d (crip ['%' (trip name.d)])]
10966− =/ sample=itype [%cell [%cell [%const literal] typ.d] full.p]
10967− ``[%fn sample full.p]
10969−++ api-request-parts
10970− |= [evidence=(unit iapi-path-evidence) case-name=term]
10971− ^- (unit iapi-request-parts)
10973− =/ found=(list iapi-path-typed)
10974− (skim paths.u.evidence |=(p=iapi-path-typed =(name.path.p case-name)))
10975− ?. ?=([* ~] found) ~
10976− =/ p=iapi-path-typed i.found
10977− =/ raw=(unit (list iapi-parameter)) (api-path-parameters segments.path.p ~)
10979− =/ params=(unit (list iapi-request-parameter)) (api-request-parameter-types u.raw)
10981− =/ fold=(unit (unit itype)) (api-request-fold-type p)
10983− =/ watch=?(%watchable %not-watchable) ?~(scry.path.p %watchable %not-watchable)
10984− `[u.evidence p u.params full.p u.fold watch]
10986−:: Check ordinary API molds and values plus every declared mark type using
10987−:: the same trusted source, prepared prelude and reader inputs as path
10988−:: evidence. Keep elaborations with those inputs for a later interface.
10989−:: This is partial analysis: an unused /- core is not independently checked,
10990−:: definitions needing derived values remain unsupported, and no complete
10991−:: API, request or constructor is exported or given runtime behavior.
10992−+$ iapi-support-evidence
10993− [paths=iapi-path-evidence values=ienv molds=imold-types marks=(list iapi-mark-type) elaborations=(list iwidth-definition)]
10994−++ api-support-analysis-source
10995− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
10996− ^- (each iapi-support-evidence @t)
10997− =/ path-result (api-path-evidence-source file src externals marks modules prepared)
10998− ?: ?=(%| -.path-result) [%| p.path-result]
10999− =/ evidence=iapi-path-evidence p.path-result
11000− =/ parsed (parse file src)
11001− ?: ?=(%| -.parsed) [%| 'API source does not parse']
11002− =/ mod=module p.parsed
11003− =/ ordinary=(list def)
11004− (skim defs.mod |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
11005− =/ prep=iprelude prepared.evidence
11006− ?. (module-scope-valid mod(defs ordinary) values.prep molds.prep) [%| 'API ordinary scope needs unsupported inference']
11007− =/ vals=(list term) (global-value-names ordinary)
11008− ?: (lien vals |=(n=term =(n %main))) [%| 'API module kind needs unsupported inference']
11009− =/ declared=(list term) (collect-mark-imports imports.mod)
11010− =/ mark-types=(unit (list iapi-mark-type)) (api-diff-types declared marks declared)
11011− ?~ mark-types [%| 'API declared marks need unsupported inference']
11012− =/ prelude=(unit ifile) `iface.prep
11013− =/ deps=jimports-result
11014− (resolve-jibb-imports imports.mod externals marks modules ~[file] values.prep molds.prep dependencies.evidence prelude)
11015− ?: ?=(%| -.deps) [%| p.deps]
11016− =/ molds=imolds (collect-simple-molds ordinary)
11017− =/ globals=(list term) (weld values.prep (weld (import-binding-names imports.mod) vals))
11018− =/ surs=(list term) (collect-sur-imports imports.mod)
11019− =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
11020− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11021− =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~]
11022− =/ mts=(each imold-types @t) (module-mold-types molds state)
11023− ?: ?=(%| -.mts) [%| p.mts]
11024− =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
11025− ?. (module-values-complete ordinary env.resolution) [%| 'API ordinary definitions need unsupported inference']
11026− [%& [evidence env.resolution p.mts u.mark-types artifacts.resolution]]
11027−:: Preserve the same graph context through supporting definitions.
11028−++ api-support-analysis-graph
11029− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
11030− ^- (each iapi-support-evidence @t)
11031− =/ path-result (api-path-evidence-graph file src externals marks modules active cache prepared)
11032− ?: ?=(%| -.path-result) [%| p.path-result]
11033− =/ evidence=iapi-path-evidence p.path-result
11034− =/ parsed (parse file src)
11035− ?: ?=(%| -.parsed) [%| 'API source does not parse']
11036− =/ mod=module p.parsed
11037− =/ ordinary=(list def)
11038− (skim defs.mod |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
11039− =/ prep=iprelude prepared.evidence
11040− ?. (module-scope-valid mod(defs ordinary) values.prep molds.prep) [%| 'API ordinary scope needs unsupported inference']
11041− =/ vals=(list term) (global-value-names ordinary)
11042− ?: (lien vals |=(n=term =(n %main))) [%| 'API module kind needs unsupported inference']
11043− =/ declared=(list term) (collect-mark-imports imports.mod)
11044− =/ mark-types=(unit (list iapi-mark-type)) (api-diff-types declared marks declared)
11045− ?~ mark-types [%| 'API declared marks need unsupported inference']
11046− =/ prelude=(unit ifile) `iface.prep
11047− =/ deps=jimports-result
11048− (resolve-jibb-imports imports.mod externals marks modules active values.prep molds.prep dependencies.evidence prelude)
11049− ?: ?=(%| -.deps) [%| p.deps]
11050− =/ molds=imolds (collect-simple-molds ordinary)
11051− =/ globals=(list term) (weld values.prep (weld (import-binding-names imports.mod) vals))
11052− =/ surs=(list term) (collect-sur-imports imports.mod)
11053− =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
11054− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11055− =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~]
11056− =/ mts=(each imold-types @t) (module-mold-types molds state)
11057− ?: ?=(%| -.mts) [%| p.mts]
11058− =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
11059− ?. (module-values-complete ordinary env.resolution) [%| 'API ordinary definitions need unsupported inference']
11060− [%& [evidence env.resolution p.mts u.mark-types artifacts.resolution]]
11062−:: Type-analysis artifact for one plain request. The resolver may publish
11063−:: its interface only together with trusted source and reader evidence.
11064−:: No lowering or runtime validator exists.
11065−:: Value watchability remains unproved even for a watchable declaration.
11066−+$ ione-request-interface
11067− [support=iapi-support-evidence parts=iapi-request-parts iface=ifile]
11068−++ request-compatible-ask
11069− |= prelude=iprelude
11071− =/ public=ifile iface.prelude
11072− ?. =(at.public /lib/jibb/prelude/jibb) ~
11073− =/ ask=(unit ischeme) (find-jibb-mold %ask public)
11075− ?. ?=([@ ~] vars.u.ask) ~
11076− ?. ?=(%union -.typ.u.ask) ~
11077− ?. =(origin.typ.u.ask `[/lib/jibb/internal/jibb %ask]) ~
11078− ?. (identity-union-parameters vars.u.ask args.typ.u.ask) ~
11079− =/ m=@ud i.vars.u.ask
11080− ?: (itype-var-is-atom m typ.u.ask) ~
11081− ?. (levy (itype-vars typ.u.ask) |=(n=@ud =(n m))) ~
11082− ?: (itype-has-tag typ.u.ask) ~
11083− =/ private=(list iwidth-dependency)
11084− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
11085− ?. ?=([* ~] private) ~
11086− ?~ source.i.private ~
11087− =/ path=(unit ischeme) (find-jibb-mold %path public)
11090− =/ path-type=itype [%collection %list ~[[%atom %ta]]]
11091− ?. =(typ.u.path path-type) ~
11092− =/ unit-template=(unit ischeme) (find-jibb-mold %unit public)
11093− ?~ unit-template ~
11094− ?. (standard-unit-template u.unit-template /lib/jibb/prelude/jibb) ~
11095− =/ state-unit=(unit itype) (template-apply u.unit-template ~[[%noun ~]])
11097− =/ path-unit=(unit itype) (template-apply u.unit-template ~[path-type])
11099− =/ output=itype [%cell [%face %state [%noun ~]] [%face %message [%var m]]]
11100− =/ agent-input=itype [%cell [%face %mark [%atom %tas]] [%cell [%face %state u.state-unit] [%face %fact [%noun ~]]]]
11101− =/ store-input=itype [%cell [%face %state u.state-unit] [%face %fact [%noun ~]]]
11102− =/ pure-case=itype [%cell [%const [%term %tas %pure '%pure']] [%face %value [%var m]]]
11103− =/ agent-case=itype
11104− [%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]]]]]]]]
11105− =/ store-case=itype
11106− [%cell [%const [%term %tas %store '%store']] [%cell [%face %module [%atom %t]] [%cell [%face %name [%atom %tas]] [%face %receive [%fn store-input output]]]]]
11107− ?. =(cases.typ.u.ask ~[pure-case agent-case store-case]) ~
11110−:: The first supported standalone API has exactly one mark import and one
11111−:: plain path declaration, with no other definitions or imports. No partial
11112−:: success is published when source, schema, or a required mold is unknown.
11113−++ one-request-interface-source
11114− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
11115− ^- (each ione-request-interface @t)
11116− =/ out (api-support-analysis-source file src externals marks modules prepared)
11117− ?: ?=(%| -.out) [%| p.out]
11118− =/ support=iapi-support-evidence p.out
11119− =/ ev=iapi-path-evidence paths.support
11120− =/ parsed (parse file src)
11121− ?: ?=(%| -.parsed) [%| 'request source does not parse']
11122− =/ mod=module p.parsed
11123− ?. ?=(?([[%mark *] ~] [[%mark *] [%mark *] ~]) imports.mod) [%| 'request imports need unsupported inference']
11124− ?. ?=([[%mold *] ~] defs.mod) [%| 'request definitions need unsupported inference']
11125− ?. =(%paths name.i.defs.mod) [%| 'request declaration needs unsupported inference']
11126− ?. ?=([* ~] paths.ev) [%| 'request count needs unsupported inference']
11127− =/ p=iapi-path-typed i.paths.ev
11128− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
11129− ?~ parts [%| 'request components need unsupported inference']
11130− ?. ?=(?(~ [* ~]) parameters.u.parts) [%| 'request parameters need unsupported inference']
11131− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) [%| 'request parameter and fold need unsupported inference']
11132− ?^ scry.path.p [%| 'request scry needs unsupported inference']
11134− ?~ fold.u.parts ?=([* ~] marks.support)
11135− ?=([* [* ~]] marks.support)
11136− ?. valid-marks [%| 'request marks need unsupported inference']
11139− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
11140− ?: fold-open [%| 'request fold needs unsupported inference']
11141− ?^ (itype-vars reply-sample.u.parts) [%| 'request payload needs unsupported inference']
11142− ?: (itype-has-tag reply-sample.u.parts) [%| 'request payload needs unsupported inference']
11143− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
11144− ?~ ask [%| 'request ask needs unsupported inference']
11145− =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
11146− ?~ result [%| 'request ask needs unsupported inference']
11147− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
11149− ?^ fold.u.parts [%cell callback u.fold.u.parts]
11150− ?~ parameters.u.parts callback
11151− [%cell typ.i.parameters.u.parts callback]
11152− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
11153− =/ exports=imold-types
11154− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
11155− =/ prelude=iprelude prepared.ev
11156− =/ public=ifile iface.prelude
11157− ?~ source.public [%| 'request prelude source needs unsupported inference']
11158− =/ private=(list iwidth-dependency)
11159− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
11160− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
11161− ?~ source.i.private [%| 'request internal source needs unsupported inference']
11162− =/ req=irequest-evidence
11163− [file name.path.p p src u.source.public u.source.i.private values.prelude molds.prelude externals marks]
11164− =/ interface=ifile [~[[name.path.p scheme]] exports file ~ ~ ~ `src `[(silt `(list path)`~[file]) ~[req] modules `public values.prelude molds.prelude externals marks]]
11165− [%& [support u.parts interface]]
11166−:: Graph-aware request artifact; resolver use remains type-only.
11167−++ one-request-interface-graph
11168− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
11169− ^- (each ione-request-interface @t)
11170− =/ out (api-support-analysis-graph file src externals marks modules active cache prepared)
11171− ?: ?=(%| -.out) [%| p.out]
11172− =/ support=iapi-support-evidence p.out
11173− =/ ev=iapi-path-evidence paths.support
11174− =/ parsed (parse file src)
11175− ?: ?=(%| -.parsed) [%| 'request source does not parse']
11176− =/ mod=module p.parsed
11177− ?. ?=(?([[%mark *] ~] [[%mark *] [%mark *] ~]) imports.mod) [%| 'request imports need unsupported inference']
11178− ?. ?=([[%mold *] ~] defs.mod) [%| 'request definitions need unsupported inference']
11179− ?. =(%paths name.i.defs.mod) [%| 'request declaration needs unsupported inference']
11180− ?. ?=([* ~] paths.ev) [%| 'request count needs unsupported inference']
11181− =/ p=iapi-path-typed i.paths.ev
11182− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
11183− ?~ parts [%| 'request components need unsupported inference']
11184− ?. ?=(?(~ [* ~]) parameters.u.parts) [%| 'request parameters need unsupported inference']
11185− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) [%| 'request parameter and fold need unsupported inference']
11186− ?^ scry.path.p [%| 'request scry needs unsupported inference']
11188− ?~ fold.u.parts ?=([* ~] marks.support)
11189− ?=([* [* ~]] marks.support)
11190− ?. valid-marks [%| 'request marks need unsupported inference']
11193− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
11194− ?: fold-open [%| 'request fold needs unsupported inference']
11195− ?^ (itype-vars reply-sample.u.parts) [%| 'request payload needs unsupported inference']
11196− ?: (itype-has-tag reply-sample.u.parts) [%| 'request payload needs unsupported inference']
11197− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
11198− ?~ ask [%| 'request ask needs unsupported inference']
11199− =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
11200− ?~ result [%| 'request ask needs unsupported inference']
11201− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
11203− ?^ fold.u.parts [%cell callback u.fold.u.parts]
11204− ?~ parameters.u.parts callback
11205− [%cell typ.i.parameters.u.parts callback]
11206− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
11207− =/ exports=imold-types
11208− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
11209− =/ prelude=iprelude prepared.ev
11210− =/ public=ifile iface.prelude
11211− ?~ source.public [%| 'request prelude source needs unsupported inference']
11212− =/ private=(list iwidth-dependency)
11213− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
11214− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
11215− ?~ source.i.private [%| 'request internal source needs unsupported inference']
11216− =/ req=irequest-evidence
11217− [file name.path.p p src u.source.public u.source.i.private values.prelude molds.prelude externals marks]
11218− =/ interface=ifile [~[[name.path.p scheme]] exports file ~ ~ ~ `src `[(silt `(list path)`~[file]) ~[req] modules `public values.prelude molds.prelude externals marks]]
11219− [%& [support u.parts interface]]
11221−++ api-mark-exports
11222− |= [marks=(list term) all=(list term) externals=imark-externals]
11225− =/ t=(unit itype) (find-imported-mark i.marks externals all)
11226− ?~ t $(marks t.marks)
11227− [[i.marks [u.t ~]] $(marks t.marks)]
11229−:: Experimental direct poke-only API. Unsupported API declarations fail
11230−:: as a whole; supplied mark reader results retain their existing boundary.
11231−++ api-poke-interface
11232− |= [at=path mod=module mark-externals=imark-externals prelude-values=(list term) prelude-molds=(list term) prelude=(unit ifile)]
11234− ?: (lien defs.mod def-has-hole) ~
11235− ?. ?=([%ui %api @ %jibb ~] at) ~
11236− ?^ (duplicate-defs defs.mod) ~
11238− ?. =(at.u.prelude /lib/jibb/prelude/jibb) ~
11239− =/ poke=(unit ischeme) (find-jibb-mold %poke u.prelude)
11241− ?. ?=(%union -.typ.u.poke) ~
11244− %+ lien cases.typ.u.poke
11246− ?=([%cell [%const [%term %tas %agent *]] [%cell [%face %agent [%atom %tas]] [%cell [%face %mark [%atom %tas]] [%face %payload [%noun ~]]]]] c)
11248− ?. (module-scope-valid mod(defs ~) prelude-values prelude-molds) ~
11249− ?. (levy imports.mod |=(i=import ?=(%mark -.i))) ~
11250− =/ marks=(list term) (collect-mark-imports imports.mod)
11251− ?. ?=([@ ~] marks) ~
11252− =/ ds=(list def) defs.mod
11253− ?. ?=([[%mold *] ~] ds) ~
11254− ?. =(%poke name.i.ds) ~
11255− =/ sh=shape shape.i.ds
11256− ?. ?=([%ref *] sh) ~
11257− ?. ?=([@ ~] names.sh) ~
11258− =/ n=term i.names.sh
11259− ?. (unique-value-name n marks) ~
11260− ?: |((lien prelude-values |=(x=term =(n x))) (lien prelude-molds |=(x=term =(n x)))) ~
11261− =/ mark=(unit itype) (find-imported-mark n mark-externals marks)
11263− =/ sc=ischeme [[%fn u.mark typ.u.poke] ~]
11264− `[~[[n sc]] (api-mark-exports marks marks mark-externals) at ~[[n i.t.t.at n]] ~ ~ ~ ~]
11266−:: Source-proven ordinary helpers validate each selected /sur dependency.
11267−:: Unused or less direct cores remain unsupported by this first interface.
11269− |= [surs=(list term) defs=(list def) externals=iexternals all=(list term)]
11272− =/ found=(list def)
11275− ?. ?=(%mold -.d) |
11276− ?. ?=(%ref -.shape.d) |
11277− ?. ?=([@ [@ ~]] names.shape.d) |
11278− =(i.t.names.shape.d i.surs)
11280− =/ selected=def i.found
11281− ?. ?=(%mold -.selected) |
11282− =/ sh=shape shape.selected
11283− ?. ?=(%ref -.sh) |
11284− ?. ?=([@ [@ ~]] names.sh) |
11285− =/ checked=(unit itype) (find-imported-mold i.surs i.names.sh externals all)
11289−+$ imulti-request-gates [values=ienv requests=(list irequest-evidence)]
11290−++ api-request-gates
11291− |= [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]
11292− ^- (unit imulti-request-gates)
11295− =/ p=iapi-path-typed i.paths
11296− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
11298− ?. ?=(?(~ [* ~]) parameters.u.parts) ~
11299− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) ~
11301− ?^ (itype-vars reply-sample.u.parts) ~
11302− ?: (itype-has-tag reply-sample.u.parts) ~
11305− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
11307− =/ result=(unit itype) (template-apply ask ~[[%var 0]])
11309− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
11311− ?^ fold.u.parts [%cell callback u.fold.u.parts]
11312− ?~ parameters.u.parts callback
11313− [%cell typ.i.parameters.u.parts callback]
11314− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
11315− =/ prep=iprelude prepared.ev
11316− =/ req=irequest-evidence
11317− [file name.path.p p src public internal values.prep molds.prep externals marks]
11318− =/ rest=(unit imulti-request-gates)
11319− $(paths t.paths, fuel (dec fuel))
11321− `[[[name.path.p scheme] values.u.rest] [req requests.u.rest]]
11323−++ api-poke-from-checked
11324− |= [file=path mod=module marks=imark-externals values=(list term) molds=(list term) prelude=(unit ifile)]
11325− ^- (unit [values=ienv derived=(list iderived)])
11326− =/ pokes=(list def)
11327− (skim defs.mod |=(d=def &(?=(%mold -.d) =(%poke name.d))))
11329− ?. ?=([* ~] pokes) ~
11330− =/ declared=(list term) (collect-mark-imports imports.mod)
11331− =/ ns=(unit (list term)) (api-poke-mark-names pokes declared)
11333− ?. ?=([@ ~] u.ns) ~
11334− =/ matching=(list import)
11335− %+ skim imports.mod
11337− ?. ?=(%mark -.i) |
11339− ?. ?=([* ~] matching) ~
11340− =/ checked=(unit ifile)
11341− (api-poke-interface file mod(defs pokes, imports matching) marks values molds prelude)
11343− `[values.u.checked derived.u.checked]
11345−:: The partial interface is published atomically: all paths, ordinary
11346−:: source definitions, declared marks and the poke must check. Unselected
11347−:: /sur bindings, runtime validation and value watchability remain unproved.
11348−++ multi-request-interface-graph
11349− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
11350− ^- (each [iface=ifile cache=jcache] @t)
11351− =/ out (api-support-analysis-graph file src externals marks modules active cache prepared)
11352− ?: ?=(%| -.out) [%| p.out]
11353− =/ support=iapi-support-evidence p.out
11354− =/ ev=iapi-path-evidence paths.support
11355− =/ parsed (parse file src)
11356− ?: ?=(%| -.parsed) [%| 'request source does not parse']
11357− =/ mod=module p.parsed
11358− ?. (levy imports.mod |=(i=import ?=(?(%mark %sur) -.i)))
11359− [%| 'request imports need unsupported inference']
11360− =/ surs=(list term) (collect-sur-imports imports.mod)
11361− ?. (api-sur-covered surs defs.mod externals surs)
11362− [%| 'API source dependency needs unsupported inference']
11363− ?~ paths.ev [%| 'request count needs unsupported inference']
11364− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
11365− ?~ ask [%| 'request ask needs unsupported inference']
11366− =/ prep=iprelude prepared.ev
11367− =/ public=ifile iface.prep
11368− ?~ source.public [%| 'request prelude source needs unsupported inference']
11369− =/ private=(list iwidth-dependency)
11370− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
11371− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
11372− ?~ source.i.private [%| 'request internal source needs unsupported inference']
11373− =/ gates=(unit imulti-request-gates)
11374− (api-request-gates paths.ev ev u.ask file src u.source.public u.source.i.private externals marks 256)
11375− ?~ gates [%| 'request paths need unsupported inference']
11376− =/ poke=(unit [values=ienv derived=(list iderived)])
11377− (api-poke-from-checked file mod marks values.prep molds.prep `public)
11378− ?~ poke [%| 'API poke needs unsupported inference']
11379− =/ mark-molds=imold-types
11380− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
11381− =/ exports=imold-types (weld mark-molds molds.support)
11382− =/ names=(list term) (turn exports |=(m=[name=term template=ischeme] name.m))
11383− ?. (levy names |=(n=term (unique-value-name n names)))
11384− [%| 'API exported molds need unsupported inference']
11385− =/ env=ienv (weld values.u.gates (weld values.u.poke values.support))
11386− =/ graph=irequest-graph
11387− [(silt `(list path)`~[file]) requests.u.gates modules `public values.prep molds.prep externals marks]
11389− [env exports file derived.u.poke elaborations.support ~ `src `graph]
11390− [%& [iface dependencies.ev]]
11392++ infer-jibb-file
6392++ infer-jibb-file
11393− |= [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)]
6393+ |= [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]
11394 ^- jfile-result
6394 ^- jfile-result
6395+ ?: ?=([%ui %api *] at) [%| (crip "API module needs unsupported inference: {(spud at)}")]
11395 =/ parsed (parse at src)
6396 =/ parsed (parse at src)
11396 ?: ?=(%| -.parsed) [%| (crip "module source does not parse: {(spud at)}")]
6397 ?: ?=(%| -.parsed) [%| (crip "module source does not parse: {(spud at)}")]
11397 =/ mod=module p.parsed
6398 =/ mod=module p.parsed
11398− =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
11399− ?^ duplicate [%| (show-duplicate-fields at src u.duplicate)]
11400− ?: ?=([%ui %api *] at)
11401− =/ iface=(unit ifile) (api-poke-interface at mod mark-externals prelude-values prelude-molds prelude)
11403− =/ checked=ifile u.iface(source `src, graph `[(silt `(list path)`~[at]) ~ modules prelude prelude-values prelude-molds externals mark-externals])
11404− [%& [checked [[at checked] cache]]]
11405− ?~ prelude [%| (crip "API module needs unsupported inference: {(spud at)}")]
11406− =/ prepared=iprelude [u.prelude prelude-values prelude-molds]
11408− ?. ?=([[%mark *] ~] imports.mod) |
11409− ?. ?=([[%mold *] ~] defs.mod) |
11410− ?. =(%paths name.i.defs.mod) |
11411− !?=(%union -.shape.i.defs.mod)
11413− =/ request=(each ione-request-interface @t)
11414− (one-request-interface-graph at src externals mark-externals modules active cache `prepared)
11415− ?: ?=(%| -.request) [%| (crip "API module needs unsupported inference: {(spud at)}")]
11416− =/ checked=ifile iface.p.request
11417− [%& [checked [[at checked] dependencies.paths.support.p.request]]]
11418− =/ multi=(each [iface=ifile cache=jcache] @t)
11419− (multi-request-interface-graph at src externals mark-externals modules active cache `prepared)
11420− ?: ?=(%| -.multi) [%| (crip "API module needs unsupported inference: {(spud at)}")]
11421− [%& [iface.p.multi [[at iface.p.multi] cache.p.multi]]]
11422− ?. (module-scope-valid mod prelude-values prelude-molds)
6399+ ?. (module-scope-valid mod prelude-values prelude-molds) [%| (crip "module has conflicting names: {(spud at)}")]
11423− ?: (pending-declared-poke at mod prelude-values prelude-molds)
11424− [%| (crip "module kind or scope needs unsupported inference: {(spud at)}")]
11425− [%| (crip "module has conflicting names: {(spud at)}")]
11426 =/ vals=(list term) (global-value-names defs.mod)
6400 =/ vals=(list term) (global-value-names defs.mod)
11427 ?: (lien vals |=(n=term =(n %main)))
6401 ?: (lien vals |=(n=term =(n %main)))
11428 [%| (crip "module kind needs unsupported inference: {(spud at)}")]
6402 [%| (crip "module kind needs unsupported inference: {(spud at)}")]
11429− =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
6403+ =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache)
11430 ?: ?=(%| -.js) [%| p.js]
6404 ?: ?=(%| -.js) [%| p.js]
11431 =/ molds=imolds (collect-simple-molds defs.mod)
6405 =/ molds=imolds (collect-simple-molds defs.mod)
11432 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
6406 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
11433 =/ surs=(list term) (collect-sur-imports imports.mod)
6407 =/ surs=(list term) (collect-sur-imports imports.mod)
11434 =/ marks=(list term) (collect-mark-imports imports.mod)
6408 =/ marks=(list term) (collect-mark-imports imports.mod)
11435 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
6409 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
11436− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11437− =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude ~ 256 ~]
6410+ =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ |]
11438 =/ mts=(each imold-types @t) (module-mold-types molds state)
6411 =/ mts=(each imold-types @t) (module-mold-types molds state)
11439 ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
6412 ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
11440− =/ resolution=iresolved (resolve-groups defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
6413+ =/ env=ienv (resolve-supported-defs defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved)
11441− =/ env=ienv env.resolution
11442 ?. (module-values-complete defs.mod env)
6414 ?. (module-values-complete defs.mod env)
11443 [%| (crip "module definitions need unsupported inference: {(spud at)}")]
6415 [%| (crip "module definitions need unsupported inference: {(spud at)}")]
11444− =/ initial=irequest-graph [(silt `(list path)`~[at]) ~ modules prelude prelude-values prelude-molds externals mark-externals]
6416+ [%& [[env p.mts] [[at [env p.mts]] cache.p.js]]]
11445− =/ graph=(unit irequest-graph) (request-graph-merge resolved.p.js initial (add 1 (lent resolved.p.js)))
11446− ?~ graph [%| 'module request evidence needs unsupported inference']
11447− =/ iface=ifile [env p.mts at ~ artifacts.resolution ~ `src graph]
11448− [%& [iface [[at iface] cache.p.js]]]
11450−:: A source-bound analysis of one named mold, not a module, island,
11451−:: request, watchability or runtime check. The host owns the trusted
11452−:: prepared prelude, canonical paths and reader/source version identities.
11453−:: The 256-node cap covers only classification, not source/graph work.
11455− [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]
11456−++ gate-free-mold-source
11457− |= [file=path src=@t name=term externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude) fuel=@ud]
11458− ^- (each igate-free-mold @t)
11459− ?~ file [%| 'mold analysis needs a path ending in jibb']
11460− ?. =(%jibb (rear file)) [%| 'mold analysis needs a path ending in jibb']
11461− ?: |(=(file /lib/jibb/internal/jibb) =(file /lib/jibb/primitives/jibb))
11462− [%| 'the prelude internal modules are private']
11463− ?: ?=([%ui %api *] file) [%| 'API declarations need unsupported mold analysis']
11464− ?: ?=([%ui %stores *] file) [%| 'store declarations need unsupported mold analysis']
11465− =/ entries=jbundle (skim modules |=(m=jsource =(file at.m)))
11466− ?: (gth (lent entries) 1) [%| 'duplicate root module sources']
11467− =/ wrong-root=? ?~(entries | !=(source.i.entries src))
11468− ?: wrong-root [%| 'root module source does not match bundle']
11469− =/ parsed (parse file src)
11470− ?: ?=(%| -.parsed) [%| 'mold source does not parse']
11471− =/ mod=module p.parsed
11472− =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
11473− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
11474− ?~ prepared [%| 'mold analysis needs the prepared prelude']
11475− ?. (module-scope-valid mod values.u.prepared molds.u.prepared)
11476− [%| 'mold source has conflicting or unsupported scope']
11477− =/ selected=(list def)
11478− (skim defs.mod |=(d=def &(?=(%mold -.d) =(name.d name))))
11479− ?~ selected [%| 'selected mold is not declared']
11480− ?^ t.selected [%| 'selected mold is not unique']
11481− ?> ?=(%mold -.i.selected)
11482− =/ public=ifile iface.u.prepared
11483− =/ js=jimports-result
11484− (resolve-jibb-imports imports.mod externals marks modules ~[file] values.u.prepared molds.u.prepared ~ `public)
11485− ?: ?=(%| -.js) [%| p.js]
11486− =/ ms=imolds (collect-simple-molds defs.mod)
11487− =/ vals=(list term) (global-value-names defs.mod)
11488− =/ globals=(list term) (weld values.u.prepared (weld (import-binding-names imports.mod) vals))
11489− =/ surs=(list term) (collect-sur-imports imports.mod)
11490− =/ declared=(list term) (collect-mark-imports imports.mod)
11491− =/ reserved=(list term) (weld molds.u.prepared (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
11492− =/ top=(list term) (turn ms |=(m=[name=term body=shape] name.m))
11493− =/ state=istate [0 ~ ~ ~ ms globals externals surs marks declared resolved.p.js reserved ~ ~ ~ | file top `public ~ 256 ~]
11494− =/ inferred=(unit [template=ischeme state=istate])
11495− (infer-mold-template shape.i.selected state(active ~[name], in-mold &))
11496− ?~ inferred [%| 'selected mold needs unsupported inference']
11497− =/ template=ischeme template.u.inferred
11498− =. typ.template (label-direct-union typ.template shape.i.selected name state)
11499− =. typ.template (itype-normalize typ.template sub.state.u.inferred)
11500− =/ cap=@ud (min fuel 256)
11501− =/ analysis=igate-free (gate-free-type typ.template cap ~)
11502− [%& [file src name u.prepared externals marks modules cache.p.js template fuel cap analysis]]
11504:: +golden-types-with-modules fails closed for imports without prelude
6418:: +golden-types-with-modules fails closed for imports without prelude
11505:: scope. +golden-types-with-prelude resolves supported library graphs;
6419:: scope. +golden-types-with-prelude resolves supported library graphs;
@@ -11510,103 +6424,54 @@
11511 =/ parsed (parse file src)
6425 =/ parsed (parse file src)
11512 ?: ?=(%| -.parsed) (show-error src p.parsed)
6426 ?: ?=(%| -.parsed) (show-error src p.parsed)
11513− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11514− ?^ duplicate (duplicate-fields-report file src u.duplicate)
11515 ?: (lien imports.p.parsed |=(i=import ?=(%jibb -.i)))
6427 ?: (lien imports.p.parsed |=(i=import ?=(%jibb -.i)))
11516 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
6428 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
11517 (golden-types-with-marks file src externals mark-externals)
6429 (golden-types-with-marks file src externals mark-externals)
11519−:: The caller supplies the actual prelude source. Its declared names are
6431+:: The caller supplies the actual prelude source. Its current names are
11520−:: reserved, and supported inferred types are made available. The inventory
6432+:: reserved, but its incomplete inventory and types are not checked here.
11521−:: and the checker are incomplete, so this never claims a checked module.
11522−:: Hosts may prepare the same trusted source once and reuse its interface.
11524++ golden-types-with-prelude
6434++ golden-types-with-prelude
11525 |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prelude-source=@t]
6435 |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prelude-source=@t]
11527 =/ parsed (parse file src)
6437 =/ parsed (parse file src)
11528 ?: ?=(%| -.parsed) (show-error src p.parsed)
6438 ?: ?=(%| -.parsed) (show-error src p.parsed)
11529− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11530− ?^ duplicate (duplicate-fields-report file src u.duplicate)
11531 ?: =(0 prelude-source) 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
6439 ?: =(0 prelude-source) 'partial inference; module not checked\0aprelude source missing; module import inference unsupported'
11532 =/ prelude (parse /lib/jibb/prelude/jibb prelude-source)
6440 =/ prelude (parse /lib/jibb/prelude/jibb prelude-source)
11533 ?: ?=(%| -.prelude) 'partial inference; module not checked\0aprelude source does not parse; module import inference unsupported'
6441 ?: ?=(%| -.prelude) 'partial inference; module not checked\0aprelude source does not parse; module import inference unsupported'
11534− =/ prepared=(unit iprelude) (prepare-prelude prelude-source)
6442+ =/ prelude-values=(list term) (global-value-names defs.p.prelude)
11535− ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
6443+ =/ prelude-molds=(list term)
11536− (golden-types-with-prepared-prelude file src externals mark-externals modules prepared)
6444+ (turn (collect-simple-molds defs.p.prelude) |=(m=[name=term body=shape] name.m))
11538−++ golden-types-with-prelude-and-internal
11539− |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prelude-source=@t internal-source=@t]
11541− =/ prepared=(unit iprelude) (prepare-prelude-with-internal prelude-source internal-source)
11542− (golden-types-with-prepared-prelude file src externals mark-externals modules prepared)
11544−++ golden-types-with-prepared-prelude
11545− |= [file=path src=@t externals=iexternals mark-externals=imark-externals modules=jbundle prepared=(unit iprelude)]
11547− =/ parsed (parse file src)
11548− ?: ?=(%| -.parsed) (show-error src p.parsed)
11549− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11550− ?^ duplicate (duplicate-fields-report file src u.duplicate)
11551− ?~ prepared 'partial inference; module not checked\0aprelude interface is not supported'
11552− =/ prelude-values=(list term) values.u.prepared
11553− =/ prelude-molds=(list term) molds.u.prepared
11554− =/ iface=(unit ifile) `iface.u.prepared
11555 ?. (module-scope-valid p.parsed prelude-values prelude-molds)
6445 ?. (module-scope-valid p.parsed prelude-values prelude-molds)
11556− ?: (pending-declared-poke file p.parsed prelude-values prelude-molds)
11557− 'partial inference; module not checked\0amodule kind or scope needs unsupported inference'
11558 'partial inference; module not checked\0amodule has conflicting names'
6446 'partial inference; module not checked\0amodule has conflicting names'
11559 =/ js=jimports-result
6447 =/ js=jimports-result
11560− (resolve-jibb-imports imports.p.parsed externals mark-externals modules ~[file] prelude-values prelude-molds ~ iface)
6448+ (resolve-jibb-imports imports.p.parsed externals mark-externals modules ~[file] prelude-values prelude-molds ~)
11561 ?: ?=(%| -.js) (of-wain:format ~['partial inference; module not checked' p.js])
6449 ?: ?=(%| -.js) (of-wain:format ~['partial inference; module not checked' p.js])
11562 =/ scope-values=(list term)
6450 =/ scope-values=(list term)
11563 (weld prelude-values (weld (collect-sur-imports imports.p.parsed) (collect-mark-imports imports.p.parsed)))
6451 (weld prelude-values (weld (collect-sur-imports imports.p.parsed) (collect-mark-imports imports.p.parsed)))
11564− (golden-types-in-context file src externals mark-externals resolved.p.js scope-values prelude-molds iface)
6452+ (golden-types-in-context file src externals mark-externals resolved.p.js scope-values prelude-molds)
11566:: +golden-types-with-marks: supply declared mark types separately from /sur
6454:: +golden-types-with-marks: supply declared mark types separately from /sur
11567:: entries, as [mark result] with the result from +read-mark:jibb-import.
6455:: entries, as [mark result] with the result from +read-mark:jibb-import.
11568:: Unknown, duplicated, failed and undeclared entries never resolve a mold.
6456:: Unknown, duplicated, failed and undeclared entries never resolve a mold.
11570−:: Callers pass unchanged structured reader results; graph validation
11571−:: remains in the existing bridge, and failures stay available lazily.
11572−++ reader-result-for-checker
11575− ?: ?=([%ok *] result) [%& +.result]
11578−++ golden-types-with-reader-diagnostics
11579− |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
11582− (turn externals |=(e=[module=term name=term result=*] [module.e name.e (reader-result-for-checker result.e)]))
11583− =/ mx=imark-externals
11584− (turn mark-externals |=(e=[mark=term result=*] [mark.e (reader-result-for-checker result.e)]))
11585− (golden-types-with-marks file src ex mx)
11587++ golden-types-with-marks
6458++ golden-types-with-marks
11588 |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
6459 |= [file=path src=@t externals=iexternals mark-externals=imark-externals]
11590− (golden-types-in-context file src externals mark-externals ~ ~ ~ ~)
6461+ (golden-types-in-context file src externals mark-externals ~ ~ ~)
11592++ golden-types-in-context
6463++ golden-types-in-context
11593− |= [file=path src=@t externals=iexternals mark-externals=imark-externals jimports=ijimports prelude-values=(list term) reserved-molds=(list term) prelude=(unit ifile)]
6464+ |= [file=path src=@t externals=iexternals mark-externals=imark-externals jimports=ijimports prelude-values=(list term) reserved-molds=(list term)]
11595 =. reserved-molds (weld reserved-molds (turn jimports |=(j=[face=term interface=ifile] face.j)))
6466 =. reserved-molds (weld reserved-molds (turn jimports |=(j=[face=term interface=ifile] face.j)))
11596 =/ parsed (parse file src)
6467 =/ parsed (parse file src)
11597 ?: ?=(%| -.parsed) (show-error src p.parsed)
6468 ?: ?=(%| -.parsed) (show-error src p.parsed)
11598− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
11599− ?^ duplicate (duplicate-fields-report file src u.duplicate)
11600− ?: (module-has-reserved-proj p.parsed)
11601− 'module has reserved proj name'
11602 =/ ds=(list def) defs.p.parsed
6469 =/ ds=(list def) defs.p.parsed
11603 =/ molds=imolds (collect-simple-molds ds)
6470 =/ molds=imolds (collect-simple-molds ds)
11604 =/ globals=(list term) (weld prelude-values (weld (turn jimports |=(j=[face=term interface=ifile] face.j)) (global-value-names ds)))
6471 =/ globals=(list term) (weld prelude-values (weld (turn jimports |=(j=[face=term interface=ifile] face.j)) (global-value-names ds)))
11605 =/ surs=(list term) (collect-sur-imports imports.p.parsed)
6472 =/ surs=(list term) (collect-sur-imports imports.p.parsed)
11606 =/ marks=(list term) (collect-mark-imports imports.p.parsed)
6473 =/ marks=(list term) (collect-mark-imports imports.p.parsed)
11607− =/ resolution=iresolved (resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds file prelude)
6474+ =/ env=ienv (resolve-supported-defs ds molds globals externals surs mark-externals marks jimports reserved-molds)
11608− =/ cycles=(list icycle) (definite-value-cycles ds globals)
11609− =/ env=ienv env.resolution
11610 =/ lines=(list @t) ~
6475 =/ lines=(list @t) ~
11612 ?~ ds (of-wain:format ['partial inference; module not checked' (flop lines)])
6477 ?~ ds (of-wain:format ['partial inference; module not checked' (flop lines)])
@@ -11615,54 +6480,21 @@
11615 $(ds t.ds, lines [(show-partial-mold file src d molds) lines])
6480 $(ds t.ds, lines [(show-partial-mold file src d molds) lines])
11616 ?. (unique-value-name name.d globals)
6481 ?. (unique-value-name name.d globals)
11617 $(ds t.ds, lines [(crip "++ {(trip name.d)}: name already in scope") lines])
6482 $(ds t.ds, lines [(crip "++ {(trip name.d)}: name already in scope") lines])
11618− =/ cycle=(list icycle) (skim cycles |=(c=icycle =(name.c name.d)))
11620− =/ diag=idiag ["non-gate value depends on itself through a cycle" ~[[first.i.cycle "value in cycle"] [next.i.cycle "dependency in cycle"]]]
11621− $(ds t.ds, lines [(show-inference-diagnostic file src name.d diag) lines])
11622− ?: (lien grouped.resolution |=(n=term =(n name.d)))
11623− =/ found=(unit ischeme) (ienv-lookup name.d env)
11624− ?~ found $(ds t.ds, lines [(crip "++ {(trip name.d)}: recursive group unavailable") lines])
11625− =/ typ=itype (canonical-itype typ.u.found vars.u.found)
11626− =/ line=@t (crip "++ {(trip name.d)}: {(show-itype typ ~)}{(show-atom-constraint typ)}")
11627− $(ds t.ds, lines [line lines])
11628− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11629− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude ~ 256 ~]
6483+ =/ result=iresult (infer-fragment val.d env [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ |])
11630− =. initial (reserve-def-caps val.d initial)
11632− ?: |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
11633− (infer-recursive-gate d env initial)
11634− (infer-fragment val.d env initial)
11635 ?: ?=(%| -.result)
6484 ?: ?=(%| -.result)
11636 $(ds t.ds, lines [(show-inference-diagnostic file src name.d p.result) lines])
6485 $(ds t.ds, lines [(show-inference-diagnostic file src name.d p.result) lines])
11637− =. state.p.result (promote-restricted-numbers state.p.result env)
11638− =. 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)))
11639− =/ hole=(unit idiag) (unresolved-hole holes.state.p.result holes.initial state.p.result)
11641− $(ds t.ds, lines [(show-inference-diagnostic file src name.d u.hole) lines])
11642− =/ merged=(unit [first=icap second=icap])
11643− (merged-capitals caps.state.p.result sub.state.p.result)
11646− ["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"]]]
11647− $(ds t.ds, lines [(show-inference-diagnostic file src name.d diag) lines])
11648 ?: (constrained-capitals caps.state.p.result sub.state.p.result)
6486 ?: (constrained-capitals caps.state.p.result sub.state.p.result)
11649 $(ds t.ds, lines [(crip "++ {(trip name.d)}: explicit capital constraints are not supported by partial inference") lines])
6487 $(ds t.ds, lines [(crip "++ {(trip name.d)}: explicit capital constraints are not supported by partial inference") lines])
11650 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
6488 =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
11651− ?: (pending-null tags.state.p.result sub.state.p.result)
11652− $(ds t.ds, lines [(crip "++ {(trip name.d)}: `~` needs context in partial inference") lines])
11653 ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ))
6489 ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ))
11654 $(ds t.ds, lines [(crip "++ {(trip name.d)}: tag needs context in partial inference") lines])
6490 $(ds t.ds, lines [(crip "++ {(trip name.d)}: tag needs context in partial inference") lines])
11655− ?: (itype-has-hidden-recursive typ)
6491+ ?: (itype-has-union typ)
11656− $(ds t.ds, lines [(crip "++ {(trip name.d)}: recursive mold name is not available in this scope") lines])
11657− ?: (itype-has-hidden-generic typ)
11658− $(ds t.ds, lines [(crip "++ {(trip name.d)}: generic union name is not available in this scope") lines])
6492+ $(ds t.ds, lines [(crip "++ {(trip name.d)}: union type printing is not supported by partial inference") lines])
11659 ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result)
6493 ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result)
11660 $(ds t.ds, lines [(crip "++ {(trip name.d)}: unresolved aura-variable inference") lines])
6494 $(ds t.ds, lines [(crip "++ {(trip name.d)}: unresolved aura-variable inference") lines])
11661 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
6495 =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
11662 ?: (gth (lent vars) 26)
6496 ?: (gth (lent vars) 26)
11663 $(ds t.ds, lines [(crip "++ {(trip name.d)}: too many variables for partial printer") lines])
6497 $(ds t.ds, lines [(crip "++ {(trip name.d)}: too many variables for partial printer") lines])
11664− ?~ (width-finalize projections.state.p.result sub.state.p.result vars)
11665− $(ds t.ds, lines [(crip "++ {(trip name.d)}: record projection elaboration needs unsupported inference") lines])
11666 =/ printable=itype (canonical-itype typ vars)
6498 =/ printable=itype (canonical-itype typ vars)
11667 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
6499 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
11668 $(ds t.ds, lines [line lines])
6500 $(ds t.ds, lines [line lines])