@@ -4607,8 +4607,6 @@
46074607:: Atom constraints tied to an explicit capital or an inferred sample
46084608:: are generalized and printed. Other aura variables remain unsupported until
46094609:: their defaulting and inferred generalization are implemented.
4610−:: Restricted-number promotion considers written capitals only; if there
4611−:: are none, it skips the otherwise unnecessary environment traversal.
46124610:: Bare @ is a separate unrestricted atom type. A directional fit check
46134611:: permits concrete atoms to widen to it, never the reverse. A fit that
46144612:: needs a not-yet-implemented constraint remains unsupported. Named unions
@@ -4630,32 +4628,6 @@
46304628:: proofs to fewer than 1,024 cells; the projection planner has a separate
46314629:: 4,096-step bound. These are inference limits, not language limits.
46324630::
4633−:: Supported API imports derive request-gate types atomically for multiple
4634−:: paths, including one typed segment or one diff fold per case. Their checked
4635−:: ordinary definitions, mark molds and supported poke constructor are also
4636−:: exported. A selected /sur mold is checked through its trusted reader result;
4637−:: unused cores and other bindings are not independently validated. APIs
4638−:: with /= imports, separate scry paths, multiple parameters or diffs, or a
4639−:: parameter together with a fold remain unsupported. The unchanged todo API
4640−:: fits this fragment, including named closed fold gates.
4641−::
4642−:: Each case's source-derived schema and canonical API identity travel in a
4643−:: dependency closure bound to the exact supplied bundle, prelude, scope and
4644−:: trusted reader results. Unknown cached entries are rebuilt. Request-bearing
4645−:: closures are limited to 256 source paths and requests. This is type
4646−:: inference only: no request lowering, runtime schema validator or proof that
4647−:: an arbitrary ask value is watchable is supplied.
4648−::
4649−:: A closed gate sample may omit one outer face from a known input slot when
4650−:: its product is identical. Distinct written names, nested value faces,
4651−:: ambiguous cell tails and raw-variable-origin fits retain their prior rules.
4652−::
4653−:: In one synthetic eval of a 48-module deep and 48-module wide request-free
4654−:: graph, baseline versus certificate inference took 21.53 s versus 23.10 s
4655−:: elapsed (21.10 s versus 22.34 s CPU), including startup. The deep cache's
4656−:: jam grew from 2,402 to 4,209 bytes (+1,807 bytes). These single-run figures
4657−:: are not production memory or performance benchmarks.
4658−::
46594631+$ itype
46604632 $~ [%var 0]
46614633 $% [%var id=@ud]
@@ -4667,13 +4639,11 @@
46674639 [%any-atom ~]
46684640 [%flag ~]
46694641 [%noun ~]
4670− [%empty ~]
46714642 [%tag id=@ud literal=lit constructor=?]
46724643 [%const literal=lit]
46734644 [%collection name=term args=(list itype)]
46744645 [%recursive module=term name=term label=(unit @t)]
46754646 [%jrec at=path name=term label=(unit @t) head=term aura=@ta tail=term]
4676− [%grec at=path name=term label=(unit @t) proof=shape args=(list itype)]
46774647 [%union cases=(list itype) origin=(unit [at=path name=term]) label=(unit @t) args=(list itype)]
46784648 [%face name=term body=itype]
46794649 [%fn sample=itype product=itype]
@@ -4726,88 +4696,6 @@
47264696 $(t u.found)
47274697 ==
47284698::
4729−:: Prove only emptiness; unknown types are never treated as empty.
4730−:: A shared node budget bounds each proof attempt.
4731−++ itype-empty-cases
4732− |= [xs=(list itype) sub=isub fuel=@ud]
4733− ^- (unit [empty=? left=@ud])
4734− ?~ xs `[& fuel]
4735− =/ first=(unit [empty=? left=@ud]) (itype-empty-proof i.xs sub fuel)
4736− ?~ first ~
4737− ?. empty.u.first `[| left.u.first]
4738− $(xs t.xs, fuel left.u.first)
4739−++ itype-empty-proof
4740− |= [typ=itype sub=isub fuel=@ud]
4741− ^- (unit [empty=? left=@ud])
4742− ?: =(0 fuel) ~
4743− =. fuel (dec fuel)
4744− =. typ (itype-walk typ sub)
4745− ?- -.typ
4746− %empty `[& fuel]
4747− %face $(typ body.typ)
4748− %cell
4749− =/ left=(unit [empty=? left=@ud]) $(typ hed.typ)
4750− ?~ left ~
4751− ?: empty.u.left `[& left.u.left]
4752− $(typ tal.typ, fuel left.u.left)
4753− %union (itype-empty-cases cases.typ sub fuel)
4754− * `[| fuel]
4755− ==
4756−:: Prove reachability separately from emptiness. An unresolved fixed
4757−:: recursive type is not presumed inhabited. A written, still-unconstrained
4758−:: capital is existentially inhabited for pattern reachability; the normal
4759−:: definition-boundary checks reject subsequently constrained capitals.
4760−++ itype-inhabited-cases
4761− |= [xs=(list itype) sub=isub caps=icaps fuel=@ud pending=?]
4762− ^- (unit [result=?(%yes %no %unknown) left=@ud])
4763− ?~ xs `[?:(pending %unknown %no) fuel]
4764− =/ first=(unit [result=?(%yes %no %unknown) left=@ud])
4765− (itype-inhabited-proof i.xs sub caps fuel)
4766− ?~ first ~
4767− ?: =(%yes result.u.first) first
4768− $(xs t.xs, fuel left.u.first, pending |(pending =(%unknown result.u.first)))
4769−++ itype-inhabited-proof
4770− |= [typ=itype sub=isub caps=icaps fuel=@ud]
4771− ^- (unit [result=?(%yes %no %unknown) left=@ud])
4772− ?: =(0 fuel) ~
4773− =. fuel (dec fuel)
4774− =. typ (itype-walk typ sub)
4775− ?- -.typ
4776− %empty `[%no fuel]
4777− ?(%atom %any-atom %flag %const %noun %avar %rvar %nvar %rnvar %fn %jrec) `[%yes fuel]
4778− %var
4779− ?: (lien caps |=(c=icap (hole-same-variable typ (itype-walk [%var id.c] sub)))) `[%yes fuel]
4780− `[%unknown fuel]
4781− %face $(typ body.typ)
4782− %cell
4783− =/ head=(unit [result=?(%yes %no %unknown) left=@ud]) $(typ hed.typ)
4784− ?~ head ~
4785− ?: =(%no result.u.head) head
4786− =/ tail=(unit [result=?(%yes %no %unknown) left=@ud]) $(typ tal.typ, fuel left.u.head)
4787− ?~ tail ~
4788− ?: =(%no result.u.tail) tail
4789− ?: |(=(%unknown result.u.head) =(%unknown result.u.tail)) `[%unknown left.u.tail]
4790− `[%yes left.u.tail]
4791− %union (itype-inhabited-cases cases.typ sub caps fuel |)
4792− %collection
4793− ?. &(|(=(%list name.typ) =(%unit name.typ)) ?=([* ~] args.typ)) `[%unknown fuel]
4794− `[%yes fuel]
4795− %grec ?:((grec-tree-proof name.typ proof.typ) `[%yes fuel] `[%unknown fuel])
4796− * `[%unknown fuel]
4797− ==
4798−++ itype-live-cases
4799− |= [xs=(list itype) sub=isub caps=icaps fuel=@ud]
4800− ^- (unit (list itype))
4801− ?~ xs `~
4802− =/ first=(unit [result=?(%yes %no %unknown) left=@ud])
4803− (itype-inhabited-proof i.xs sub caps fuel)
4804− ?~ first ~
4805− ?: =(%unknown result.u.first) ~
4806− =/ rest=(unit (list itype)) $(xs t.xs, fuel left.u.first)
4807− ?~ rest ~
4808− ?: =(%no result.u.first) rest
4809− `[i.xs u.rest]
4810−::
48114699++ itype-occurs
48124700 |= [n=@ud t=itype sub=isub]
48134701 ^- ?
@@ -4822,13 +4710,11 @@
48224710 %any-atom |
48234711 %flag |
48244712 %noun |
4825− %empty |
48264713 %tag =(n id.t)
48274714 %const |
48284715 %union |((lien cases.t |=(c=itype (itype-occurs n c sub))) (lien args.t |=(c=itype (itype-occurs n c sub))))
48294716 %recursive |
48304717 %jrec |
4831− %grec (lien args.t |=(c=itype (itype-occurs n c sub)))
48324718 %collection (lien args.t |=(c=itype (itype-occurs n c sub)))
48334719 %face $(t body.t)
48344720 %fn |($(t sample.t) $(t product.t))
@@ -4847,9 +4733,6 @@
48474733 =. a (itype-walk a sub)
48484734 =. b (itype-walk b sub)
48494735 ?: =(a b) `sub
4850− ?: &(?=(%grec -.a) ?=(%grec -.b))
4851− ?. &(=(at.a at.b) =(name.a name.b)) ~
4852− (itype-unify-args args.a args.b sub)
48534736 ?: &(?=(%jrec -.a) ?=(%jrec -.b))
48544737 ?:(&(=(at.a at.b) =(name.a name.b) =(head.a head.b) =(aura.a aura.b) =(tail.a tail.b)) `sub ~)
48554738 ?: &(?=(%recursive -.a) ?=(%recursive -.b))
@@ -4955,13 +4838,11 @@
49554838 %any-atom &
49564839 %flag |
49574840 %noun |
4958− %empty |
49594841 %tag |
49604842 %const |
49614843 %union |((lien cases.t |=(c=itype (itype-has-any-atom c sub))) (lien args.t |=(c=itype (itype-has-any-atom c sub))))
49624844 %recursive |
49634845 %jrec |
4964− %grec (lien args.t |=(c=itype (itype-has-any-atom c sub)))
49654846 %collection (lien args.t |=(c=itype (itype-has-any-atom c sub)))
49664847 %face $(t body.t)
49674848 %fn |($(t sample.t) $(t product.t))
@@ -5031,13 +4912,11 @@
50314912 %any-atom &
50324913 %flag &
50334914 %noun |
5034− %empty |
50354915 %tag &
50364916 %const &
50374917 %union |((lien cases.typ |=(c=itype (itype-has-fixed-atom c))) (lien args.typ |=(c=itype (itype-has-fixed-atom c))))
50384918 %recursive |
50394919 %jrec |
5040− %grec (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
50414920 %collection (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
50424921 %face $(typ body.typ)
50434922 %fn |($(typ sample.typ) $(typ product.typ))
@@ -5066,7 +4945,6 @@
50664945 ^- ?
50674946 =. t (itype-walk t sub)
50684947 ?- -.t
5069− %grec (lien args.t |=(c=itype (itype-has-face c sub)))
50704948 %collection (lien args.t |=(c=itype (itype-has-face c sub)))
50714949 %face &
50724950 %cell |($(t hed.t) $(t tal.t))
@@ -5074,42 +4952,6 @@
50744952 * |
50754953 ==
50764954::
5077−:: Closed function samples may omit a slot face, but a known name must
5078−:: match another known name. Keep nested value faces and require exact
5079−:: invariant compatibility; a faced tail against a cell is ambiguous.
5080−++ itype-closed-slot-match
5081− |= [a=itype b=itype]
5082− ^- ?
5083− ?: &(?=(%face -.a) ?=(%face -.b))
5084− ?. =(name.a name.b) |
5085− ?=(^ (itype-unify body.a body.b ~))
5086− ?: ?=(%face -.a) ?=(^ (itype-unify body.a b ~))
5087− ?: ?=(%face -.b) ?=(^ (itype-unify a body.b ~))
5088− ?=(^ (itype-unify a b ~))
5089−++ itype-closed-sample-match
5090− |= [a=itype b=itype fuel=@ud]
5091− ^- ?
5092− ?: =(0 fuel) |
5093− ?. &(?=(%cell -.a) ?=(%cell -.b)) |
5094− ?. (itype-closed-slot-match hed.a hed.b) |
5095− =/ x=itype tal.a
5096− =/ y=itype tal.b
5097− ?: &(?=(%cell -.x) ?=(%cell -.y))
5098− ?=(^ (itype-unify x y ~))
5099− ?: |(&(?=(%face -.x) ?=(%cell -.y)) &(?=(%cell -.x) ?=(%face -.y))) |
5100− (itype-closed-slot-match x y)
5101−++ itype-closed-gates-match
5102− |= [a=itype b=itype]
5103− ^- ?
5104− ?. &(?=(%fn -.a) ?=(%fn -.b)) |
5105− ?. &(?=(%cell -.sample.a) ?=(%cell -.sample.b)) |
5106− ?. =(product.a product.b) |
5107− ?^ (itype-vars a) |
5108− ?^ (itype-vars b) |
5109− ?: |((itype-has-tag a) (itype-has-tag b)) |
5110− ?. (itype-closed-sample-match sample.a sample.b 1.024) |
5111− ?=(^ (itype-unify product.a product.b ~))
5112−::
51134955++ itype-face-asym-collection-args
51144956 |= [as=(list itype) bs=(list itype) sub=isub]
51154957 ^- ?
@@ -5123,9 +4965,6 @@
51234965 ^- ?
51244966 =. a (itype-walk a sub)
51254967 =. b (itype-walk b sub)
5126− ?: &(?=(%grec -.a) ?=(%grec -.b))
5127− ?. &(=(at.a at.b) =(name.a name.b)) |
5128− (itype-face-asym-collection-args args.a args.b sub)
51294968 ?: &(?=(%collection -.a) ?=(%collection -.b))
51304969 ?. =(name.a name.b) |
51314970 (itype-face-asym-collection-args args.a args.b sub)
@@ -5158,12 +4997,6 @@
51584997:: labels. Ignore one raw sample-slot face per written argument while
51594998:: checking value faces as usual. An unknown or variable-bound cell spine
51604999:: cannot justify this distinction, so keep the existing conservative guard.
5161−++ itype-positional-slot-face-asym
5162− |= [actual=itype expected=itype sub=isub]
5163− ^- ?
5164− ?: &(?=(%fn -.actual) ?=(%fn -.expected) (itype-closed-gates-match actual expected)) |
5165− (itype-face-asym actual expected sub)
5166−::
51675000++ itype-positional-face-asym
51685001 |= [args=(list expr) actual=itype expected=itype sub=isub]
51695002 ^- ?
@@ -5171,11 +5004,11 @@
51715004 ?~ t.args
51725005 =/ slot=itype expected
51735006 =? slot ?=(%face -.slot) body.slot
5174− (itype-positional-slot-face-asym actual slot sub)
5007+ (itype-face-asym actual slot sub)
51755008 ?. &(?=(%cell -.actual) ?=(%cell -.expected)) &
51765009 =/ slot=itype hed.expected
51775010 =? slot ?=(%face -.slot) body.slot
5178− ?: (itype-positional-slot-face-asym hed.actual slot sub) &
5011+ ?: (itype-face-asym hed.actual slot sub) &
51795012 $(args t.args, actual tal.actual, expected tal.expected)
51805013::
51815014++ itype-output-may-be-cell
@@ -5188,7 +5021,6 @@
51885021 %union &
51895022 %recursive &
51905023 %jrec &
5191− %grec &
51925024 %noun &
51935025 %collection &
51945026 %face $(t body.t)
@@ -5218,7 +5050,6 @@
52185050 ^- ?
52195051 ?- -.t
52205052 %tag &
5221− %grec (lien args.t |=(c=itype (itype-has-tag c)))
52225053 %collection (lien args.t |=(c=itype (itype-has-tag c)))
52235054 %face $(t body.t)
52245055 %fn |($(t sample.t) $(t product.t))
@@ -5232,7 +5063,6 @@
52325063 ^- ?
52335064 ?- -.t
52345065 %union &
5235− %grec (lien args.t |=(c=itype (itype-has-union c)))
52365066 %collection (lien args.t |=(c=itype (itype-has-union c)))
52375067 %face $(t body.t)
52385068 %fn |($(t sample.t) $(t product.t))
@@ -5251,7 +5081,6 @@
52515081 %union
52525082 ?: &(?=(~ label.t) ?=(^ args.t)) &
52535083 (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-generic c)))
5254− %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-generic c))))
52555084 %collection (lien args.t |=(c=itype (itype-has-hidden-generic c)))
52565085 %face $(t body.t)
52575086 %fn |($(t sample.t) $(t product.t))
@@ -5265,7 +5094,6 @@
52655094 ?- -.t
52665095 %recursive &
52675096 %jrec &
5268− %grec &
52695097 %collection (lien args.t |=(c=itype (itype-has-recursive c)))
52705098 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-recursive c)))
52715099 %face $(t body.t)
@@ -5280,7 +5108,6 @@
52805108 ?- -.t
52815109 %recursive ?=(~ label.t)
52825110 %jrec ?=(~ label.t)
5283− %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-recursive c))))
52845111 %collection (lien args.t |=(c=itype (itype-has-hidden-recursive c)))
52855112 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-recursive c)))
52865113 %face $(t body.t)
@@ -5308,63 +5135,30 @@
53085135 $(cases t.cases, good `trial)
53095136 ==
53105137::
5311−:: A constructor needs a case whose head has the same literal noun as its
5312−:: tag. An unresolved or opaque case may reveal one later, so it cannot
5313−:: prove a mismatch or a unique match. A broad atom mold is not a case.
5138+:: A constructor needs a case with its tag at the head and a payload
5139+:: compatible with the expected gate sample. Other case forms do not
5140+:: identify a constructor.
53145141::
53155142++ itype-fit-ctor-cases
53165143 |= [tag=lit sample=itype cases=(list itype) sub=isub next=@ud]
53175144 ^- ifit
53185145 =/ found=(unit ifit) ~
5319− =/ pending=? |
53205146 |-
5321− ?~ cases
5322− ?: pending [%unknown ~]
5323− ?~ found [%bad ~]
5324− u.found
5325− =/ raw=itype i.cases
5326− ?: ?=(%var -.raw)
5327− $(cases t.cases, pending &)
5328− =/ c=itype (itype-walk raw sub)
5329− ?: ?=(?(%var %tag %recursive %jrec %grec %union %face) -.c)
5330− $(cases t.cases, pending &)
5147+ ?~ cases ?~(found [%bad ~] u.found)
5148+ =/ c=itype (itype-walk i.cases sub)
53315149 ?. ?=(%cell -.c) $(cases t.cases)
5332− =/ raw-head=itype hed.c
5333− ?: ?=(%var -.raw-head)
5334− $(cases t.cases, pending &)
5335− =/ head=itype (itype-walk raw-head sub)
5336− :: A single faced, explicitly atom-only head cannot be the tag case.
5337− :: Do not follow variables or peel nested faces for this negative proof.
5338− ?: ?=(%face -.head)
5339− ?: ?=(?(%atom %any-atom %flag %avar %rvar %nvar %rnvar) -.body.head)
5340− $(cases t.cases)
5341− $(cases t.cases, pending &)
5342− ?: ?=(?(%var %tag %recursive %jrec %grec %union) -.head)
5343− $(cases t.cases, pending &)
5150+ =/ head=itype (itype-walk hed.c sub)
53445151 ?. ?=(%const -.head) $(cases t.cases)
5152+ ?. =(%term form.literal.head) $(cases t.cases)
53455153 ?. =(val.literal.head val.tag) $(cases t.cases)
5346− :: Equal heads can have disjoint payloads. Test each from the original
5347− :: substitution; a unique success is usable only with no unknown rival.
5154+ ?^ found [%unknown ~]
53485155 =/ trial=ifit (itype-fit sample tal.c sub next)
5349− ?- -.trial
5350− %bad $(cases t.cases)
5351− %unknown $(cases t.cases, pending &)
5352− %ok
5353− ?^ found [%unknown ~]
5354− $(cases t.cases, found `trial)
5355− ==
5156+ $(cases t.cases, found `trial)
53565157::
53575158++ itype-fit
53585159 |= [actual=itype expected=itype sub=isub next=@ud]
53595160 ^- ifit
5360− =/ result=ifit (itype-fit-inner actual expected sub next | |)
5361− ?: ?=(%ok -.result) result
5362− =/ source=itype (itype-walk actual sub)
5363− ?. ?=(?(%empty %face %cell %union) -.source) result
5364− =/ empty=(unit [empty=? left=@ud]) (itype-empty-proof actual sub 256)
5365− ?~ empty [%unknown ~]
5366− ?: empty.u.empty [%ok sub next]
5367− result
5161+ (itype-fit-inner actual expected sub next | |)
53685162++ itype-fit-inner
53695163 |= [actual=itype expected=itype sub=isub next=@ud skip-width=? spine-proof=?]
53705164 ^- ifit
@@ -5383,10 +5177,6 @@
53835177 =. actual (itype-walk actual sub)
53845178 =. expected (itype-walk expected sub)
53855179 ?: =(actual expected) [%ok sub next]
5386− ?: &(?=(%empty -.expected) |(?=(%cell -.actual) ?=(%face -.actual) ?=(%union -.actual) ?=(%grec -.actual) ?=(%recursive -.actual))) [%unknown ~]
5387− :: The relation of the source loobean mold to explicit @f is not yet
5388− :: established. Keep it unsupported rather than asserting a mismatch.
5389− ?: &(?=(%flag -.actual) ?=(%atom -.expected) =(%f aura.expected)) [%unknown ~]
53905180 :: Any value can be used where a noun is expected. An unresolved
53915181 :: bare tag is fixed as a constant; a constructor still needs a gate.
53925182 ?: ?=(%noun -.expected)
@@ -5396,14 +5186,6 @@
53965186 [%ok sub next]
53975187 :: An arbitrary noun is not known to fit a narrower type.
53985188 ?: &(?=(%noun -.actual) !?=(%var -.expected)) [%unknown ~]
5399− ?: &(!uncertain ?=(%grec -.actual) ?=(%face -.expected)) $(expected body.expected)
5400− ?: &(!uncertain ?=(%face -.actual) ?=(%grec -.expected)) $(actual body.actual)
5401− ?: &(?=(%grec -.actual) ?=(%grec -.expected))
5402− ?. &(=(at.actual at.expected) =(name.actual name.expected)) [%unknown ~]
5403− =/ matched=(unit isub) (itype-unify-args args.actual args.expected sub)
5404− ?~ matched [%unknown ~]
5405− [%ok u.matched next]
5406− ?: &(|(?=(%grec -.actual) ?=(%grec -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
54075189 ?: &(!uncertain ?=(%jrec -.actual) ?=(%face -.expected)) $(expected body.expected)
54085190 ?: &(!uncertain ?=(%face -.actual) ?=(%jrec -.expected)) $(actual body.actual)
54095191 ?: &(?=(%jrec -.actual) ?=(%jrec -.expected))
@@ -5477,10 +5259,6 @@
54775259 ?: ?=(%const -.expected)
54785260 ?:(=(val.literal.actual val.literal.expected) [%ok sub next] [%bad ~])
54795261 ?: ?=(%atom -.expected)
5480− :: A loobean singleton must not silently widen into another aura.
5481− ?: =(%loobean form.literal.actual)
5482− ?: =(%f aura.expected) [%unknown ~]
5483− [%bad ~]
54845262 ?: |(=(%tas aura.expected) =(%ta aura.expected)) [%ok sub next]
54855263 [%bad ~]
54865264 ?: ?=(%flag -.expected)
@@ -5540,7 +5318,6 @@
55405318 $(actual body.actual, expected body.expected, skip-width |, spine-proof |)
55415319 ?: ?=(%face -.actual) $(actual body.actual, skip-width |, spine-proof |)
55425320 ?: ?=(%face -.expected) $(expected body.expected, skip-width |, spine-proof |)
5543− ?: &(!uncertain (itype-closed-gates-match actual expected)) [%ok sub next]
55445321 ?: (itype-face-asym actual expected sub) [%unknown ~]
55455322 ?: |((itype-has-any-atom actual sub) (itype-has-any-atom expected sub))
55465323 [%unknown ~]
@@ -5619,19 +5396,7 @@
56195396+$ iderived [name=term agent=term mark=term]
56205397+$ iwidth-definition [name=term original=expr typ=itype sub=isub projections=(list iwprojection)]
56215398+$ iwidth-dependency [at=path source=(unit @t) definitions=(list iwidth-definition)]
5622−:: Nonrecursive request evidence is compiler-owned metadata, not a property
5623−:: of an arbitrary ask value. Reader graphs and source inputs are trusted.
5624−+$ irequest-evidence
5625− [api-at=path name=term path=iapi-path-typed api-source=@t public-source=@t internal-source=@t prelude-values=(list term) prelude-molds=(list term) externals=iexternals marks=imark-externals]
5626−:: Store requests have their own source-bound evidence. In particular, an
5627−:: API path certificate cannot make a store state member watchable, or vice versa.
5628−+$ istore-request-evidence
5629− [store-at=path source=@t state=itype action-name=term action=itype]
5630−:: A unit distinguishes a verified empty closure from a detached legacy file.
5631−:: The opaque prelude is an exact trusted input, not a recursive interface mold.
5632−+$ irequest-graph
5633− [paths=(set path) requests=(list irequest-evidence) stores=(list istore-request-evidence) bundle-input=* prelude-input=* prelude-values=(list term) prelude-molds=(list term) externals=iexternals marks=imark-externals]
5634−+$ 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)]
5399++$ ifile [values=ienv molds=imold-types at=path derived=(list iderived) elaborations=(list iwidth-definition) dependencies=(list iwidth-dependency) source=(unit @t)]
56355400+$ ijimports (list [face=term interface=ifile])
56365401+$ icap [name=@t id=@ud at=span]
56375402+$ icaps (list icap)
@@ -5734,77 +5499,7 @@
57345499 ?. (width-in-order order.source.shape order.target.shape) ~
57355500 (width-fit-fields index.source.shape order.target.shape sub next)
57365501::
5737−:: Provisional, globally budgeted gate-free proof. %no includes a
5738−:: gate-bearing witness; an uninhabited sibling could invalidate it.
5739−:: Input types must be resolved and normalized under valid substitutions,
5740−:: from trusted source-backed interfaces and reader results. Collection
5741−:: list/unit names rely on their existing identity invariant; this arm
5742−:: does not validate fabricated internal types.
5743−+$ igf-segment
5744− $% [%field name=term]
5745− [%head ~]
5746− [%tail ~]
5747− [%item ~]
5748− [%case index=@ud]
5749− ==
5750−+$ igate-free [verdict=?(%yes %no %unknown) inhabited=? left=@ud path=(unit (list igf-segment))]
5751−++ gate-free-types
5752− |= [types=(list itype) fuel=@ud path=(list igf-segment) index=@ud]
5753− ^- igate-free
5754− ?~ types [%yes | fuel ~]
5755− ?: =(0 fuel) [%unknown | 0 ~]
5756− =/ first=igate-free (gate-free-type i.types fuel [[%case index] path])
5757− ?: =(%no verdict.first) first
5758− =/ rest=igate-free $(types t.types, fuel left.first, index +(index))
5759− ?: =(%no verdict.rest) rest
5760− =/ inhabited=? |(inhabited.first inhabited.rest)
5761− ?: |(=(%unknown verdict.first) =(%unknown verdict.rest)) [%unknown inhabited left.rest ~]
5762− [%yes inhabited left.rest ~]
5763−++ gate-free-type
5764− |= [typ=itype fuel=@ud path=(list igf-segment)]
5765− ^- igate-free
5766− ?: =(0 fuel) [%unknown | 0 ~]
5767− =. fuel (dec fuel)
5768− ?- -.typ
5769− %fn [%no & fuel `(flop path)]
5770− %atom [%yes & fuel ~]
5771− %any-atom [%yes & fuel ~]
5772− %flag [%yes & fuel ~]
5773− %const [%yes & fuel ~]
5774− %face $(typ body.typ, path [[%field name.typ] path])
5775− %cell
5776− =/ head=igate-free $(typ hed.typ, path [[%head ~] path])
5777− =/ tail=igate-free $(typ tal.typ, fuel left.head, path [[%tail ~] path])
5778− =/ inhabited=? &(inhabited.head inhabited.tail)
5779− ?: |(&(=(%yes verdict.head) !inhabited.head) &(=(%yes verdict.tail) !inhabited.tail)) [%yes | left.tail ~]
5780− ?: &(=(%no verdict.head) inhabited.tail) head(left left.tail)
5781− ?: &(=(%no verdict.tail) inhabited.head) tail
5782− ?: |(!=(%yes verdict.head) !=(%yes verdict.tail)) [%unknown inhabited left.tail ~]
5783− [%yes inhabited left.tail ~]
5784− %collection
5785− ?. |(=(%list name.typ) =(%unit name.typ)) [%unknown | fuel ~]
5786− ?. ?=([* ~] args.typ) [%unknown | fuel ~]
5787− =/ item=igate-free $(typ i.args.typ, path [[%item ~] path])
5788− item(inhabited &)
5789− %union
5790− ?~ cases.typ [%unknown | fuel ~]
5791− (gate-free-types cases.typ fuel path 0)
5792− %noun [%unknown & fuel ~]
5793− %empty [%yes | fuel ~]
5794− %var [%unknown | fuel ~]
5795− %avar [%yes & fuel ~]
5796− %rvar [%yes & fuel ~]
5797− %nvar [%yes & fuel ~]
5798− %rnvar [%yes & fuel ~]
5799− %tag [%unknown | fuel ~]
5800− %recursive [%unknown | fuel ~]
5801− %jrec [%yes & fuel ~]
5802− %grec [%unknown | fuel ~]
5803− ==
5804−::
5805−+$ igate-prelude-evidence [iface=ifile gates=(map term def)]
5806−+$ dgo [left=itype right=itype at=span context=span]
5807−+$ istate [next=@ud sub=isub caps=icaps binders=(list @ud) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) params=iparams active=(list term) tags=(list ipending) in-mold=? at=path top-molds=(list term) prelude=(unit ifile) holes=(list ihole) jrec-fuel=@ud projections=(list iwprojection) gate-defs=(map term def) head-evidence=(unit igate-prelude-evidence) grec-index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)]) defer=(unit ~) obligations=(list dgo)]
5502++$ 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)]
58085503+$ idiag [msg=tape sites=(list [at=span note=tape])]
58095504+$ iresult (each [typ=itype state=istate] idiag)
58105505+$ isample-result (each [typ=itype env=ienv state=istate] tape)
@@ -5824,7 +5519,6 @@
58245519 |= [t=itype sub=isub]
58255520 ^- itype
58265521 =. t (itype-walk t sub)
5827− ?: ?=(%grec -.t) t(args (turn args.t |=(c=itype (itype-normalize c sub))))
58285522 ?: ?=(%collection -.t) [%collection name.t (turn args.t |=(c=itype (itype-normalize c sub)))]
58295523 ?: ?=(%union -.t)
58305524 [%union (turn cases.t |=(c=itype (itype-normalize c sub))) origin.t label.t (turn args.t |=(c=itype (itype-normalize c sub)))]
@@ -5851,7 +5545,6 @@
58515545 %cell |($(t hed.t) $(t tal.t))
58525546 %recursive |
58535547 %jrec |
5854− %grec &
58555548 %collection (lien args.t |=(c=itype (itype-has-gate c)))
58565549 %face $(t body.t)
58575550 %union (lien cases.t |=(c=itype (itype-has-gate c)))
@@ -5866,7 +5559,6 @@
58665559 %any-atom |
58675560 %flag |
58685561 %noun |
5869− %empty |
58705562 ==
58715563::
58725564++ default-decimals
@@ -5876,7 +5568,6 @@
58765568 ?- -.t
58775569 %nvar [%atom %ud]
58785570 %rnvar [%atom %ud]
5879− %grec t(args (turn args.t |=(c=itype (default-decimals c))))
58805571 %collection [%collection name.t (turn args.t |=(c=itype (default-decimals c)))]
58815572 %face [%face name.t $(t body.t)]
58825573 %cell [%cell $(t hed.t) $(t tal.t)]
@@ -5918,7 +5609,6 @@
59185609 %tag |
59195610 %any-atom &
59205611 %union &((levy cases.t |=(c=itype (hole-known c state))) (levy args.t |=(c=itype (hole-known c state))))
5921− %grec (levy args.t |=(c=itype (hole-known c state)))
59225612 %collection (levy args.t |=(c=itype (hole-known c state)))
59235613 %face $(t body.t)
59245614 %fn &($(t sample.t) $(t product.t))
@@ -5928,8 +5618,6 @@
59285618++ promote-restricted-numbers
59295619 |= [state=istate env=ienv]
59305620 ^- istate
5931− :: With no written capitals, there is nothing to promote.
5932− ?~ caps.state state
59335621 =/ ids=(list @ud) (turn caps.state |=(c=icap id.c))
59345622 =/ free=(list @ud) (free-env-vars env sub.state)
59355623 |-
@@ -5966,7 +5654,6 @@
59665654 ?- -.t
59675655 ?(%tag %nvar %rnvar %avar %rvar) !(hole-known t state)
59685656 %union |((lien cases.t |=(c=itype (hole-uncertain c state))) (lien args.t |=(c=itype (hole-uncertain c state))))
5969− %grec (lien args.t |=(c=itype (hole-uncertain c state)))
59705657 %collection (lien args.t |=(c=itype (hole-uncertain c state)))
59715658 %face $(t body.t)
59725659 %fn |($(t sample.t) $(t product.t))
@@ -5998,13 +5685,11 @@
59985685 %any-atom ~
59995686 %flag ~
60005687 %noun ~
6001− %empty ~
60025688 %tag ~
60035689 %const ~
60045690 %union (zing (turn (weld args.t cases.t) |=(c=itype (itype-vars c))))
60055691 %recursive ~
60065692 %jrec ~
6007− %grec (zing (turn args.t |=(c=itype (itype-vars c))))
60085693 %collection (zing (turn args.t |=(c=itype (itype-vars c))))
60095694 %face $(t body.t)
60105695 %fn (weld $(t sample.t) $(t product.t))
@@ -6048,13 +5733,11 @@
60485733 %any-atom t
60495734 %flag t
60505735 %noun t
6051− %empty t
60525736 %tag t
60535737 %const t
60545738 %union [%union (turn cases.t |=(c=itype (itype-rename c ren))) origin.t label.t (turn args.t |=(c=itype (itype-rename c ren)))]
60555739 %recursive t
60565740 %jrec t
6057− %grec t(args (turn args.t |=(c=itype (itype-rename c ren))))
60585741 %collection [%collection name.t (turn args.t |=(c=itype (itype-rename c ren)))]
60595742 %face [%face name.t $(t body.t)]
60605743 %fn [%fn $(t sample.t) $(t product.t)]
@@ -6077,13 +5760,11 @@
60775760 %any-atom |
60785761 %flag |
60795762 %noun |
6080− %empty |
60815763 %tag |
60825764 %const |
60835765 %union |((lien cases.t |=(c=itype (itype-var-is-atom n c))) (lien args.t |=(c=itype (itype-var-is-atom n c))))
60845766 %recursive |
60855767 %jrec |
6086− %grec (lien args.t |=(c=itype (itype-var-is-atom n c)))
60875768 %collection (lien args.t |=(c=itype (itype-var-is-atom n c)))
60885769 %face $(t body.t)
60895770 %fn |($(t sample.t) $(t product.t))
@@ -6102,13 +5783,11 @@
61025783 %any-atom |
61035784 %flag |
61045785 %noun |
6105− %empty |
61065786 %tag |
61075787 %const |
61085788 %union |((lien cases.t |=(c=itype (itype-var-is-restricted n c))) (lien args.t |=(c=itype (itype-var-is-restricted n c))))
61095789 %recursive |
61105790 %jrec |
6111− %grec (lien args.t |=(c=itype (itype-var-is-restricted n c)))
61125791 %collection (lien args.t |=(c=itype (itype-var-is-restricted n c)))
61135792 %face $(t body.t)
61145793 %fn |($(t sample.t) $(t product.t))
@@ -6405,7 +6084,6 @@
64056084 ^- upat
64066085 ?- -.typ
64076086 %noun [%all ~]
6408− %empty [%empty ~]
64096087 %atom [%atom ~]
64106088 %flag [%or ~[[%atom `0] [%atom `1]]]
64116089 %const [%atom `val.literal.typ]
@@ -6540,16 +6218,6 @@
65406218 ?: &(?=(~ vars.template) ?=(%jrec -.typ.template) =(at.typ.template origin) =(name.typ.template name)) `name.i.molds
65416219 $(molds t.molds)
65426220::
6543−++ grec-visible-alias
6544− |= [origin=path name=term proof=shape args=(list itype) molds=imold-types]
6545− ^- (unit term)
6546− ?~ molds ~
6547− =/ template=ischeme template.i.molds
6548− ?. ?=(%grec -.typ.template) $(molds t.molds)
6549− ?. &(=(at.typ.template origin) =(name.typ.template name) =(proof.typ.template proof)) $(molds t.molds)
6550− ?. &((identity-union-parameters vars.template args.typ.template) =((lent vars.template) (lent args))) $(molds t.molds)
6551− `name.i.molds
6552−::
65536221++ itype-in-import
65546222 |= [t=itype iface=ifile face=term prelude=(unit ifile)]
65556223 ^- itype
@@ -6569,11 +6237,6 @@
65696237 `(crip "{(trip u.alias)}.{(trip face)}")
65706238 [%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)))]
65716239 %recursive [%recursive module.t name.t ~]
6572− %grec
6573− =/ public=(unit term) ?~(prelude ~ (grec-visible-alias at.t name.t proof.t args.t molds.u.prelude))
6574− =/ alias=(unit term) ?~(public (grec-visible-alias at.t name.t proof.t args.t molds.iface) public)
6575− =/ label=(unit @t) ?~(alias ~ ?~(public `(crip "{(trip u.alias)}.{(trip face)}") `u.alias))
6576− t(label label, args (turn args.t |=(c=itype (itype-in-import c iface face prelude))))
65776240 %jrec
65786241 =/ public=(unit term) ?~(prelude ~ (jrec-alias at.t name.t molds.u.prelude))
65796242 ?^ public t(label `u.public)
@@ -6686,29 +6349,9 @@
66866349 ?. =(names.tail ~[name]) ~
66876350 `[%jrec at.state name `name name.i.fs aura.shape.i.fs name.i.t.fs]
66886351::
6689−++ simple-source-generic-recursive
6690− |= [name=term sh=shape args=(list itype) state=istate]
6691− ^- (unit itype)
6692− ?. ?=(%generic -.sh) ~
6693− ?. ?=([@ ~] vars.sh) ~
6694− ?. ?=([* ~] args) ~
6695− ?~ grec-index.state ~
6696− ?. =(at.u.grec-index.state at.state) ~
6697− ?~ prelude.state ~
6698− ?. =(prelude.u.grec-index.state u.prelude.state) ~
6699− =/ proof=(unit shape) (~(get by shapes.u.grec-index.state) name)
6700− ?~ proof ~
6701− ?. =(u.proof sh) ~
6702− `[%grec at.state name `name sh args]
6703−::
6704−
67056352++ infer-mold-template
67066353 |= [sh=shape state=istate]
67076354 ^- (unit [template=ischeme state=istate])
6708− =/ generic=(unit itype)
6709− ?. ?=([@ ~] active.state) ~
6710− (simple-source-generic-recursive i.active.state sh ~[[%var next.state]] state)
6711− ?^ generic `[[u.generic ~[next.state]] state(next +(next.state))]
67126355 =/ direct=(unit itype)
67136356 ?. ?=([@ ~] active.state) ~
67146357 (simple-source-recursive i.active.state sh state)
@@ -6766,7 +6409,7 @@
67666409 ?~ found ~
67676410 ?^ t.found ~
67686411 result.i.found
6769− ?. ?=([%invalid ?(%aura %core %overlap) @] raw) ~
6412+ ?. ?=([%invalid ?(%aura %core) @] raw) ~
67706413 `["{(trip +>.raw)}" ~[[at.sh "invalid imported mold"]]]
67716414::
67726415:: Replay only the shape branches whose evaluation order we can prove.
@@ -6841,18 +6484,12 @@
68416484 `[[%atom aura.sh] state]
68426485 %flag `[[%flag ~] state]
68436486 %noun `[[%noun ~] state]
6844− %void `[[%empty ~] state]
68456487 %const
6846− ?. |(=(%term form.lit.sh) =(%null form.lit.sh) =(%loobean form.lit.sh)) ~
6847− ?: &(=(%loobean form.lit.sh) !|(=(0 val.lit.sh) =(1 val.lit.sh))) ~
6488+ ?. |(=(%term form.lit.sh) =(%null form.lit.sh)) ~
68486489 `[[%const lit.sh] state]
68496490 %union
68506491 =/ pairs=(list upair) (union-pairs cases.sh molds.state)
6851− ?: (lien pairs |=(p=upair =(%overlap relation.p))) ~
6852− =/ source-proof=?
6853− ?: (levy pairs |=(p=upair =(%disjoint relation.p))) &
6854− &((union-source-state-safe state 256) (union-source-distinct-tags cases.sh molds.state 256))
6855− ?. source-proof ~
6492+ ?. (levy pairs |=(p=upair =(%disjoint relation.p))) ~
68566493 =/ cs=(unit [types=(list itype) state=istate]) (infer-shape-args cases.sh state)
68576494 ?~ cs ~
68586495 `[[%union types.u.cs ~ ~ ~] state.u.cs]
@@ -6926,8 +6563,6 @@
69266563 ?~ applied ~
69276564 `[u.applied state.u.args]
69286565 ?. ?=(%generic -.u.found) ~
6929− =/ grec=(unit itype) (simple-source-generic-recursive n u.found types.u.args state.u.args)
6930− ?^ grec `[u.grec state.u.args]
69316566 ?. (distinct-params vars.u.found) ~
69326567 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
69336568 ?~ params ~
@@ -7256,7 +6891,6 @@
72566891 =/ retried=? ?=(%| -.inferred)
72576892 =? inferred retried (infer-recursive-gate d env local-state)
72586893 ?: ?=(%| -.inferred) $(ds t.ds, remaining [d remaining])
7259− ?: !=(obligations.state.p.inferred obligations.state) [%| ["deferred local definition needs unsupported inference" ~]]
72606894 =. state.p.inferred (promote-restricted-numbers state.p.inferred env)
72616895 =. 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)))
72626896 =/ hole=(unit idiag) (unresolved-hole holes.state.p.inferred holes.state state.p.inferred)
@@ -7366,8 +7000,6 @@
73667000 ?: &(?=(%collection -.expected) =(%list name.expected) (context-list-expression e))
73677001 (infer-list-context e expected env state context)
73687002 ?: ?=(%branch -.e)
7369− =/ empty-list=(unit iresult) (empty-list-null-branch e env state `[expected context])
7370− ?^ empty-list u.empty-list
73717003 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
73727004 ?~ t.arms.e [%| ["branch pattern is not supported by partial inference" ~]]
73737005 ?^ t.t.arms.e [%| ["branch is not supported by partial inference" ~]]
@@ -7481,12 +7113,7 @@
74817113 =/ target=itype (itype-walk expected sub.state)
74827114 =/ value=iresult (infer-call-context-arg i.items target env state context)
74837115 ?: ?=(%| -.value) value
7484− =/ ordinary-fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
7485− =/ fit=ifit
7486− ?: ?=(%ok -.ordinary-fit) ordinary-fit
7487− ?: ?&(?=(%union -.target) ?=(^ prelude.state) =(origin.target `[at.u.prelude.state %element]))
7488− (program-single-generic-fit typ.p.value target sub.state.p.value next.state.p.value)
7489− ordinary-fit
7116+ =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
74907117 ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
74917118 ?: ?=(%bad -.fit)
74927119 ?: |((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))
@@ -7503,12 +7130,7 @@
75037130 =/ target=itype (itype-walk expected sub.state)
75047131 =/ value=iresult (infer-call-context-arg i.items target env state context)
75057132 ?: ?=(%| -.value) value
7506− =/ ordinary-fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
7507− =/ fit=ifit
7508− ?: ?=(%ok -.ordinary-fit) ordinary-fit
7509− ?: ?&(?=(%union -.target) ?=(^ prelude.state) =(origin.target `[at.u.prelude.state %element]))
7510− (program-single-generic-fit typ.p.value target sub.state.p.value next.state.p.value)
7511− ordinary-fit
7133+ =/ fit=ifit (itype-fit typ.p.value target sub.state.p.value next.state.p.value)
75127134 ?: ?=(%unknown -.fit) [%| ["list item constraint is not supported by partial inference" ~]]
75137135 ?: ?=(%bad -.fit)
75147136 =/ missing=(unit idiag) (missing-union-tag i.items target sub.state.p.value context)
@@ -7595,11 +7217,6 @@
75957217 [%| ["list pattern needs the standard prelude in partial inference" ~]]
75967218 ?~ args.typ [%| ["list pattern is not supported by partial inference" ~]]
75977219 ?^ t.args.typ [%| ["list pattern is not supported by partial inference" ~]]
7598− =/ item-live=(unit [result=?(%yes %no %unknown) left=@ud])
7599− (itype-inhabited-proof i.args.typ sub.state caps.state 256)
7600− ?~ item-live [%| ["list element reachability needs unsupported inference" ~]]
7601− ?: =(%unknown result.u.item-live) [%| ["list element reachability needs unsupported inference" ~]]
7602− ?: =(%no result.u.item-live) [%| ["list nonempty pattern is unreachable" ~]]
76037220 ?~ arms.e [%| ["list branch is not supported by partial inference" ~]]
76047221 ?~ t.arms.e [%| ["list branch is not supported by partial inference" ~]]
76057222 ?^ t.t.arms.e [%| ["list branch is not supported by partial inference" ~]]
@@ -7653,11 +7270,6 @@
76537270 [%| ["pattern binder shadows a name" ~]]
76547271 =/ payload=(unit itype) (unit-union-payload typ)
76557272 ?~ payload [%| ["unit branch subject is not supported by partial inference" ~]]
7656− =/ payload-live=(unit [result=?(%yes %no %unknown) left=@ud])
7657− (itype-inhabited-proof u.payload sub.state.p.subject caps.state.p.subject 256)
7658− ?~ payload-live [%| ["unit payload reachability needs unsupported inference" ~]]
7659− ?: =(%unknown result.u.payload-live) [%| ["unit payload reachability needs unsupported inference" ~]]
7660− ?: =(%no result.u.payload-live) [%| ["unit present pattern is unreachable" ~]]
76617273 =/ extended=ienv [[u.binder [u.payload ~]] env]
76627274 =/ left=iresult
76637275 ?~ expected (infer-fragment val.x ?:(first-empty env extended) state.p.subject)
@@ -7810,9 +7422,7 @@
78107422 ?: ?=(%| -.subject) `subject
78117423 =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
78127424 ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
7813− =/ live=(unit (list itype)) (itype-live-cases cases.typ sub.state.p.subject caps.state.p.subject 4.096)
7814− ?~ live ~
7815− =/ cases=(list itype) u.live
7425+ =/ cases=(list itype) cases.typ
78167426 =/ remaining=(list itype) cases
78177427 =/ arms=(list arm) arms.e
78187428 =/ st=istate state.p.subject
@@ -7849,9 +7459,7 @@
78497459 ?: ?=(%| -.subject) `subject
78507460 =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
78517461 ?. ?=(%union -.typ) `[%| ["branch is not supported by partial inference" ~]]
7852− =/ live=(unit (list itype)) (itype-live-cases cases.typ sub.state.p.subject caps.state.p.subject 4.096)
7853− ?~ live ~
7854− =/ cases=(list itype) u.live
7462+ =/ cases=(list itype) cases.typ
78557463 =/ remaining=(list itype) cases
78567464 =/ arms=(list arm) arms.e
78577465 =/ st=istate state.p.subject
@@ -7895,9 +7503,7 @@
78957503 ?: ?=(%| -.subject) subject
78967504 =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
78977505 ?. ?=(%union -.typ) [%| ["branch is not supported by partial inference" ~]]
7898− =/ live=(unit (list itype)) (itype-live-cases cases.typ sub.state.p.subject caps.state.p.subject 4.096)
7899− ?~ live [%| ["union emptiness needs unsupported inference" ~]]
7900− =/ expanded=(unit (list ifinite)) (finite-cases u.live ~ 0)
7506+ =/ expanded=(unit (list ifinite)) (finite-cases cases.typ ~ 0)
79017507 ?~ expanded [%| ["union pattern expansion needs unsupported inference" ~]]
79027508 =/ cases=(list ifinite) u.expanded
79037509 =/ remaining=(list ifinite) cases
@@ -8018,65 +7624,9 @@
80187624 =/ cell=itype [%cell [%face head.typ [%atom aura.typ]] [%face tail.typ typ]]
80197625 [%& [%union ~[nil cell] ~ ~ ~] state.p.subject(jrec-fuel (dec jrec-fuel.state.p.subject))]
80207626::
8021−:: A bounded source-proven tree match permits flat tag patterns and
8022−:: nonbinding catch-alls. Whole-case binders cannot consume the temporary
8023−:: structural view. Pattern count and field arity are checked first.
8024−++ grec-simple-pattern
8025− |= [pat=pattern view=itype]
8026− ^- ?
8027− ?. ?=(%cell -.pat) |
8028− ?~ items.pat |
8029− =/ first=pattern i.items.pat
8030− ?. ?=(%lit -.first) |
8031− ?. =(%term form.lit.first) |
8032− =/ chosen=(unit itype) (contextual-tagged-case view val.lit.first ~)
8033− ?~ chosen |
8034− ?> ?=(%cell -.u.chosen)
8035− =/ rest=(list pattern) t.items.pat
8036− =/ arity=? ?:(?=(%cell -.tal.u.chosen) ?=([* [* ~]] rest) ?=([* ~] rest))
8037− ?. arity |
8038− (levy rest |=(p=pattern |(?=(%bind -.p) ?=(%any -.p))))
8039−::
8040−:: A catch-all with no binder is safe even when it covers both cases.
8041−:: A bound whole case still declines to avoid exporting the analysis view.
8042−++ grec-patterns-eligible
8043− |= [arms=(list arm) view=itype left=@ud]
8044− ^- ?
8045− ?~ arms &
8046− ?: =(0 left) |
8047− =/ pat=pattern pat.i.arms
8048− ?. |(?=(%any -.pat) (grec-simple-pattern pat view)) |
8049− $(arms t.arms, left (dec left))
8050−++ grec-match-view
8051− |= [e=expr subject=iresult]
8052− ^- iresult
8053− ?: ?=(%| -.subject) subject
8054− ?. ?=(%branch -.e) subject
8055− ?. (grec-direct-context typ.p.subject sub.state.p.subject) subject
8056− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
8057− ?. ?=(%grec -.typ) subject
8058− ?~ arms.e subject
8059− =/ view=(unit [view=itype left=@ud]) (grec-unfold-view typ jrec-fuel.state.p.subject)
8060− ?~ view [%| ["recursive mold unfolding needs unsupported inference" ~]]
8061− ?. (grec-patterns-eligible arms.e view.u.view 128) subject
8062− [%& view.u.view state.p.subject(jrec-fuel left.u.view)]
8063−::
8064−:: A single-arm diagnostic only probes a direct, source-typed in-scope wing;
8065−:: other subjects retain the prior single-pattern inference path.
8066−++ grec-single-wing-subject
8067− |= [e=expr env=ienv state=istate]
8068− ^- (unit iresult)
8069− ?. ?=(%wing -.e) ~
8070− ?. ?=([@ ~] names.e) ~
8071− =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
8072− ?~ scheme ~
8073− ?. (grec-direct-context typ.u.scheme sub.state) ~
8074− `(infer-fragment e env state)
8075−::
80767627++ infer-known-union-branch-subject
80777628 |= [e=expr env=ienv subject=iresult]
80787629 ^- iresult
8079− =. subject (grec-match-view e subject)
80807630 =. subject (jrec-match-view e subject)
80817631 =/ whole=(unit iresult) (infer-known-union-whole e env subject)
80827632 ?~ whole (infer-known-union-finite e env subject ~)
@@ -8091,7 +7641,6 @@
80917641++ infer-known-union-context-subject
80927642 |= [e=expr expected=itype env=ienv subject=iresult context=span]
80937643 ^- iresult
8094− =. subject (grec-match-view e subject)
80957644 =. subject (jrec-match-view e subject)
80967645 =/ whole=(unit iresult) (infer-known-union-context-whole e expected env subject context)
80977646 ?~ whole (infer-known-union-finite e env subject `[expected context])
@@ -8144,67 +7693,9 @@
81447693 =/ subject=iresult (infer-fragment e env state)
81457694 ?: ?=(%| -.subject) ?:((union-subject-call e) `subject ~)
81467695 =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
8147− ?. |(?=(%union -.typ) ?=(%jrec -.typ) &(?=(%grec -.typ) (grec-direct-context typ.p.subject sub.state.p.subject))) ~
7696+ ?. |(?=(%union -.typ) ?=(%jrec -.typ)) ~
81487697 `subject
81497698::
8150−:: A direct wing with an already-known union may skip genuinely empty cases
8151−:: when checking a one-arm match. Other subjects keep their existing path.
8152−:: A directly known canonical list of an empty element contains only null.
8153−:: This helper never refines an opaque or variable-bound subject.
8154−++ empty-list-null-branch
8155− |= [e=expr env=ienv state=istate expected=(unit [typ=itype context=span])]
8156− ^- (unit iresult)
8157− ?. ?=(%branch -.e) ~
8158− ?~ arms.e ~
8159− ?^ t.arms.e ~
8160− ?. (unit-empty-pattern pat.i.arms.e) ~
8161− ?. ?=(%wing -.subject.e) ~
8162− ?. ?=([@ ~] names.subject.e) ~
8163− =/ scheme=(unit ischeme) (ienv-lookup i.names.subject.e env)
8164− ?~ scheme ~
8165− ?. ?=(%collection -.typ.u.scheme) ~
8166− ?. =(%list name.typ.u.scheme) ~
8167− ?~ prelude.state ~
8168− ?. =(at.u.prelude.state /lib/jibb/prelude/jibb) ~
8169− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude.state)
8170− ?~ standard ~
8171− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]]) ~
8172− =/ subject=iresult (infer-fragment subject.e env state)
8173− ?: ?=(%| -.subject) ~
8174− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
8175− ?. ?=(%collection -.typ) ~
8176− ?. =(%list name.typ) ~
8177− ?~ args.typ ~
8178− ?^ t.args.typ ~
8179− =/ proof=(unit [empty=? left=@ud]) (itype-empty-proof i.args.typ sub.state.p.subject 256)
8180− ?~ proof ~
8181− ?. empty.u.proof ~
8182− ?~ expected `(infer-fragment val.i.arms.e env state.p.subject)
8183− =/ body=iresult (infer-call-context-arg val.i.arms.e typ.u.expected env state.p.subject context.u.expected)
8184− ?: ?=(%| -.body) `body
8185− =/ fit=ifit (itype-fit typ.p.body typ.u.expected sub.state.p.body next.state.p.body)
8186− ?: ?=(%unknown -.fit) `[%| ["single-case branch result constraint is not supported by partial inference" ~]]
8187− ?: ?=(%bad -.fit) `[%| ["single-case branch arm does not fit its expected type" ~[[context.u.expected "expected type"] [(span-of val.i.arms.e) "branch arm"]]]]
8188− ?: (itype-has-tag (itype-normalize typ.u.expected sub.fit))
8189− `[%| ["single-case branch result needs context in partial inference" ~]]
8190− `[%& typ.p.body state.p.body(sub sub.fit, next next.fit)]
8191−::
8192−++ known-empty-union-wing
8193− |= [e=expr env=ienv state=istate]
8194− ^- (unit iresult)
8195− ?. ?=(%wing -.e) ~
8196− ?. ?=([@ ~] names.e) ~
8197− =/ scheme=(unit ischeme) (ienv-lookup i.names.e env)
8198− ?~ scheme ~
8199− ?. (contextual-direct-union typ.u.scheme) ~
8200− =/ subject=iresult (infer-fragment e env state)
8201− ?: ?=(%| -.subject) ~
8202− =/ typ=itype (itype-normalize typ.p.subject sub.state.p.subject)
8203− ?. ?=(%union -.typ) ~
8204− =/ live=(unit (list itype)) (itype-live-cases cases.typ sub.state.p.subject caps.state.p.subject 4.096)
8205− ?~ live ~
8206− ?: =(u.live cases.typ) ~
8207− `subject
82087699::
82097700:: Infer changes only against a fully known record spine. Retain the
82107701:: target type; unknown spines and repeated edits remain unsupported.
@@ -8449,10 +7940,7 @@
84497940 =/ traced=iresult $(e val.e)
84507941 ?: ?=(%| -.traced) traced
84517942 $(e then.e, state state.p.traced)
8452− %tuple
8453− ?: &(?=(^ defer.state) ?=(^ prelude.state))
8454− (dg-infer-tuple-items items.e env state)
8455− (infer-simple-items items.e env state)
7943+ %tuple (infer-simple-items items.e env state)
84567944 %body
84577945 ?~ defs.e $(e final.e)
84587946 =/ local-names=(list term) (global-value-names defs.e)
@@ -8475,15 +7963,8 @@
84757963 ?: ?=(%| -.result) result
84767964 [%& typ.p.result state.p.result(globals globals.state, molds molds.state)]
84777965 %branch
8478− ?^ defer.state (dg-boolean-branch e env state)
84797966 ?~ arms.e [%| ["branch is not supported by partial inference" ~]]
84807967 ?~ t.arms.e
8481− =/ empty-list=(unit iresult) (empty-list-null-branch e env state ~)
8482− ?^ empty-list u.empty-list
8483− =/ empty-union=(unit iresult) (known-empty-union-wing subject.e env state)
8484− ?^ empty-union (infer-known-union-branch-subject e env u.empty-union)
8485− =/ single=(unit iresult) (grec-single-wing-subject subject.e env state)
8486− ?^ single (infer-known-union-branch-subject e env u.single)
84877968 ?: (single-structured-pattern e) (infer-single-case-branch e env state ~)
84887969 (infer-cell-branch e env state ~)
84897970 ?^ t.t.arms.e (infer-known-union-branch e env state)
@@ -8551,8 +8032,6 @@
85518032 =/ 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)
85528033 ?^ nested [%| u.nested]
85538034 [%| ["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)]]]]
8554− ?: &(?=(^ defer.state.p.value) !(dg-stable-fit typ.p.value typ.u.target sub.fit))
8555− [%| ["deferred cast fit needs stable inference" ~]]
85568035 =/ merged=itype (itype-merge-faces typ.p.value typ.u.target sub.fit)
85578036 [%& merged state.p.value(sub sub.fit, next next.fit)]
85588037 %crash [%& [%var next.state] state(next +(next.state))]
@@ -8602,234 +8081,6 @@
86028081 ?: ?=(%| -.out) [%| p.out]
86038082 [%& [e typ.p.out sub.state.p.out (flop projections.state.p.out)]]
86048083::
8605−:: Source-bound gate-layout evidence, confined to checked root gate
8606−:: definitions and direct unshadowed prelude calls. The prepared prelude
8607−:: interface and its retained source are trusted as a matching artifact.
8608−:: Layouts identify sample binder faces; they do not change call arity or
8609−:: authorize stripping nested value faces. Unknown origins use ordinary fit.
8610−++ direct-written-gates
8611− |= [ds=(list def) out=ivisited]
8612− ^- ivisited
8613− ?~ ds out
8614− ?: ?=(%mold -.i.ds) $(ds t.ds)
8615− ?. |(?=(%gate -.val.i.ds) ?=(%gate-wide -.val.i.ds)) $(ds t.ds)
8616− $(ds t.ds, out (~(put by out) name.i.ds &))
8617−++ direct-may-use-prelude
8618− |= [ds=(list def) root=ivisited heads=ivisited]
8619− ^- ?
8620− ?~ ds |
8621− ?: ?=(%mold -.i.ds) $(ds t.ds)
8622− =/ refs=(list term) (dependency-expr val.i.ds)
8623− =/ has-root=? (lien refs |=(n=term ?=(^ (~(get by root) n))))
8624− =/ has-head=? (lien refs |=(n=term ?=(^ (~(get by heads) n))))
8625− ?: &(has-root has-head) &
8626− $(ds t.ds)
8627−++ direct-unique-names
8628− |= [names=(list term) seen=ivisited]
8629− ^- ?
8630− ?~ names &
8631− ?: ?=(^ (~(get by seen) i.names)) |
8632− $(names t.names, seen (~(put by seen) i.names &))
8633−++ direct-prelude-evidence
8634− |= [ds=(list def) prelude=(unit ifile)]
8635− ^- (unit igate-prelude-evidence)
8636− ?~ prelude ~
8637− ?~ source.u.prelude ~
8638− =/ root=ivisited (direct-written-gates ds ~)
8639− =/ names=(list term) (turn values.u.prelude |=(e=[name=term scheme=ischeme] name.e))
8640− =/ heads=ivisited (graph-nameset names ~)
8641− ?. (direct-may-use-prelude ds root heads) ~
8642− =/ parsed (parse at.u.prelude u.source.u.prelude)
8643− ?: ?=(%| -.parsed) ~
8644− ?^ (duplicate-defs defs.p.parsed) ~
8645− ?. (direct-unique-names (global-value-names defs.p.parsed) ~) ~
8646− =/ gates=(map term def) (direct-checked-gates defs.p.parsed values.u.prelude)
8647− `[u.prelude gates]
8648−++ direct-checked-gates
8649− |= [ds=(list def) env=ienv]
8650− ^- (map term def)
8651− =/ names=(list term) (turn env |=(e=[name=term scheme=ischeme] name.e))
8652− =/ known=ivisited (graph-nameset names ~)
8653− =/ out=(map term def) ~
8654− |-
8655− ?~ ds out
8656− =/ d=def i.ds
8657− ?: ?=(%mold -.d) $(ds t.ds)
8658− ?. ?=(^ (~(get by known) name.d)) $(ds t.ds)
8659− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) $(ds t.ds)
8660− $(ds t.ds, out (~(put by out) name.d d))
8661−++ direct-find-gate
8662− |= [n=term ds=(list def)]
8663− ^- (unit def)
8664− ?~ ds ~
8665− ?: &(?=(%value -.i.ds) =(n name.i.ds)) `i.ds
8666− $(ds t.ds)
8667−++ direct-gate-sample
8668− |= d=def
8669− ^- (unit sample)
8670− ?. ?=(%value -.d) ~
8671− ?- -.val.d
8672− %gate `sample.val.d
8673− %gate-wide `sample.val.d
8674− * ~
8675− ==
8676−++ direct-sample-name
8677− |= sam=sample
8678− ^- (unit term)
8679− ?- -.sam
8680− %bind `name.sam
8681− %face `name.sam
8682− %pun `name.sam
8683− * ~
8684− ==
8685−++ direct-field-name
8686− |= f=field
8687− ^- (unit term)
8688− ?- -.f
8689− %face `name.f
8690− %pun `name.f
8691− * ~
8692− ==
8693−++ direct-slot-body
8694− |= [typ=itype name=(unit term)]
8695− ^- (unit itype)
8696− ?~ name `typ
8697− ?. ?=(%face -.typ) ~
8698− ?. =(name.typ u.name) ~
8699− `body.typ
8700−++ direct-invariant
8701− |= [a=itype b=itype sub=isub next=@ud]
8702− ^- ifit
8703− ?: (itype-face-asym a b sub) [%unknown ~]
8704− =/ forward=ifit (itype-fit a b sub next)
8705− ?. ?=(%ok -.forward) [%unknown ~]
8706− ?: (itype-face-asym a b sub.forward) [%unknown ~]
8707− =/ reverse=ifit (itype-fit b a sub.forward next.forward)
8708− ?. ?=(%ok -.reverse) [%unknown ~]
8709− reverse
8710−++ direct-function-fit
8711− |= [a=itype b=itype sam=sample sh=shape sub=isub next=@ud]
8712− ^- ifit
8713− ?. &(?=(%fn -.a) ?=(%fn -.b) ?=(%cell -.sam) ?=(%fn -.sh)) [%unknown ~]
8714− ?. ?=(%cell -.sample.sh) [%unknown ~]
8715− =/ as=(list sample) items.sam
8716− =/ bs=(list field) fields.sample.sh
8717− ?~ as [%unknown ~]
8718− ?~ t.as [%unknown ~]
8719− ?^ t.t.as [%unknown ~]
8720− ?~ bs [%unknown ~]
8721− ?~ t.bs [%unknown ~]
8722− ?^ t.t.bs [%unknown ~]
8723− ?. &(?=(%cell -.sample.a) ?=(%cell -.sample.b)) [%unknown ~]
8724− =/ an=(unit term) (direct-sample-name i.as)
8725− =/ bn=(unit term) (direct-field-name i.bs)
8726− ?: &(?=(^ an) ?=(^ bn) !=(u.an u.bn)) [%unknown ~]
8727− =/ x=(unit itype) (direct-slot-body hed.sample.a an)
8728− =/ y=(unit itype) (direct-slot-body hed.sample.b bn)
8729− ?~ x [%unknown ~]
8730− ?~ y [%unknown ~]
8731− =/ first=ifit (direct-invariant u.x u.y sub next)
8732− ?. ?=(%ok -.first) [%unknown ~]
8733− =. an (direct-sample-name i.t.as)
8734− =. bn (direct-field-name i.t.bs)
8735− ?: &(?=(^ an) ?=(^ bn) !=(u.an u.bn)) [%unknown ~]
8736− =/ x2=(unit itype) (direct-slot-body tal.sample.a an)
8737− =/ y2=(unit itype) (direct-slot-body tal.sample.b bn)
8738− ?~ x2 [%unknown ~]
8739− ?~ y2 [%unknown ~]
8740− =/ second=ifit (direct-invariant u.x2 u.y2 sub.first next.first)
8741− ?. ?=(%ok -.second) [%unknown ~]
8742− (direct-invariant product.a product.b sub.second next.second)
8743−:: This is a tentative proof: its caller must require closed call samples
8744−:: and repeat every positional check under the stable final substitution.
8745−++ direct-positional-fit
8746− |= [args=(list expr) slots=(list sample) actual=itype expected=itype env=ienv state=istate sub=isub next=@ud]
8747− ^- ifit
8748− ?~ args [%unknown ~]
8749− ?~ slots [%unknown ~]
8750− =/ last=? ?=(~ t.args)
8751− ?: !=(last ?=(~ t.slots)) [%unknown ~]
8752− =/ split=(unit [left=itype right=itype])
8753− ?: last `[actual expected]
8754− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8755− `[hed.actual hed.expected]
8756− ?~ split [%unknown ~]
8757− =/ x=itype left.u.split
8758− =/ y=itype right.u.split
8759− =/ expected-name=(unit term) (direct-sample-name i.slots)
8760− =/ expected-body=(unit itype) (direct-slot-body y expected-name)
8761− ?~ expected-body [%unknown ~]
8762− =. y u.expected-body
8763− =/ fit=ifit (itype-fit x y sub next)
8764− =/ accepted=? &(?=(%ok -.fit) !(itype-positional-slot-face-asym x y sub.fit))
8765− =/ result=(unit ifit)
8766− ?: accepted `fit
8767− ?. &(?=(%face -.i.slots) ?=(%fn -.shape.i.slots)) ~
8768− ?. ?=(%wing -.i.args) ~
8769− ?. ?=([@ ~] names.i.args) ~
8770− ?. (unique-value-name i.names.i.args globals.state) ~
8771− =/ source=(unit def) (~(get by gate-defs.state) i.names.i.args)
8772− ?~ source ~
8773− =/ sample=(unit sample) (direct-gate-sample u.source)
8774− ?~ sample ~
8775− =/ trial=ifit (direct-function-fit x y u.sample shape.i.slots sub next)
8776− ?. ?=(%ok -.trial) ~
8777− `trial
8778− ?~ result [%unknown ~]
8779− =. fit u.result
8780− ?: last fit
8781− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) [%unknown ~]
8782− ?. ?=(%ok -.fit) [%unknown ~]
8783− $(args t.args, slots t.slots, actual tal.actual, expected tal.expected, sub sub.fit, next next.fit)
8784−++ direct-any-gate-arg
8785− |= [args=(list expr) defs=(map term def)]
8786− ^- ?
8787− ?~ args |
8788− =/ found=?
8789− ?. ?=(%wing -.i.args) |
8790− ?. ?=([@ ~] names.i.args) |
8791− ?=(^ (~(get by defs) i.names.i.args))
8792− ?: found &
8793− $(args t.args)
8794−++ direct-gate-call-fit
8795− |= [e=expr actual=itype expected=itype env=ienv state=istate]
8796− ^- (unit ifit)
8797− ?. ?=(%call -.e) ~
8798− ?~ args.e ~
8799− ?~ t.args.e ~
8800− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) ~
8801− ?. ?=(%wing -.head.e) ~
8802− ?. ?=([@ ~] names.head.e) ~
8803− ?. ?=(~ (ienv-lookup i.names.head.e env)) ~
8804− ?. (unique-value-name i.names.head.e globals.state) ~
8805− ?. (direct-any-gate-arg args.e gate-defs.state) ~
8806− ?~ prelude.state ~
8807− ?~ source.u.prelude.state ~
8808− ?~ head-evidence.state ~
8809− ?. =(u.prelude.state iface.u.head-evidence.state) ~
8810− ?. ?=(^ (ienv-lookup i.names.head.e values.u.prelude.state)) ~
8811− =/ head=(unit def) (~(get by gates.u.head-evidence.state) i.names.head.e)
8812− ?~ head ~
8813− =/ sam=(unit sample) (direct-gate-sample u.head)
8814− ?~ sam ~
8815− ?. ?=(%cell -.u.sam) ~
8816− =/ fit=ifit (direct-positional-fit args.e items.u.sam actual expected env state sub.state next.state)
8817− ?. ?=(%ok -.fit) ~
8818− :: Enclosing inference may add constraints after this call. Only a
8819− :: closed call-sample proof can remain stable under those later bindings.
8820− =/ actual-final=itype (itype-normalize actual sub.fit)
8821− =/ expected-final=itype (itype-normalize expected sub.fit)
8822− ?^ (itype-vars actual-final) ~
8823− ?^ (itype-vars expected-final) ~
8824− ?: |((itype-has-tag actual-final) (itype-has-tag expected-final)) ~
8825− :: A later argument may resolve a variable used by an earlier slot.
8826− :: Recheck every fit and face against the completed substitution; no
8827− :: additional binding or fresh variable is permitted in the second pass.
8828− =/ verified=ifit (direct-positional-fit args.e items.u.sam actual expected env state sub.fit next.fit)
8829− ?. ?=(%ok -.verified) ~
8830− ?. &(=(sub.fit sub.verified) =(next.fit next.verified)) ~
8831− `fit
8832−::
88338084++ infer-call-with-head
88348085 |= [e=expr env=ienv state=istate head=iresult]
88358086 ^- iresult
@@ -8856,17 +8107,7 @@
88568107 =/ fit=ifit
88578108 ?^ t.args.e (itype-fit-inner typ.p.arg sample.ht sub.st next.st & |)
88588109 (itype-fit typ.p.arg sample.ht sub.st next.st)
8859− =/ direct=(unit ifit)
8860− ?: ?=(%ok -.fit) ~
8861− (direct-gate-call-fit e typ.p.arg sample.ht env st)
8862− =. fit ?~(direct fit u.direct)
8863− ?: ?=(%unknown -.fit)
8864− ?~ defer.st [%| ["call constraint is not supported by partial inference" ~]]
8865− =/ edge=(unit dgo) (dg-eligible-ctor e typ.p.head typ.p.arg sample.ht st)
8866− ?~ edge [%| ["call constraint is not supported by partial inference" ~]]
8867− ?: (gth (lent obligations.st) 63) [%| ["call constraint is not supported by partial inference" ~]]
8868− [%& product.ht st(obligations [u.edge obligations.st])]
8869−
8110+ ?: ?=(%unknown -.fit) [%| ["call constraint is not supported by partial inference" ~]]
88708111 ?: ?=(%bad -.fit)
88718112 ?~ t.args.e
88728113 =/ missing=(unit idiag) (missing-union-tag i.args.e sample.ht sub.st (span-of head.e))
@@ -8881,10 +8122,7 @@
88818122 =/ arg-at=span ?~(bad whole-args at.u.bad)
88828123 =/ arg-type=itype ?~(bad typ.p.arg typ.u.bad)
88838124 [%| ["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)]]]]
8884− ?: &(?=(^ defer.st) !(dg-stable-call-fit typ.p.arg sample.ht product.ht sub.fit ?=(^ t.args.e)))
8885− [%| ["deferred call fit needs stable inference" ~]]
88868125 =/ face-asym=?
8887− ?^ direct |
88888126 ?^ t.args.e (itype-positional-face-asym args.e typ.p.arg sample.ht sub.fit)
88898127 (itype-face-asym typ.p.arg sample.ht sub.fit)
88908128 ?: &((itype-has-face typ.p.arg sub.fit) face-asym (itype-output-may-be-cell product.ht sub.fit))
@@ -8951,10 +8189,9 @@
89518189 [%| ["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)]]]]
89528190 [%& expected state.p.value(sub sub.fit, next next.fit)]
89538191::
8954−:: A known gate may receive an enclosing target before its argument is
8955−:: inferred when its result is open or a direct, matching named generic
8956−:: union. Opaque, recursive, tag-constrained and variable-bound union
8957−:: results keep the existing directional path.
8192+:: A known gate whose result is still an inference variable can receive
8193+:: an enclosing target before its argument is inferred. Other products
8194+:: and unresolved calls use the existing directional path unchanged.
89588195++ infer-contextual-call
89598196 |= [e=expr expected=itype env=ienv state=istate]
89608197 ^- iresult
@@ -8965,31 +8202,7 @@
89658202 =/ ht=itype (itype-walk typ.p.head sub.state.p.head)
89668203 ?. ?=(%fn -.ht) (infer-call-with-head e env state head)
89678204 =/ result=itype (itype-walk product.ht sub.state.p.head)
8968− =/ eligible=?
8969− ?: ?=(%var -.result) &
8970− :: A direct known generic union may receive the same nominal result
8971− :: context before its arguments are checked. Variable-bound origins,
8972− :: pending tags, recursive identities and unknown atoms stay open.
8973− ?. &(?=(%union -.product.ht) ?=(%union -.result) ?=(%union -.expected)) |
8974− ?~ origin.result |
8975− ?. =(origin.result origin.expected) |
8976− ?~ args.result |
8977− ?. =((lent args.result) (lent args.expected)) |
8978− ?: |((itype-has-tag (itype-normalize result sub.state.p.head)) (itype-has-tag (itype-normalize expected sub.state.p.head))) |
8979− =/ result-recursive=? (itype-has-recursive (itype-normalize result sub.state.p.head))
8980− =/ expected-recursive=? (itype-has-recursive (itype-normalize expected sub.state.p.head))
8981− =/ result-ok=?
8982− ?. result-recursive &
8983− ?~ prelude.state |
8984− &(=(at.u.prelude.state /lib/jibb/prelude/jibb) =(origin.result `[at.u.prelude.state %element]))
8985− =/ expected-ok=?
8986− ?. expected-recursive &
8987− ?~ prelude.state |
8988− &(=(at.u.prelude.state /lib/jibb/prelude/jibb) =(origin.expected `[at.u.prelude.state %element]))
8989− ?. &(result-ok expected-ok) |
8990− ?: |((itype-has-any-atom result sub.state.p.head) (itype-has-any-atom expected sub.state.p.head)) |
8991− &
8992− ?. eligible (infer-call-with-head e env state head)
8205+ ?. ?=(%var -.result) (infer-call-with-head e env state head)
89938206 ?: |(?=(%var -.expected) ?=(%avar -.expected) ?=(%rvar -.expected) |(?=(%nvar -.expected) ?=(%rnvar -.expected)) (itype-has-tag (itype-normalize expected sub.state.p.head)))
89948207 (infer-call-with-head e env state head)
89958208 =/ sub=(unit isub) (itype-unify result expected sub.state.p.head)
@@ -9077,199 +8290,9 @@
90778290 =/ st=istate state.p.value(sub sub.u.project, next next.u.project)
90788291 [%& expected st(projections [[at.e e typ.p.value expected steps.u.project] projections.st])]
90798292::
9080−:: A known literal singleton in a direct union can contextualize a
9081−:: loobean literal of the same noun. Only explicit singleton and cell
9082−:: competitors are considered; opaque or variable cases stay unknown.
9083−++ explicit-singleton-in-union
9084− |= [t=itype noun=@]
9085− ^- ?
9086− ?. ?=(%union -.t) |
9087− =/ cases=(list itype) cases.t
9088− =/ found=? |
9089− |-
9090− ?~ cases found
9091− =/ c=itype i.cases
9092− ?: ?=(%cell -.c) $(cases t.cases)
9093− ?. ?=(%const -.c) |
9094− ?: =(noun val.literal.c)
9095− ?: found |
9096− $(cases t.cases, found &)
9097− $(cases t.cases)
9098−::
9099−:: Select a written literal-headed case only when every competing case is
9100−:: also an explicit singleton-headed cell and exactly one matches. Opaque,
9101−:: variable-bound and differently shaped cases keep inference unchanged.
9102−:: This first slice supplies context to a directly called payload. Plain
9103−:: literal data and other expressions retain their existing inference path.
9104−++ contextual-atomic-arguments
9105− |= args=(list expr)
9106− ^- ?
9107− ?~ args &
9108− ?. ?=(?(%lit %wing %ctor) -.i.args) |
9109− $(args t.args)
9110−++ contextual-direct-payload-call
9111− |= e=expr
9112− ^- ?
9113− ?: ?=(%group -.e) $(e inner.e)
9114− ?. ?=(%call -.e) |
9115− ?. ?=(%wing -.head.e) |
9116− ?~ args.e |
9117− (contextual-atomic-arguments args.e)
9118−::
9119−:: A walked variable may have concealed a union inside a substituted
9120−:: structure before this arm was called. Decline in that case rather than
9121−:: deriving provenance from the already-walked type.
9122−++ contextual-simple-sub
9123− |= sub=isub
9124− ^- ?
9125− ?~ sub &
9126− ?: ?=(?(%cell %face %fn %union %collection) -.val.i.sub) |
9127− $(sub t.sub)
9128−::
9129−:: Check the syntactic root before scanning; scan substitutions once.
9130−++ grec-direct-context
9131− |= [expected=itype sub=isub]
9132− ^- ?
9133− =/ left=@ud 4.096
9134− |-
9135− ?: ?=(%face -.expected)
9136− ?: =(0 left) |
9137− $(expected body.expected, left (dec left))
9138− ?. ?=(%grec -.expected) |
9139− ?~ sub &
9140− ?: =(0 left) |
9141− ?: ?=(?(%cell %face %fn %union %collection %grec) -.val.i.sub) |
9142− $(sub t.sub, left (dec left))
9143−++ contextual-direct-union
9144− |= target=itype
9145− ^- ?
9146− ?: ?=(%face -.target) $(target body.target)
9147− ?=(%union -.target)
9148−++ contextual-tagged-case
9149− |= [target=itype tag=@ sub=isub]
9150− ^- (unit itype)
9151− ?. ?=(%union -.target) ~
9152− =/ remaining=(list itype) cases.target
9153− =/ found=(unit itype) ~
9154− =/ seen=(set @) *(set @)
9155− |-
9156− ?~ remaining found
9157− =/ c=itype i.remaining
9158− ?. ?=(%cell -.c) ~
9159− =/ head=itype hed.c
9160− ?. ?=(%const -.head) ~
9161− ?: (~(has in:..zuse seen) val.literal.head) ~
9162− =. seen (~(put in:..zuse seen) val.literal.head)
9163− ?: =(tag val.literal.head)
9164− $(remaining t.remaining, found `c)
9165− $(remaining t.remaining)
9166−::
9167−:: A bounded syntactic screen: no nested branch, cast, gate or local body
9168−:: can re-enter cell-branch retry during either inference attempt.
9169−++ closed-cell-retry-safe
9170− |= [todo=(list expr) fuel=@ud]
9171− ^- ?
9172− ?~ todo &
9173− ?: =(0 fuel) |
9174− =/ e=expr i.todo
9175− =. fuel (dec fuel)
9176− ?+ -.e |
9177− %lit $(todo t.todo)
9178− %wing $(todo t.todo)
9179− %ctor $(todo t.todo)
9180− %path $(todo t.todo)
9181− %crash $(todo t.todo)
9182− %str
9183− ?. (levy pieces.e |=(p=piece ?=(%text -.p))) |
9184− $(todo t.todo)
9185− %group $(todo [inner.e t.todo])
9186− %pair $(todo [val.e t.todo])
9187− %unit $(todo [val.e t.todo])
9188− %list $(todo (weld items.e t.todo))
9189− %tuple $(todo (weld (turn items.e |=(i=item val.i)) t.todo))
9190− %change $(todo (weld (turn edits.e |=(ed=edit val.ed)) t.todo))
9191− %call $(todo [head.e (weld args.e t.todo)])
9192− %trace $(todo [val.e then.e t.todo])
9193− ==
9194−::
9195−++ closed-cell-sub-safe
9196− |= [sub=isub fuel=@ud]
9197− ^- ?
9198− ?~ sub &
9199− ?: =(0 fuel) |
9200− ?: ?=(?(%cell %face %fn %union %collection %grec %jrec %recursive) -.val.i.sub) |
9201− $(sub t.sub, fuel (dec fuel))
9202−::
9203−++ closed-cell-branch-eligible
9204− |= [e=expr expected=itype sub=isub]
9205− ^- ?
9206− ?. &(?=(%branch -.e) ?=(%cell -.expected) (closed-cell-sub-safe sub 512)) |
9207− ?~ arms.e |
9208− ?~ t.arms.e |
9209− ?^ t.t.arms.e |
9210− =/ x=arm i.arms.e
9211− =/ y=arm i.t.arms.e
9212− ?. &(?=(%lit -.pat.x) ?=(%lit -.pat.y)) |
9213− ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y)) |
9214− ?: =(val.lit.pat.x val.lit.pat.y) |
9215− (closed-cell-retry-safe ~[subject.e val.x val.y] 512)
9216−::
9217−:: Attempt ordinary inference first; retry from the same state only for
9218−:: the bounded non-reentrant syntax above. Preserve original value faces.
9219−++ infer-closed-cell-branch
9220− |= [e=expr expected=itype env=ienv state=istate context=span]
9221− ^- iresult
9222− ?> (closed-cell-branch-eligible e expected sub.state)
9223− ?> ?=(%branch -.e)
9224− ?> ?=(^ arms.e)
9225− ?> ?=(^ t.arms.e)
9226− =/ ordinary=iresult (infer-fragment e env state)
9227− =/ ordinary-good=?
9228− ?: ?=(%| -.ordinary) |
9229− =/ fit=ifit (itype-fit typ.p.ordinary expected sub.state.p.ordinary next.state.p.ordinary)
9230− ?=(%ok -.fit)
9231− ?: ordinary-good ordinary
9232− =/ attempt=(unit iresult)
9233− =/ x=arm i.arms.e
9234− =/ y=arm i.t.arms.e
9235− =/ subject=iresult (infer-fragment subject.e env state)
9236− ?: ?=(%| -.subject) ~
9237− =/ subject-type=itype (itype-normalize typ.p.subject sub.state.p.subject)
9238− ?: ?=(%union -.subject-type) ~
9239− =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
9240− ?~ su ~
9241− =/ left=iresult (infer-call-context-arg val.x expected env state.p.subject(sub u.su) context)
9242− ?: ?=(%| -.left) ~
9243− =/ lf=ifit (itype-fit typ.p.left expected sub.state.p.left next.state.p.left)
9244− ?. ?=(%ok -.lf) ~
9245− =/ right=iresult (infer-call-context-arg val.y expected env state.p.left(sub sub.lf, next next.lf) context)
9246− ?: ?=(%| -.right) ~
9247− =/ rf=ifit (itype-fit typ.p.right expected sub.state.p.right next.state.p.right)
9248− ?. ?=(%ok -.rf) ~
9249− =/ sub=isub sub.rf
9250− =/ next=@ud next.rf
9251− =/ lt=itype (itype-normalize typ.p.left sub)
9252− =/ rt=itype (itype-normalize typ.p.right sub)
9253− =/ et=itype (itype-normalize expected sub)
9254− ?. =(lt rt) ~
9255− ?: |(?=(^ (itype-vars lt)) ?=(^ (itype-vars rt)) ?=(^ (itype-vars et))) ~
9256− ?: |((itype-has-tag lt) (itype-has-tag rt) (itype-has-tag et)) ~
9257− =/ lcheck=ifit (itype-fit typ.p.left expected sub next)
9258− ?. ?=(%ok -.lcheck) ~
9259− ?. &(=(sub.lcheck sub) =(next.lcheck next)) ~
9260− =/ rcheck=ifit (itype-fit typ.p.right expected sub next)
9261− ?. ?=(%ok -.rcheck) ~
9262− ?. &(=(sub.rcheck sub) =(next.rcheck next)) ~
9263− `[%& typ.p.left state.p.right(sub sub, next next)]
9264− ?~ attempt ordinary
9265− u.attempt
9266−::
92678293++ infer-call-context-arg
92688294 |= [e=expr expected=itype env=ienv state=istate context=span]
92698295 ^- iresult
9270− ?: &(?=(^ defer.state) ?=(%branch -.e)) (infer-fragment e env state)
9271− ?: &(?=(^ defer.state) ?=(^ prelude.state) ?=(%tuple -.e))
9272− (infer-fragment e env state)
92738296 ?: ?=(%pair -.e) $(e (pair-as-cell e))
92748297 ?: ?=(%group -.e) $(e inner.e)
92758298 ?: &(?=(%body -.e) ?=(~ defs.e)) $(e final.e)
@@ -9282,23 +8305,6 @@
92828305 ?: ?=(%face -.target) $(target (itype-walk body.target sub.state))
92838306 ?: (explicit-proj-call e env state)
92848307 (infer-proj-context e expected env state context)
9285− :: Experimental construction only for a source-proven direct target.
9286− :: Decline any walked structural binding to retain raw-variable provenance.
9287− ?: &(?=(%grec -.target) ?=(%tuple -.e) (grec-direct-context expected sub.state))
9288− =/ unfolded=(unit [view=itype left=@ud]) (grec-unfold-view target jrec-fuel.state)
9289− ?~ unfolded [%| ["recursive mold unfolding needs unsupported inference" ~]]
9290− ?~ items.e [%| ["recursive mold constructor needs unsupported inference" ~]]
9291− =/ first=item i.items.e
9292− ?. &(?=(~ face.first) ?=(%lit -.val.first) =(%term form.lit.val.first))
9293− [%| ["recursive mold constructor needs unsupported inference" ~]]
9294− =/ chosen=(unit itype) (contextual-tagged-case view.u.unfolded val.lit.val.first sub.state)
9295− ?~ chosen [%| ["recursive mold constructor has no matching case" ~]]
9296− =/ value=iresult (infer-call-context-items items.e u.chosen env state(jrec-fuel left.u.unfolded) context)
9297− ?: ?=(%| -.value) value
9298− =/ fit=ifit (itype-fit typ.p.value u.chosen sub.state.p.value next.state.p.value)
9299− ?: ?=(%unknown -.fit) [%| ["recursive mold case needs unsupported inference" ~]]
9300− ?: ?=(%bad -.fit) [%| ["recursive mold case does not fit its source shape" ~]]
9301− [%& target state.p.value(sub sub.fit, next next.fit)]
93028308 :: Only the source-proven one-layer cell is exposed. Each recursive
93038309 :: descent consumes one written tuple; named values use ordinary fit.
93048310 ?: &(?=(%jrec -.target) ?=(%lit -.e) =(%null form.lit.e))
@@ -9316,23 +8322,17 @@
93168322 ?: ?=(%bad -.fit) [%| ["recursive mold cell does not fit its source shape" ~]]
93178323 [%& target state.p.value(sub sub.fit, next next.fit)]
93188324 ?: ?=(%call -.e) (infer-contextual-call e target env state)
9319− =/ empty-list=(unit iresult) (empty-list-null-branch e env state `[target context])
9320− ?^ empty-list u.empty-list
93218325 ?: (single-structured-pattern e)
9322− ?> ?=(%branch -.e)
9323− =/ empty-union=(unit iresult) (known-empty-union-wing subject.e env state)
9324− ?^ empty-union (infer-known-union-context-subject e target env u.empty-union context)
9325− =/ single=(unit iresult) (grec-single-wing-subject subject.e env state)
9326− ?^ single (infer-known-union-context-subject e target env u.single context)
93278326 (infer-single-case-branch e env state `[target context])
93288327 ?: (cell-binder-pattern e)
93298328 (infer-cell-branch e env state `[target context])
9330− :: In an explicit singleton context retain the written loobean noun;
9331− :: the ordinary singleton fit compares its noun, not its spelling.
8329+ :: In a loobean-singleton context retain the written loobean noun;
8330+ :: the usual final fit decides whether that value is permitted.
93328331 =/ singleton=(unit itype)
93338332 ?. ?=(%lit -.e) ~
93348333 ?. =(%loobean form.lit.e) ~
9335− ?. |(?=(%const -.target) &(?=(%union -.expected) (explicit-singleton-in-union expected val.lit.e))) ~
8334+ ?. ?=(%const -.target) ~
8335+ ?. =(%loobean form.literal.target) ~
93368336 `[%const lit.e]
93378337 ?^ singleton [%& u.singleton state]
93388338 =/ known=(unit iresult)
@@ -9343,8 +8343,6 @@
93438343 (infer-known-union-context-subject e target env u.known context)
93448344 ?: &(?=(%union -.target) ?=(%unit -.e))
93458345 (infer-unit-context e target env state context)
9346− ?: (closed-cell-branch-eligible e expected sub.state)
9347− (infer-closed-cell-branch e expected env state context)
93488346 ?: &(?=(%flag -.target) (context-union-branch e))
93498347 (infer-union-context e target env state context)
93508348 ?: &(?=(%union -.target) (context-union-branch e))
@@ -9353,34 +8351,6 @@
93538351 (infer-union-context e target env state context)
93548352 ?: &(?=(%collection -.target) =(%list name.target) (context-list-expression e))
93558353 (infer-list-context e target env state context)
9356− :: A literal-headed tuple can receive the unique case's payload
9357− :: context. The ordinary final fit still checks the complete union.
9358− =/ selected=(unit itype)
9359− ?. &((contextual-simple-sub sub.state) (contextual-direct-union expected) ?=(%union -.target) ?=(%tuple -.e) ?=(^ items.e)) ~
9360− ?~ t.items.e ~
9361− ?^ t.t.items.e ~
9362− ?. (contextual-direct-payload-call val.i.t.items.e) ~
9363− =/ first=item i.items.e
9364− ?. &(?=(~ face.first) ?=(%lit -.val.first) |(=(%term form.lit.val.first) =(%null form.lit.val.first) =(%loobean form.lit.val.first))) ~
9365− (contextual-tagged-case target val.lit.val.first sub.state)
9366− ?^ selected
9367− ?> ?=(%tuple -.e)
9368− :: On this bounded shallow-call shape, preserve any inference that
9369− :: already fits before trying the new contextual path. Neither pass
9370− :: can recursively select a nested tuple from the atomic arguments.
9371− =/ ordinary=(unit iresult)
9372− =/ initial=iresult (infer-fragment e env state)
9373− ?: ?=(%| -.initial) ~
9374− =/ fit=ifit (itype-fit typ.p.initial target sub.state.p.initial next.state.p.initial)
9375− ?. ?=(%ok -.fit) ~
9376− `initial
9377− ?^ ordinary u.ordinary
9378− =/ value=iresult (infer-call-context-items items.e u.selected env state context)
9379− ?: ?=(%| -.value) value
9380− =/ fit=ifit (itype-fit typ.p.value u.selected sub.state.p.value next.state.p.value)
9381− ?: ?=(%unknown -.fit) [%| ["tagged case needs unsupported inference" ~]]
9382− ?: ?=(%bad -.fit) [%| ["tagged case does not fit its expected type" ~[[context "expected union case"] [(span-of e) "value"]]]]
9383− [%& typ.p.value state.p.value(sub sub.fit, next next.fit)]
93848354 ?: &(?=(%cell -.target) ?=(%tuple -.e))
93858355 (infer-call-context-items items.e target env state context)
93868356 (infer-fragment e env state)
@@ -9483,7 +8453,7 @@
94838453 ?~ t.names |
94848454 =. typ (itype-walk typ sub)
94858455 ?: ?=(%cell -.typ) $(typ tal.typ, names t.names)
9486− |(?=(%union -.typ) ?=(%collection -.typ) ?=(%recursive -.typ) ?=(%jrec -.typ) ?=(%grec -.typ) ?=(%noun -.typ) ?=(%fn -.typ) ?=(%tag -.typ))
8456+ |(?=(%union -.typ) ?=(%collection -.typ) ?=(%recursive -.typ) ?=(%jrec -.typ) ?=(%noun -.typ) ?=(%fn -.typ) ?=(%tag -.typ))
94878457::
94888458++ cell-binder-pattern
94898459 |= e=expr
@@ -9554,7 +8524,6 @@
95548524 %any-atom "@"
95558525 %flag "?"
95568526 %noun "*"
9557− %empty "!!"
95588527 %tag (trip txt.literal.t)
95598528 %const (trip txt.literal.t)
95608529 %union
@@ -9563,7 +8532,6 @@
95638532 "({(trip u.label.t)} {(show-itype-cases args.t sub)})"
95648533 %recursive ?~(label.t "recursive mold" (trip u.label.t))
95658534 %jrec ?~(label.t "recursive mold" (trip u.label.t))
9566− %grec ?~(label.t "recursive mold" "({(trip u.label.t)} {(show-itype-cases args.t sub)})")
95678535 %collection "({(trip name.t)} {(show-itype-cases args.t sub)})"
95688536 %face "[{(trip name.t)}={(show-itype-context body.t sub)}]"
95698537 %fn "$-({(show-itype-context sample.t sub)} {(show-itype-context product.t sub)})"
@@ -9607,13 +8575,11 @@
96078575 %any-atom |
96088576 %flag |
96098577 %noun |
9610− %empty |
96118578 %tag |
96128579 %const |
96138580 %union |((lien cases.typ |=(c=itype (itype-has-nvar c))) (lien args.typ |=(c=itype (itype-has-nvar c))))
96148581 %recursive |
96158582 %jrec |
9616− %grec (lien args.typ |=(c=itype (itype-has-nvar c)))
96178583 %collection (lien args.typ |=(c=itype (itype-has-nvar c)))
96188584 %face $(typ body.typ)
96198585 %fn |($(typ sample.typ) $(typ product.typ))
@@ -9725,13 +8691,11 @@
97258691 %any-atom |
97268692 %flag |
97278693 %noun |
9728− %empty |
97298694 %tag |
97308695 %const |
97318696 %union |((lien cases.t |=(c=itype (has-atom-var n c))) (lien args.t |=(c=itype (has-atom-var n c))))
97328697 %recursive |
97338698 %jrec |
9734− %grec (lien args.t |=(c=itype (has-atom-var n c)))
97358699 %collection (lien args.t |=(c=itype (has-atom-var n c)))
97368700 %face $(t body.t)
97378701 %fn |($(t sample.t) $(t product.t))
@@ -9875,8 +8839,6 @@
98758839++ infer-recursive-gate
98768840 |= [d=def env=ienv state=istate]
98778841 ^- iresult
9878− ?^ defer.state [%| ["deferred recursive inference is unsupported" ~]]
9879− =. gate-defs.state ~
98808842 ?. ?=(%value -.d) [%| ["recursive definition is not a gate" ~]]
98818843 ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
98828844 [%| ["recursive definition is not a gate" ~]]
@@ -10100,13 +9062,12 @@
101009062++ infer-gate-group
101019063 |= [ds=(list def) env=ienv state=istate]
101029064 ^- ilocal-result
10103− ?^ defer.state [%| ["deferred recursive inference is unsupported" ~]]
101049065 =/ names=(list term) (global-value-names ds)
101059066 ?. (levy names |=(n=term (unique-value-name n names)))
101069067 [%| ["recursive group contains duplicate names" ~]]
101079068 ?: (lien names |=(n=term ?=(^ (ienv-lookup n env))))
101089069 [%| ["recursive group shadows a name" ~]]
10109− =/ scoped=istate state(globals (weld names globals.state), gate-defs ~)
9070+ =/ scoped=istate state(globals (weld names globals.state))
101109071 =/ seeded=igate-seeds (seed-gate-group ds env scoped)
101119072 ?: ?=(%| -.seeded) seeded
101129073 =/ seeds=ienv (group-seed-env entries.p.seeded ~)
@@ -10140,11 +9101,35 @@
101409101 `[entry u.rest]
101419102::
101429103++ add-supported-defs
10143− |= [ds=(list def) all-defs=(list def) checked=(map term def) heads=(unit igate-prelude-evidence) env=ienv molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile) artifacts=(list iwidth-definition)]
9104+ |= [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)]
101449105 ^- [env=ienv artifacts=(list iwidth-definition)]
10145− (add-supported-defs-core ds all-defs checked heads env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts ~)
9106+ ?~ ds [env artifacts]
9107+ =/ d=def i.ds
9108+ ?: ?=(%mold -.d) $(ds t.ds)
9109+ ?. (unique-value-name name.d globals) $(ds t.ds)
9110+ ?^ (ienv-lookup name.d env) $(ds t.ds)
9111+ =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9112+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~]
9113+ =. initial (reserve-def-caps val.d initial)
9114+ =/ result=iresult (infer-fragment val.d env initial)
9115+ =? result ?=(%| -.result) (infer-recursive-gate d env initial)
9116+ ?: ?=(%| -.result) $(ds t.ds)
9117+ =. state.p.result (promote-restricted-numbers state.p.result env)
9118+ =. 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)))
9119+ ?^ (unresolved-hole holes.state.p.result holes.initial state.p.result) $(ds t.ds)
9120+ ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
9121+ =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
9122+ ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
9123+ ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
9124+ =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
9125+ ?: (gth (lent vars) 26) $(ds t.ds)
9126+ =/ finalized=(unit (list iwprojection))
9127+ (width-finalize projections.state.p.result sub.state.p.result vars)
9128+ ?~ finalized $(ds t.ds)
9129+ =? artifacts ?=(^ u.finalized)
9130+ [[name.d val.d typ sub.state.p.result (flop u.finalized)] artifacts]
9131+ $(ds t.ds, env [[name.d [typ vars]] env])
101469132::
10147−
101489133+$ iresolved [env=ienv grouped=(list term) artifacts=(list iwidth-definition)]
101499134+$ iadj (map term (list term))
101509135+$ ivisited (map term ?)
@@ -10258,57 +9243,6 @@
102589243++ resolve-groups
102599244 |= [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)]
102609245 ^- iresolved
10261− (resolve-groups-core ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude ~)
10262−::
10263−
10264−+$ iadded-definition
10265− [env=ienv checked=(map term def) artifacts=(list iwidth-definition)]
10266−++ add-supported-result
10267− |= [d=def result=iresult initial=istate env=ienv checked=(map term def) artifacts=(list iwidth-definition)]
10268− ^- (unit iadded-definition)
10269− ?> ?=(%value -.d)
10270− ?: ?=(%| -.result) ~
10271− =. state.p.result (promote-restricted-numbers state.p.result env)
10272− =. 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)))
10273− ?^ (unresolved-hole holes.state.p.result holes.initial state.p.result) ~
10274− ?: (constrained-capitals caps.state.p.result sub.state.p.result) ~
10275− =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
10276− ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) ~
10277− ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) ~
10278− =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
10279− ?: (gth (lent vars) 26) ~
10280− =/ finalized=(unit (list iwprojection))
10281− (width-finalize projections.state.p.result sub.state.p.result vars)
10282− ?~ finalized ~
10283− =? artifacts ?=(^ u.finalized)
10284− [[name.d val.d typ sub.state.p.result (flop u.finalized)] artifacts]
10285− =? checked |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) (~(put by checked) name.d d)
10286− `[[[name.d [typ vars]] env] checked artifacts]
10287−++ add-supported-defs-core
10288− |= [ds=(list def) all-defs=(list def) checked=(map term def) heads=(unit igate-prelude-evidence) env=ienv molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile) artifacts=(list iwidth-definition) index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])]
10289− ^- [env=ienv artifacts=(list iwidth-definition)]
10290− ?~ ds [env artifacts]
10291− =/ d=def i.ds
10292− ?: ?=(%mold -.d) $(ds t.ds)
10293− ?: (lien (program-recovery-names all-defs) |=(n=term =(n name.d))) $(ds t.ds)
10294− ?. (unique-value-name name.d globals) $(ds t.ds)
10295− ?^ (ienv-lookup name.d env) $(ds t.ds)
10296− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10297− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~ ~ ~]
10298− =. grec-index.initial index
10299− =. gate-defs.initial checked
10300− =. head-evidence.initial heads
10301− =. initial (reserve-def-caps val.d initial)
10302− =/ result=iresult (infer-fragment val.d env initial)
10303− =? result ?=(%| -.result) (infer-recursive-gate d env initial)
10304− =/ added=(unit iadded-definition)
10305− (add-supported-result d result initial env checked artifacts)
10306− ?~ added $(ds t.ds)
10307− $(ds t.ds, env env.u.added, checked checked.u.added, artifacts artifacts.u.added)
10308−::
10309−++ resolve-groups-core
10310− |= [ds=(list def) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) at=path prelude=(unit ifile) index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])]
10311− ^- iresolved
103129246 =/ env=ienv ~
103139247 =/ grouped=(list term) ~
103149248 =/ artifacts=(list iwidth-definition) ~
@@ -10317,12 +9251,10 @@
103179251 =/ graph=iadj (graph-make-forward ds nameset ~)
103189252 =/ components=icomponents (graph-components ds names)
103199253 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10320− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude)
103219254 |-
103229255 =/ next=[env=ienv artifacts=(list iwidth-definition)]
10323− (add-supported-defs-core ds ds (direct-checked-gates ds env) heads env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts index)
10324− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~ ~ ~]
10325− =. grec-index.initial index
9256+ (add-supported-defs ds env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts)
9257+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~]
103269258 =/ out=iresolved (add-groups ds components graph env.next grouped artifacts.next initial)
103279259 ?: =(env env.out) out
103289260 $(env env.out, grouped grouped.out, artifacts artifacts.out)
@@ -10571,288 +9503,37 @@
105719503 %overlap
105729504 %unknown
105739505::
10574−:: A source-only fallback for literal-tagged cells and one-hop local
10575−:: generic applications. It screens all work before ordinary inference.
10576−++ union-simple-shape-budget
10577− |= [s=shape fuel=@ud vars=(unit (list @t))]
10578− ^- (unit @ud)
10579− ?: =(0 fuel) ~
10580− =. fuel (dec fuel)
10581− ?- -.s
10582− ?(%aura %noun %void %flag) `fuel
10583− %tvar
10584− ?~ vars `fuel
10585− ?:((lien u.vars |=(n=@t =(n name.s))) `fuel ~)
10586− %const
10587− ?. |(=(%term form.lit.s) =(%null form.lit.s) =(%loobean form.lit.s)) ~
10588− ?: &(=(%loobean form.lit.s) !|(=(0 val.lit.s) =(1 val.lit.s))) ~
10589− `fuel
10590− %cell (union-simple-fields-budget fields.s fuel vars)
10591− %fn
10592− =/ left=(unit @ud) $(s sample.s, fuel fuel)
10593− ?~ left ~
10594− $(s product.s, fuel u.left)
10595− * ~
10596− ==
10597−++ union-simple-fields-budget
10598− |= [fields=(list field) fuel=@ud vars=(unit (list @t))]
10599− ^- (unit @ud)
10600− ?~ fields `fuel
10601− ?: =(0 fuel) ~
10602− =/ field-shape=shape
10603− ?- -.i.fields
10604− %bare shape.i.fields
10605− %face shape.i.fields
10606− %pun [%ref at.i.fields ~[name.i.fields]]
10607− ==
10608− =/ head=(unit @ud) (union-simple-shape-budget field-shape (dec fuel) vars)
10609− ?~ head ~
10610− $(fields t.fields, fuel u.head)
10611−++ union-source-find
10612− |= [n=term molds=imolds fuel=@ud]
10613− ^- (unit [body=shape left=@ud])
10614− =/ found=(unit shape) ~
10615− |-
10616− ?~ molds
10617− ?~ found ~
10618− `[u.found fuel]
10619− ?: =(0 fuel) ~
10620− ?: =(n name.i.molds)
10621− ?^ found ~
10622− $(molds t.molds, fuel (dec fuel), found `body.i.molds)
10623− $(molds t.molds, fuel (dec fuel))
10624−++ union-source-args-budget
10625− |= [vars=(list @t) args=(list shape) fuel=@ud]
10626− ^- (unit @ud)
10627− =/ seen=(set @t) *(set @t)
10628− |-
10629− ?~ vars ?~(args `fuel ~)
10630− ?~ args ~
10631− ?: =(0 fuel) ~
10632− ?: (~(has in:..zuse seen) i.vars) ~
10633− =/ arg=(unit @ud) (union-simple-shape-budget i.args (dec fuel) ~)
10634− ?~ arg ~
10635− $(vars t.vars, args t.args, fuel u.arg, seen (~(put in:..zuse seen) i.vars))
10636−++ union-source-cell-tag
10637− |= s=shape
10638− ^- (unit @)
10639− ?. ?=(%cell -.s) ~
10640− ?~ fields.s ~
10641− ?~ t.fields.s ~
10642− ?. ?=(%bare -.i.fields.s) ~
10643− =/ head=shape shape.i.fields.s
10644− ?. ?=(%const -.head) ~
10645− ?. |(=(%term form.lit.head) =(%null form.lit.head) =(%loobean form.lit.head)) ~
10646− ?: &(=(%loobean form.lit.head) !|(=(0 val.lit.head) =(1 val.lit.head))) ~
10647− `val.lit.head
10648−++ union-source-case-tag
10649− |= [s=shape molds=imolds fuel=@ud]
10650− ^- (unit [tag=@ left=@ud])
10651− ?: ?=(%cell -.s)
10652− =/ tag=(unit @) (union-source-cell-tag s)
10653− ?~ tag ~
10654− =/ left=(unit @ud) (union-simple-shape-budget s fuel ~)
10655− ?~ left ~
10656− `[u.tag u.left]
10657− ?. ?=(%apply -.s) ~
10658− ?. ?=([@ ~] ref.s) ~
10659− ?: =(0 fuel) ~
10660− =/ found=(unit [body=shape left=@ud]) (union-source-find i.ref.s molds (dec fuel))
10661− ?~ found ~
10662− ?. ?=(%generic -.body.u.found) ~
10663− ?~ vars.body.u.found ~
10664− =/ tag=(unit @) (union-source-cell-tag body.body.u.found)
10665− ?~ tag ~
10666− =/ args=(unit @ud) (union-source-args-budget vars.body.u.found args.s left.u.found)
10667− ?~ args ~
10668− =/ left=(unit @ud) (union-simple-shape-budget body.body.u.found u.args `vars.body.u.found)
10669− ?~ left ~
10670− `[u.tag u.left]
10671−++ union-source-distinct-tags
10672− |= [cases=(list shape) molds=imolds fuel=@ud]
10673− ^- ?
10674− =/ seen=(set @) *(set @)
10675− =/ has-application=? |
10676− |-
10677− ?~ cases has-application
10678− ?: =(0 fuel) |
10679− =/ item=(unit [tag=@ left=@ud]) (union-source-case-tag i.cases molds (dec fuel))
10680− ?~ item |
10681− ?: (~(has in:..zuse seen) tag.u.item) |
10682− $(cases t.cases, fuel left.u.item, seen (~(put in:..zuse seen) tag.u.item), has-application |(has-application ?=(%apply -.i.cases)))
10683−::
10684−:: This inference-only screen bounds inherited work that the small source
10685−:: slice may consult. It does not authenticate a caller-created state.
10686−++ union-state-leaf
10687− |= t=itype
10688− ^- ?
10689− ?=(?(%var %avar %rvar %nvar %rnvar %atom %any-atom %flag %noun %empty %const) -.t)
10690−++ union-state-params-budget
10691− |= [params=iparams fuel=@ud]
10692− ^- (unit @ud)
10693− ?~ params `fuel
10694− ?: =(0 fuel) ~
10695− ?. (union-state-leaf typ.i.params) ~
10696− $(params t.params, fuel (dec fuel))
10697−++ union-state-sub-budget
10698− |= [sub=isub fuel=@ud]
10699− ^- (unit @ud)
10700− ?~ sub `fuel
10701− ?: =(0 fuel) ~
10702− ?. (union-state-leaf val.i.sub) ~
10703− $(sub t.sub, fuel (dec fuel))
10704−++ union-state-caps-budget
10705− |= [caps=icaps fuel=@ud]
10706− ^- (unit @ud)
10707− ?~ caps `fuel
10708− ?: =(0 fuel) ~
10709− $(caps t.caps, fuel (dec fuel))
10710−++ union-state-active-budget
10711− |= [active=(list term) fuel=@ud]
10712− ^- (unit @ud)
10713− ?~ active `fuel
10714− ?: =(0 fuel) ~
10715− $(active t.active, fuel (dec fuel))
10716−++ union-state-tags-budget
10717− |= [tags=(list ipending) fuel=@ud]
10718− ^- (unit @ud)
10719− ?~ tags `fuel
10720− ?: =(0 fuel) ~
10721− $(tags t.tags, fuel (dec fuel))
10722−++ union-source-state-safe
10723− |= [state=istate fuel=@ud]
10724− ^- ?
10725− ?^ grec-index.state |
10726− ?^ holes.state |
10727− ?^ defer.state |
10728− ?^ obligations.state |
10729− =/ params=(unit @ud) (union-state-params-budget params.state fuel)
10730− ?~ params |
10731− =/ sub=(unit @ud) (union-state-sub-budget sub.state u.params)
10732− ?~ sub |
10733− =/ caps=(unit @ud) (union-state-caps-budget caps.state u.sub)
10734− ?~ caps |
10735− =/ active=(unit @ud) (union-state-active-budget active.state u.caps)
10736− ?~ active |
10737− ?=(^ (union-state-tags-budget tags.state u.active))
10738−::
10739−:: Positive overlap witnesses from parsed, one-hop local source only.
10740−:: Unknown or exhausted work returns no witness, never disjointness.
10741−+$ uow-case [at=span head=@ payload=upat]
10742−++ union-overlap-primitive
10743− |= s=shape
10744− ^- (unit upat)
10745− ?- -.s
10746− %aura `[%atom ~]
10747− %noun `[%all ~]
10748− %void `[%empty ~]
10749− %flag `[%flag ~]
10750− %const
10751− ?. |(=(%term form.lit.s) =(%null form.lit.s) =(%loobean form.lit.s)) ~
10752− ?: &(=(%loobean form.lit.s) !|(=(0 val.lit.s) =(1 val.lit.s))) ~
10753− `[%atom `val.lit.s]
10754− * ~
10755− ==
10756−++ union-overlap-case
10757− |= [s=shape molds=imolds fuel=@ud]
10758− ^- (unit [item=uow-case left=@ud])
10759− ?: =(0 fuel) ~
10760− =. fuel (dec fuel)
10761− :: Each body has exactly two fields; an application has exactly one
10762− :: parameter and one concrete primitive argument. The full mold table
10763− :: is scanned to establish unique ownership.
10764− =/ expanded=(unit [body=shape param=(unit [name=@t pat=upat]) left=@ud])
10765− ?: ?=(%cell -.s) `[s ~ fuel]
10766− ?. ?=(%apply -.s) ~
10767− ?. ?=([@ ~] ref.s) ~
10768− ?. ?=([* ~] args.s) ~
10769− ?: =(0 fuel) ~
10770− =/ found=(unit [body=shape left=@ud]) (union-source-find i.ref.s molds (dec fuel))
10771− ?~ found ~
10772− ?. ?=(%generic -.body.u.found) ~
10773− ?. ?=([@ ~] vars.body.u.found) ~
10774− ?: =(0 left.u.found) ~
10775− =/ argument=(unit upat) (union-overlap-primitive i.args.s)
10776− ?~ argument ~
10777− `[body.body.u.found `[i.vars.body.u.found u.argument] (dec left.u.found)]
10778− ?~ expanded ~
10779− =/ body=shape body.u.expanded
10780− ?. ?=(%cell -.body) ~
10781− ?. ?=([* * ~] fields.body) ~
10782− :: Charge the cell, two fields, and the head and payload nodes.
10783− ?: (lth left.u.expanded 5) ~
10784− =/ head=(unit @) (union-source-cell-tag body)
10785− ?~ head ~
10786− =/ field=field i.t.fields.body
10787− =/ payload=shape
10788− ?- -.field
10789− %bare shape.field
10790− %face shape.field
10791− %pun [%ref at.field ~[name.field]]
10792− ==
10793− =/ pattern=(unit upat)
10794− ?: ?=(%tvar -.payload)
10795− ?~ param.u.expanded ~
10796− ?. =(name.payload name.u.param.u.expanded) ~
10797− `pat.u.param.u.expanded
10798− (union-overlap-primitive payload)
10799− ?~ pattern ~
10800− `[[at.s u.head u.pattern] (sub left.u.expanded 5)]
10801−++ union-overlap-against
10802− |= [first=uow-case rest=(list shape) molds=imolds fuel=@ud]
10803− ^- (unit [witness=(unit upair) left=@ud])
10804− ?~ rest `[~ fuel]
10805− ?: =(0 fuel) ~
10806− =/ other=(unit [item=uow-case left=@ud]) (union-overlap-case i.rest molds (dec fuel))
10807− ?~ other ~
10808− ?: &(=(head.first head.item.u.other) =(%overlap (union-relate payload.first payload.item.u.other)))
10809− `[`[at.first at.item.u.other %overlap] left.u.other]
10810− $(rest t.rest, fuel left.u.other)
10811−++ union-source-overlap
10812− |= [cases=(list shape) molds=imolds fuel=@ud]
10813− ^- (unit upair)
10814− ?~ cases ~
10815− ?~ t.cases ~
10816− ?: =(0 fuel) ~
10817− =/ first=(unit [item=uow-case left=@ud]) (union-overlap-case i.cases molds (dec fuel))
10818− ?~ first ~
10819− =/ found=(unit [witness=(unit upair) left=@ud])
10820− (union-overlap-against item.u.first t.cases molds left.u.first)
10821− ?~ found ~
10822− ?^ witness.u.found witness.u.found
10823− $(cases t.cases, fuel left.u.found)
10824−::
10825−++ union-pairs
10826− |= [cases=(list shape) molds=imolds]
10827− ^- (list upair)
10828− ?~ cases ~
10829− =/ first=shape i.cases
10830− =/ a=upat (project-union-mold first molds ~)
10831− =/ pairs=(list upair)
10832− %+ turn t.cases
10833− |= second=shape
10834− ^- upair
10835− [at.first at.second (union-relate a (project-union-mold second molds ~))]
10836− (weld pairs $(cases t.cases))
10837−::
10838−:: A closed structural mold supplies no equation to determine a hole.
10839−:: Applications, references, unbound capitals and unions are unproved.
10840−++ simple-mold-hole
10841− |= sh=shape
10842− ^- (unit (unit span))
10843− ?: ?=(%generic -.sh)
10844− ?~ vars.sh ~
10845− ?. (distinct-params vars.sh) ~
10846− (simple-mold-hole-in body.sh vars.sh)
10847− (simple-mold-hole-in sh ~)
10848−++ simple-mold-hole-in
10849− |= [sh=shape vars=(list @t)]
10850− ^- (unit (unit span))
10851− ?- -.sh
10852− %hole ``at.sh
10853− ?(%aura %noun %void %flag %const) `~
10854− %tvar ?:((lien vars |=(v=@t =(v name.sh))) `~ ~)
10855− %cell (simple-mold-field-holes fields.sh vars)
9506+++ union-pairs
9507+ |= [cases=(list shape) molds=imolds]
9508+ ^- (list upair)
9509+ ?~ cases ~
9510+ =/ first=shape i.cases
9511+ =/ a=upat (project-union-mold first molds ~)
9512+ =/ pairs=(list upair)
9513+ %+ turn t.cases
9514+ |= second=shape
9515+ ^- upair
9516+ [at.first at.second (union-relate a (project-union-mold second molds ~))]
9517+ (weld pairs $(cases t.cases))
9518+::
9519+:: A closed structural mold supplies no equation to determine a hole.
9520+:: Applications, references, unbound capitals and unions are unproved.
9521+++ simple-mold-hole
9522+ |= sh=shape
9523+ ^- (unit (unit span))
9524+ ?: ?=(%generic -.sh)
9525+ ?~ vars.sh ~
9526+ ?. (distinct-params vars.sh) ~
9527+ (simple-mold-hole-in body.sh vars.sh)
9528+ (simple-mold-hole-in sh ~)
9529+++ simple-mold-hole-in
9530+ |= [sh=shape vars=(list @t)]
9531+ ^- (unit (unit span))
9532+ ?- -.sh
9533+ %hole ``at.sh
9534+ ?(%aura %noun %void %flag %const) `~
9535+ %tvar ?:((lien vars |=(v=@t =(v name.sh))) `~ ~)
9536+ %cell (simple-mold-field-holes fields.sh vars)
108569537 %fn
108579538 =/ a=(unit (unit span)) $(sh sample.sh)
108589539 ?~ a ~
@@ -10975,11 +9656,6 @@
109759656 ?. ?=(%union -.sh) (crip "+$ {(trip name.d)}: not checked")
109769657 =/ pairs=(list upair) (union-pairs cases.sh molds)
109779658 =/ overlapping=(list upair) (skim pairs |=(p=upair =(%overlap relation.p)))
10978− =. overlapping
10979− ?^ overlapping overlapping
10980− ?. (lien pairs |=(p=upair =(%unknown relation.p))) ~
10981− =/ witness=(unit upair) (union-source-overlap cases.sh molds 256)
10982− ?~(witness ~ ~[u.witness])
109839659 ?^ overlapping
109849660 =/ p=upair i.overlapping
109859661 =/ summary=@t (crip "+$ {(trip name.d)}: overlapping cases; mold not checked")
@@ -10987,9 +9663,7 @@
109879663 =/ second=@t (show-error src [file line.beg.second.p col.beg.second.p "overlapping case"])
109889664 (of-wain:format ~[summary first second])
109899665 ?: (lien pairs |=(p=upair =(%unknown relation.p)))
10990− ?. (union-source-distinct-tags cases.sh molds 256)
10991− (crip "+$ {(trip name.d)}: case disjointness unresolved; mold not checked")
10992− (crip "+$ {(trip name.d)}: cases proven disjoint; mold not checked")
9666+ (crip "+$ {(trip name.d)}: case disjointness unresolved; mold not checked")
109939667 (crip "+$ {(trip name.d)}: cases proven disjoint; mold not checked")
109949668::
109959669:: +show-inference-diagnostic: a partial report with both source sites
@@ -11046,14 +9720,7 @@
110469720+$ jbundle (list jsource)
110479721+$ jcache (list [at=path iface=ifile])
110489722+$ jfile-result (each [iface=ifile cache=jcache] @t)
11049−:: Overlap evidence retains the exact source that supplied its spans.
11050−:: Ordinary Jibb imports preserve this evidence through the resolver.
11051−+$ jfile-overlap [file=path source=@t name=term cases=upair]
11052−+$ jfile-failure [message=@t overlap=(unit jfile-overlap)]
11053−+$ jfile-detailed-result (each [iface=ifile cache=jcache] jfile-failure)
110549723+$ jimports-result (each [resolved=ijimports cache=jcache] @t)
11055−:: Preserve an imported overlap's original file and source across the graph.
11056−+$ jimports-detailed-result (each [resolved=ijimports cache=jcache] jfile-failure)
110579724::
110589725:: Written record fields each have their own lexical record scope.
110599726+$ written-fields (map term span)
@@ -11326,43 +9993,6 @@
113269993 (skim defs.mod |=(d=def !&(?=(%mold -.d) =(%poke name.d))))
113279994 (module-scope-valid mod(defs remaining) prelude-values prelude-molds)
113289995::
11329−:: A detailed failure is attached only to the first mold that actually
11330−:: failed in this check, using that module's checked source mold table.
11331−+$ imold-failure [message=@t overlap=(unit [name=term cases=upair])]
11332−:: Validate a generic wrapper without an unbounded duplicate-name pass.
11333−++ module-mold-params-valid
11334− |= [vars=(list @t) seen=(set @t) fuel=@ud]
11335− ^- ?
11336− ?~ vars &
11337− ?: =(0 fuel) |
11338− ?: (~(has in:..zuse seen) i.vars) |
11339− $(vars t.vars, seen (~(put in:..zuse seen) i.vars), fuel (dec fuel))
11340−++ module-mold-overlap
11341− |= [m=[name=term body=shape] molds=imolds]
11342− ^- (unit upair)
11343− =/ sh=shape body.m
11344− =/ valid=?
11345− ?. ?=(%generic -.sh) &
11346− ?~ vars.sh |
11347− (module-mold-params-valid vars.sh *(set @t) 256)
11348− ?. valid ~
11349− =? sh ?=(%generic -.sh) body.sh
11350− ?. ?=(%union -.sh) ~
11351− (union-source-overlap cases.sh molds 256)
11352−++ module-mold-types-detail
11353− |= [molds=imolds state=istate]
11354− ^- (each imold-types imold-failure)
11355− ?~ molds [%& ~]
11356− =/ m=[name=term body=shape] i.molds
11357− =/ t=(unit [template=ischeme state=istate])
11358− (infer-mold-template body.m state(active [name.m active.state], in-mold &))
11359− ?~ t
11360− =/ overlap=(unit upair) (module-mold-overlap m molds.state)
11361− [%| ['module mold needs unsupported inference' ?~(overlap ~ `[name.m u.overlap])]]
11362− =. typ.template.u.t (label-direct-union typ.template.u.t body.m name.m state)
11363− =/ rest=(each imold-types imold-failure) $(molds t.molds)
11364− ?: ?=(%| -.rest) rest
11365− [%& [[name.m template.u.t] p.rest]]
113669996++ module-mold-types
113679997 |= [molds=imolds state=istate]
113689998 ^- (each imold-types @t)
@@ -11424,9 +10054,6 @@
1142410054 |= [typ=itype name=term vars=(list @ud)]
1142510055 ^- itype
1142610056 ?: ?=(%jrec -.typ) typ(label `name)
11427− ?: ?=(%grec -.typ)
11428− ?. (identity-union-parameters vars args.typ) typ(label ~)
11429− typ(label `name)
1143010057 ?. ?=(%union -.typ) typ
1143110058 ?. (identity-union-parameters vars args.typ)
1143210059 ?~ origin.typ typ
@@ -11459,12 +10086,7 @@
1145910086 =/ plus=ischeme [[%fn [%cell b b] b] ~[0]]
1146010087 =/ minus=ischeme [[%fn b b] ~[0]]
1146110088 =/ greater=ischeme [[%fn pair [%flag ~]] ~[0]]
11462− =/ utf8=itype [%atom 'tD']
11463− =/ tape=itype [%collection %list ~[utf8]]
11464− =/ codepoints=itype [%collection %list ~[[%atom %c]]]
11465− =/ text-trip=ischeme [[%fn [%atom %t] tape] ~]
11466− =/ text-tuba=ischeme [[%fn tape codepoints] ~]
11467− [~[[%raw-add plus] [%raw-dec minus] [%raw-gth greater] [%raw-trip text-trip] [%raw-tuba text-tuba]] ~ /lib/jibb/primitives/jibb ~ ~ ~ ~ ~]
10089+ [~[[%raw-add plus] [%raw-dec minus] [%raw-gth greater]] ~ /lib/jibb/primitives/jibb ~ ~ ~ ~]
1146810090::
1146910091++ infer-private-internal
1147010092 |= [src=@t public-source=@t]
@@ -11505,9 +10127,9 @@
1150510127 =/ source-unit=(unit ischeme)
1150610128 ?~ unit-decl ~
1150710129 =/ unit-molds=imolds ~[[%unit u.unit-decl]]
11508− =/ unit-state=istate [0 ~ ~ ~ unit-molds ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | /lib/jibb/prelude/jibb ~[%unit] ~ ~ 256 ~ ~ ~ ~ ~ ~]
10130+ =/ unit-state=istate [0 ~ ~ ~ unit-molds ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | /lib/jibb/prelude/jibb ~[%unit] ~ ~ 256 ~]
1150910131 =/ unit-types=imold-types (partial-prelude-molds unit-molds unit-state)
11510− =/ unit-iface=ifile [~ unit-types /lib/jibb/prelude/jibb ~ ~ ~ ~ ~]
10132+ =/ unit-iface=ifile [~ unit-types /lib/jibb/prelude/jibb ~ ~ ~ ~]
1151110133 =/ found=(unit ischeme) (find-jibb-mold %unit unit-iface)
1151210134 ?~ found ~
1151310135 ?. (standard-unit-template u.found /lib/jibb/prelude/jibb) ~
@@ -11520,7 +10142,7 @@
1152010142 =/ js=ijimports ~[[face.i.imports.mod primitive]]
1152110143 =/ reserved=(list term) ~[face.i.imports.mod]
1152210144 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11523− =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ js reserved ~ ~ ~ | at top ~ ~ 256 ~ ~ ~ ~ ~ ~]
10145+ =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ js reserved ~ ~ ~ | at top ~ ~ 256 ~]
1152410146 =/ mts=(each imold-types @t) (module-mold-types molds state)
1152510147 =/ usable=(unit imold-types)
1152610148 ?: ?=(%& -.mts) `p.mts
@@ -11543,7 +10165,7 @@
1154310165 =/ resolution=iresolved (resolve-groups defs.mod molds globals ~ ~ ~ ~ js reserved at ~)
1154410166 =/ env=ienv env.resolution
1154510167 ?. (module-values-complete defs.mod env) ~
11546− `[env u.usable at ~ artifacts.resolution ~ `src ~]
10168+ `[env u.usable at ~ artifacts.resolution ~ `src]
1154710169::
1154810170++ partial-prelude-interface-with-internal
1154910171 |= [src=@t internal-source=(unit @t)]
@@ -11576,16 +10198,16 @@
1157610198 =? env-molds declared
1157710199 (skim molds |=(m=[name=term body=shape] !=(%list name.m)))
1157810200 =/ reserved=(list term) ?:(declared ~[%list] ~)
11579− =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ u.private reserved ~ ~ ~ | at names ~ ~ 256 ~ ~ ~ ~ ~ ~]
10201+ =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ u.private reserved ~ ~ ~ | at names ~ ~ 256 ~]
1158010202 :: Other prelude molds may use list only after its source has passed
1158110203 :: the standard-list check. The raw declaration remains removed.
1158210204 =/ declared-list=(unit shape) (find-simple-mold %list molds)
1158310205 =/ mold-prelude=(unit ifile)
1158410206 ?~ declared-list ~
1158510207 ?. (standard-prelude-list u.declared-list) ~
11586− `[~ ~[[%list [[%collection %list ~[[%var 0]]] ~[0]]]] at ~ ~ ~ ~ ~]
10208+ `[~ ~[[%list [[%collection %list ~[[%var 0]]] ~[0]]]] at ~ ~ ~ ~]
1158710209 =/ mt=imold-types (partial-prelude-molds molds state(prelude mold-prelude))
11588− =/ partial=ifile [~ mt at ~ ~ ~ ~ ~]
10210+ =/ partial=ifile [~ mt at ~ ~ ~ ~]
1158910211 :: An explicitly qualified re-export must resolve. Other unsupported
1159010212 :: prelude declarations remain reserved but absent from the interface.
1159110213 =/ required=imolds
@@ -11602,7 +10224,7 @@
1160210224 =/ deps=(list iwidth-dependency)
1160310225 ?~ u.private ~
1160410226 ~[[at.interface.i.u.private source.interface.i.u.private elaborations.interface.i.u.private]]
11605− `[env mt at ~ artifacts.resolution deps `src ~]
10227+ `[env mt at ~ artifacts.resolution deps `src]
1160610228::
1160710229++ partial-prelude-interface
1160810230 |= src=@t
@@ -11653,127 +10275,27 @@
1165310275 ?: =(at at.i.cache) `iface.i.cache
1165410276 $(cache t.cache)
1165510277::
11656−:: These certificates retain the complete checked source closure. The
11657−:: trusted host must supply the identical prepared prelude and reader nouns.
11658−:: Exact bundle equality binds all source paths and versions; the set
11659−:: retains transitive paths for active-cycle checks. Request-bearing graphs
11660−:: alone have a size limit; incompatible diamond evidence fails closed.
11661−++ request-graph-requests-add
11662− |= [pending=(list irequest-evidence) acc=(list irequest-evidence) fuel=@ud]
11663− ^- (unit (list irequest-evidence))
11664− ?~ pending `acc
11665− ?: =(0 fuel) ~
11666− =/ hit=(list irequest-evidence)
11667− (skim acc |=(x=irequest-evidence &(=(api-at.x api-at.i.pending) =(name.x name.i.pending))))
11668− ?^ hit
11669− ?. ?=([* ~] hit) ~
11670− ?. =(i.hit i.pending) ~
11671− $(pending t.pending, fuel (dec fuel))
11672− $(pending t.pending, acc [i.pending acc], fuel (dec fuel))
11673−++ request-graph-inputs-match
11674− |= [g=irequest-graph externals=iexternals marks=imark-externals modules=jbundle values=(list term) molds=(list term) prelude=(unit ifile)]
11675− ^- ?
11676− ?& =(bundle-input.g modules)
11677− =(prelude-input.g prelude)
11678− =(prelude-values.g values)
11679− =(prelude-molds.g molds)
11680− =(externals.g externals)
11681− =(marks.g marks)
11682− ==
11683−++ request-graph-bounded
11684− |= g=irequest-graph
11685− ^- ?
11686− =/ total=@ud (add (lent requests.g) (lent stores.g))
11687− &((lte (lent ~(tap in:..zuse paths.g)) 256) (lte total 256))
11688−::
11689−++ store-graph-requests-add
11690− |= [pending=(list istore-request-evidence) acc=(list istore-request-evidence) fuel=@ud]
11691− ^- (unit (list istore-request-evidence))
11692− ?~ pending `acc
11693− ?: =(0 fuel) ~
11694− =/ hit=(list istore-request-evidence)
11695− (skim acc |=(x=istore-request-evidence =(store-at.x store-at.i.pending)))
11696− ?^ hit
11697− ?. ?=([* ~] hit) ~
11698− ?. =(i.hit i.pending) ~
11699− $(pending t.pending, fuel (dec fuel))
11700− $(pending t.pending, acc [i.pending acc], fuel (dec fuel))
11701−::
11702−++ request-graph-merge
11703− |= [imports=ijimports g=irequest-graph fuel=@ud]
11704− ^- (unit irequest-graph)
11705− ?~ imports `g
11706− ?: =(0 fuel) ~
11707− =/ child=ifile interface.i.imports
11708− ?~ graph.child ~
11709− =/ cg=irequest-graph u.graph.child
11710− ?. ?& =(bundle-input.g bundle-input.cg)
11711− =(prelude-input.g prelude-input.cg)
11712− =(prelude-values.g prelude-values.cg)
11713− =(prelude-molds.g prelude-molds.cg)
11714− =(externals.g externals.cg)
11715− =(marks.g marks.cg)
11716− ==
11717− ~
11718− =/ merged=(set path) (~(uni in:..zuse paths.g) paths.cg)
11719− =/ rs=(unit (list irequest-evidence))
11720− (request-graph-requests-add requests.cg requests.g (add 1 (lent requests.cg)))
11721− ?~ rs ~
11722− =/ ss=(unit (list istore-request-evidence))
11723− (store-graph-requests-add stores.cg stores.g (add 1 (lent stores.cg)))
11724− ?~ ss ~
11725− =/ total=@ud (add (lent u.rs) (lent u.ss))
11726− ?: &(?=(^ u.rs) |((gth (lent ~(tap in:..zuse merged)) 256) (gth total 256))) ~
11727− ?: &(?=(^ u.ss) |((gth (lent ~(tap in:..zuse merged)) 256) (gth total 256))) ~
11728− $(imports t.imports, g g(paths merged, requests u.rs, stores u.ss), fuel (dec fuel))
11729−++ request-graph-reusable
11730− |= [f=ifile src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) values=(list term) molds=(list term) prelude=(unit ifile)]
11731− ^- ?
11732− ?~ source.f |
11733− ?. =(u.source.f src) |
11734− ?~ graph.f |
11735− =/ g=irequest-graph u.graph.f
11736− ?. (request-graph-inputs-match g externals marks modules values molds prelude) |
11737− ?. (~(has in:..zuse paths.g) at.f) |
11738− !(lien active |=(p=path (~(has in:..zuse paths.g) p)))
11739−::
1174010278++ resolve-jibb-imports
1174110279 |= [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)]
1174210280 ^- jimports-result
11743− =/ result=jimports-detailed-result
11744− (resolve-jibb-imports-detailed imports externals mark-externals modules active prelude-values prelude-molds cache prelude)
11745− ?: ?=(%| -.result) [%| message.p.result]
11746− [%& p.result]
11747−++ resolve-jibb-imports-detailed
11748− |= [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)]
11749− ^- jimports-detailed-result
1175010281 ?~ imports [%& [~ cache]]
1175110282 ?. ?=(%jibb -.i.imports) $(imports t.imports)
1175210283 =/ at=path (weld path.i.imports `path`~[%jibb])
1175310284 ?: =(at /lib/jibb/internal/jibb)
11754− [%| ['the prelude internal module is private' ~]]
10285+ [%| 'the prelude internal module is private']
1175510286 ?: =(at /lib/jibb/primitives/jibb)
11756− [%| ['the prelude primitive interface is private' ~]]
10287+ [%| 'the prelude primitive interface is private']
1175710288 ?: (lien active |=(p=path =(p at)))
11758− [%| [(crip "import cycle at {(spud at)}") ~]]
10289+ [%| (crip "import cycle at {(spud at)}")]
1175910290 =/ found=jbundle (skim modules |=(m=jsource =(at at.m)))
11760− ?~ found [%| [(crip "module source missing: {(spud at)}") ~]]
11761− ?^ t.found [%| [(crip "duplicate module sources: {(spud at)}") ~]]
10291+ ?~ found [%| (crip "module source missing: {(spud at)}")]
10292+ ?^ t.found [%| (crip "duplicate module sources: {(spud at)}")]
1176210293 =/ cached=(unit ifile) (find-jibb-cache at cache)
11763− =/ iface=jfile-detailed-result
11764− ?^ cached
11765− ?. =(at.u.cached at) [%| ['cached module identity needs unsupported inference' ~]]
11766− ?~ graph.u.cached
11767− :: A detached legacy interface has unknown evidence. Rebuild it
11768− :: against the current graph, without retaining any stale entry.
11769− =/ clean=jcache (skim cache |=(x=[at=path iface=ifile] !=(at.x at)))
11770− (infer-jibb-file-detailed at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds clean prelude)
11771− ?. (request-graph-reusable u.cached source.i.found externals mark-externals modules active prelude-values prelude-molds prelude)
11772− [%| ['cached module evidence needs unsupported inference' ~]]
11773− [%& [u.cached cache]]
11774− (infer-jibb-file-detailed at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
10294+ =/ iface=jfile-result
10295+ ?^ cached [%& [u.cached cache]]
10296+ (infer-jibb-file at source.i.found externals mark-externals modules [at active] prelude-values prelude-molds cache prelude)
1177510297 ?: ?=(%| -.iface) [%| p.iface]
11776− =/ rest=jimports-detailed-result $(imports t.imports, cache cache.p.iface)
10298+ =/ rest=jimports-result $(imports t.imports, cache cache.p.iface)
1177710299 ?: ?=(%| -.rest) rest
1177810300 [%& [[[face.i.imports iface.p.iface] resolved.p.rest] cache.p.rest]]
1177910301::
@@ -12020,27 +10542,6 @@
1202010542 (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
1202110543 ?~ paths [%| 'API path declaration needs unsupported analysis']
1202210544 [%& [file src u.prepared externals marks cache.p.deps u.paths]]
12023−:: Graph-aware variant preserves the caller active stack and cache.
12024−++ api-path-evidence-graph
12025− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
12026− ^- (each iapi-path-evidence @t)
12027− ?~ active [%| 'API analysis needs an active graph']
12028− ?. =(i.active file) [%| 'API analysis active graph does not start at the source']
12029− ?: (lien t.active |=(p=path =(p file))) [%| 'API analysis active graph contains a cycle']
12030− ?. ?=([%ui %api @ %jibb ~] file) [%| 'API path evidence requires /ui/api/<agent>.jibb']
12031− =/ parsed (parse file src)
12032− ?: ?=(%| -.parsed) [%| 'API path evidence source does not parse']
12033− =/ duplicate=(unit idiag) (duplicate-defs defs.p.parsed)
12034− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
12035− ?~ prepared [%| 'API path evidence needs the prepared prelude']
12036− =/ public=ifile iface.u.prepared
12037− =/ deps=jimports-result
12038− (resolve-jibb-imports imports.p.parsed externals marks modules active values.u.prepared molds.u.prepared cache `public)
12039− ?: ?=(%| -.deps) [%| p.deps]
12040− =/ paths=(unit (list iapi-path-typed))
12041− (api-path-analysis p.parsed marks values.u.prepared molds.u.prepared)
12042− ?~ paths [%| 'API path declaration needs unsupported analysis']
12043− [%& [file src u.prepared externals marks cache.p.deps u.paths]]
1204410545::
1204510546:: This query classifies a unique path declaration only. Missing evidence
1204610547:: or a nonunique name is unknown; it proves nothing about an ask value.
@@ -12136,228 +10637,13 @@
1213610637 =/ surs=(list term) (collect-sur-imports imports.mod)
1213710638 =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
1213810639 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
12139− =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~ ~ ~]
12140− =/ mts=(each imold-types @t) (module-mold-types molds state)
12141− ?: ?=(%| -.mts) [%| p.mts]
12142− =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
12143− ?. (module-values-complete ordinary env.resolution) [%| 'API ordinary definitions need unsupported inference']
12144− [%& [evidence env.resolution p.mts u.mark-types artifacts.resolution]]
12145−:: Preserve the same graph context through supporting definitions.
12146−++ api-support-analysis-graph
12147− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
12148− ^- (each iapi-support-evidence @t)
12149− =/ path-result (api-path-evidence-graph file src externals marks modules active cache prepared)
12150− ?: ?=(%| -.path-result) [%| p.path-result]
12151− =/ evidence=iapi-path-evidence p.path-result
12152− =/ parsed (parse file src)
12153− ?: ?=(%| -.parsed) [%| 'API source does not parse']
12154− =/ mod=module p.parsed
12155− =/ ordinary=(list def)
12156− (skim defs.mod |=(d=def !&(?=(%mold -.d) |(=(%paths name.d) =(%poke name.d)))))
12157− =/ prep=iprelude prepared.evidence
12158− ?. (module-scope-valid mod(defs ordinary) values.prep molds.prep) [%| 'API ordinary scope needs unsupported inference']
12159− =/ vals=(list term) (global-value-names ordinary)
12160− ?: (lien vals |=(n=term =(n %main))) [%| 'API module kind needs unsupported inference']
12161− =/ declared=(list term) (collect-mark-imports imports.mod)
12162− =/ mark-types=(unit (list iapi-mark-type)) (api-diff-types declared marks declared)
12163− ?~ mark-types [%| 'API declared marks need unsupported inference']
12164− =/ prelude=(unit ifile) `iface.prep
12165− =/ deps=jimports-result
12166− (resolve-jibb-imports imports.mod externals marks modules active values.prep molds.prep dependencies.evidence prelude)
12167− ?: ?=(%| -.deps) [%| p.deps]
12168− =/ molds=imolds (collect-simple-molds ordinary)
12169− =/ globals=(list term) (weld values.prep (weld (import-binding-names imports.mod) vals))
12170− =/ surs=(list term) (collect-sur-imports imports.mod)
12171− =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
12172− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
12173− =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~ ~ ~]
10640+ =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~]
1217410641 =/ mts=(each imold-types @t) (module-mold-types molds state)
1217510642 ?: ?=(%| -.mts) [%| p.mts]
1217610643 =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
1217710644 ?. (module-values-complete ordinary env.resolution) [%| 'API ordinary definitions need unsupported inference']
1217810645 [%& [evidence env.resolution p.mts u.mark-types artifacts.resolution]]
1217910646::
12180−:: Type-analysis artifact for one plain request. The resolver may publish
12181−:: its interface only together with trusted source and reader evidence.
12182−:: No lowering or runtime validator exists.
12183−:: Value watchability remains unproved even for a watchable declaration.
12184−+$ ione-request-interface
12185− [support=iapi-support-evidence parts=iapi-request-parts iface=ifile]
12186−++ store-compatible-poke
12187− |= prelude=iprelude
12188− ^- (unit ischeme)
12189− =/ public=ifile iface.prelude
12190− ?. =(at.public /lib/jibb/prelude/jibb) ~
12191− =/ poke=(unit ischeme) (find-jibb-mold %poke public)
12192− ?~ poke ~
12193− ?. ?=(%union -.typ.u.poke) ~
12194− ?^ vars.u.poke ~
12195− ?. =(origin.typ.u.poke `[/lib/jibb/internal/jibb %poke]) ~
12196− ?: (itype-has-tag typ.u.poke) ~
12197− =/ private=(list iwidth-dependency)
12198− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12199− ?. ?=([* ~] private) ~
12200− ?~ source.i.private ~
12201− =/ agent-case=itype
12202− [%cell [%const [%term %tas %agent '%agent']] [%cell [%face %agent [%atom %tas]] [%cell [%face %mark [%atom %tas]] [%face %payload [%noun ~]]]]]
12203− =/ store-case=itype
12204− [%cell [%const [%term %tas %store '%store']] [%cell [%face %module [%atom %t]] [%cell [%face %action [%atom %tas]] [%face %payload [%noun ~]]]]]
12205− ?. =(cases.typ.u.poke ~[agent-case store-case]) ~
12206− poke
12207−::
12208−++ request-compatible-ask
12209− |= prelude=iprelude
12210− ^- (unit ischeme)
12211− =/ public=ifile iface.prelude
12212− ?. =(at.public /lib/jibb/prelude/jibb) ~
12213− =/ ask=(unit ischeme) (find-jibb-mold %ask public)
12214− ?~ ask ~
12215− ?. ?=([@ ~] vars.u.ask) ~
12216− ?. ?=(%union -.typ.u.ask) ~
12217− ?. =(origin.typ.u.ask `[/lib/jibb/internal/jibb %ask]) ~
12218− ?. (identity-union-parameters vars.u.ask args.typ.u.ask) ~
12219− =/ m=@ud i.vars.u.ask
12220− ?: (itype-var-is-atom m typ.u.ask) ~
12221− ?. (levy (itype-vars typ.u.ask) |=(n=@ud =(n m))) ~
12222− ?: (itype-has-tag typ.u.ask) ~
12223− =/ private=(list iwidth-dependency)
12224− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12225− ?. ?=([* ~] private) ~
12226− ?~ source.i.private ~
12227− =/ path=(unit ischeme) (find-jibb-mold %path public)
12228− ?~ path ~
12229− ?^ vars.u.path ~
12230− =/ path-type=itype [%collection %list ~[[%atom %ta]]]
12231− ?. =(typ.u.path path-type) ~
12232− =/ unit-template=(unit ischeme) (find-jibb-mold %unit public)
12233− ?~ unit-template ~
12234− ?. (standard-unit-template u.unit-template /lib/jibb/prelude/jibb) ~
12235− =/ state-unit=(unit itype) (template-apply u.unit-template ~[[%noun ~]])
12236− ?~ state-unit ~
12237− =/ path-unit=(unit itype) (template-apply u.unit-template ~[path-type])
12238− ?~ path-unit ~
12239− =/ output=itype [%cell [%face %state [%noun ~]] [%face %message [%var m]]]
12240− =/ agent-input=itype [%cell [%face %mark [%atom %tas]] [%cell [%face %state u.state-unit] [%face %fact [%noun ~]]]]
12241− =/ store-input=itype [%cell [%face %state u.state-unit] [%face %fact [%noun ~]]]
12242− =/ pure-case=itype [%cell [%const [%term %tas %pure '%pure']] [%face %value [%var m]]]
12243− =/ agent-case=itype
12244− [%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]]]]]]]]
12245− =/ store-case=itype
12246− [%cell [%const [%term %tas %store '%store']] [%cell [%face %module [%atom %t]] [%cell [%face %name [%atom %tas]] [%face %receive [%fn store-input output]]]]]
12247− ?. =(cases.typ.u.ask ~[pure-case agent-case store-case]) ~
12248− ask
12249−::
12250−:: The first supported standalone API has exactly one mark import and one
12251−:: plain path declaration, with no other definitions or imports. No partial
12252−:: success is published when source, schema, or a required mold is unknown.
12253−++ one-request-interface-source
12254− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude)]
12255− ^- (each ione-request-interface @t)
12256− =/ out (api-support-analysis-source file src externals marks modules prepared)
12257− ?: ?=(%| -.out) [%| p.out]
12258− =/ support=iapi-support-evidence p.out
12259− =/ ev=iapi-path-evidence paths.support
12260− =/ parsed (parse file src)
12261− ?: ?=(%| -.parsed) [%| 'request source does not parse']
12262− =/ mod=module p.parsed
12263− ?. ?=(?([[%mark *] ~] [[%mark *] [%mark *] ~]) imports.mod) [%| 'request imports need unsupported inference']
12264− ?. ?=([[%mold *] ~] defs.mod) [%| 'request definitions need unsupported inference']
12265− ?. =(%paths name.i.defs.mod) [%| 'request declaration needs unsupported inference']
12266− ?. ?=([* ~] paths.ev) [%| 'request count needs unsupported inference']
12267− =/ p=iapi-path-typed i.paths.ev
12268− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
12269− ?~ parts [%| 'request components need unsupported inference']
12270− ?. ?=(?(~ [* ~]) parameters.u.parts) [%| 'request parameters need unsupported inference']
12271− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) [%| 'request parameter and fold need unsupported inference']
12272− ?^ scry.path.p [%| 'request scry needs unsupported inference']
12273− =/ valid-marks=?
12274− ?~ fold.u.parts ?=([* ~] marks.support)
12275− ?=([* [* ~]] marks.support)
12276− ?. valid-marks [%| 'request marks need unsupported inference']
12277− =/ fold-open=?
12278− ?~ fold.u.parts |
12279− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
12280− ?: fold-open [%| 'request fold needs unsupported inference']
12281− ?^ (itype-vars reply-sample.u.parts) [%| 'request payload needs unsupported inference']
12282− ?: (itype-has-tag reply-sample.u.parts) [%| 'request payload needs unsupported inference']
12283− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
12284− ?~ ask [%| 'request ask needs unsupported inference']
12285− =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
12286− ?~ result [%| 'request ask needs unsupported inference']
12287− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
12288− =/ sample=itype
12289− ?^ fold.u.parts [%cell callback u.fold.u.parts]
12290− ?~ parameters.u.parts callback
12291− [%cell typ.i.parameters.u.parts callback]
12292− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
12293− =/ exports=imold-types
12294− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
12295− =/ prelude=iprelude prepared.ev
12296− =/ public=ifile iface.prelude
12297− ?~ source.public [%| 'request prelude source needs unsupported inference']
12298− =/ private=(list iwidth-dependency)
12299− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12300− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
12301− ?~ source.i.private [%| 'request internal source needs unsupported inference']
12302− =/ req=irequest-evidence
12303− [file name.path.p p src u.source.public u.source.i.private values.prelude molds.prelude externals marks]
12304− =/ interface=ifile [~[[name.path.p scheme]] exports file ~ ~ ~ `src `[(silt `(list path)`~[file]) ~[req] ~ modules `public values.prelude molds.prelude externals marks]]
12305− [%& [support u.parts interface]]
12306−:: Graph-aware request artifact; resolver use remains type-only.
12307−++ one-request-interface-graph
12308− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
12309− ^- (each ione-request-interface @t)
12310− =/ out (api-support-analysis-graph file src externals marks modules active cache prepared)
12311− ?: ?=(%| -.out) [%| p.out]
12312− =/ support=iapi-support-evidence p.out
12313− =/ ev=iapi-path-evidence paths.support
12314− =/ parsed (parse file src)
12315− ?: ?=(%| -.parsed) [%| 'request source does not parse']
12316− =/ mod=module p.parsed
12317− ?. ?=(?([[%mark *] ~] [[%mark *] [%mark *] ~]) imports.mod) [%| 'request imports need unsupported inference']
12318− ?. ?=([[%mold *] ~] defs.mod) [%| 'request definitions need unsupported inference']
12319− ?. =(%paths name.i.defs.mod) [%| 'request declaration needs unsupported inference']
12320− ?. ?=([* ~] paths.ev) [%| 'request count needs unsupported inference']
12321− =/ p=iapi-path-typed i.paths.ev
12322− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
12323− ?~ parts [%| 'request components need unsupported inference']
12324− ?. ?=(?(~ [* ~]) parameters.u.parts) [%| 'request parameters need unsupported inference']
12325− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) [%| 'request parameter and fold need unsupported inference']
12326− ?^ scry.path.p [%| 'request scry needs unsupported inference']
12327− =/ valid-marks=?
12328− ?~ fold.u.parts ?=([* ~] marks.support)
12329− ?=([* [* ~]] marks.support)
12330− ?. valid-marks [%| 'request marks need unsupported inference']
12331− =/ fold-open=?
12332− ?~ fold.u.parts |
12333− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
12334− ?: fold-open [%| 'request fold needs unsupported inference']
12335− ?^ (itype-vars reply-sample.u.parts) [%| 'request payload needs unsupported inference']
12336− ?: (itype-has-tag reply-sample.u.parts) [%| 'request payload needs unsupported inference']
12337− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
12338− ?~ ask [%| 'request ask needs unsupported inference']
12339− =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
12340− ?~ result [%| 'request ask needs unsupported inference']
12341− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
12342− =/ sample=itype
12343− ?^ fold.u.parts [%cell callback u.fold.u.parts]
12344− ?~ parameters.u.parts callback
12345− [%cell typ.i.parameters.u.parts callback]
12346− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
12347− =/ exports=imold-types
12348− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
12349− =/ prelude=iprelude prepared.ev
12350− =/ public=ifile iface.prelude
12351− ?~ source.public [%| 'request prelude source needs unsupported inference']
12352− =/ private=(list iwidth-dependency)
12353− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12354− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
12355− ?~ source.i.private [%| 'request internal source needs unsupported inference']
12356− =/ req=irequest-evidence
12357− [file name.path.p p src u.source.public u.source.i.private values.prelude molds.prelude externals marks]
12358− =/ interface=ifile [~[[name.path.p scheme]] exports file ~ ~ ~ `src `[(silt `(list path)`~[file]) ~[req] ~ modules `public values.prelude molds.prelude externals marks]]
12359− [%& [support u.parts interface]]
12360−::
1236110647++ api-mark-exports
1236210648 |= [marks=(list term) all=(list term) externals=imark-externals]
1236310649 ^- imold-types
@@ -12401,1895 +10687,46 @@
1240110687 =/ mark=(unit itype) (find-imported-mark n mark-externals marks)
1240210688 ?~ mark ~
1240310689 =/ sc=ischeme [[%fn u.mark typ.u.poke] ~]
12404− `[~[[n sc]] (api-mark-exports marks marks mark-externals) at ~[[n i.t.t.at n]] ~ ~ ~ ~]
12405−::
12406−:: Source-proven ordinary helpers validate each selected /sur dependency.
12407−:: Unused or less direct cores remain unsupported by this first interface.
12408−++ api-sur-covered
12409− |= [surs=(list term) defs=(list def) externals=iexternals all=(list term)]
12410− ^- ?
12411− ?~ surs &
12412− =/ found=(list def)
12413− %+ skim defs
12414− |= d=def
12415− ?. ?=(%mold -.d) |
12416− ?. ?=(%ref -.shape.d) |
12417− ?. ?=([@ [@ ~]] names.shape.d) |
12418− =(i.t.names.shape.d i.surs)
12419− ?~ found |
12420− =/ selected=def i.found
12421− ?. ?=(%mold -.selected) |
12422− =/ sh=shape shape.selected
12423− ?. ?=(%ref -.sh) |
12424− ?. ?=([@ [@ ~]] names.sh) |
12425− =/ checked=(unit itype) (find-imported-mold i.surs i.names.sh externals all)
12426− ?~ checked |
12427− $(surs t.surs)
12428−::
12429−+$ imulti-request-gates [values=ienv requests=(list irequest-evidence)]
12430−++ api-request-gates
12431− |= [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]
12432− ^- (unit imulti-request-gates)
12433− ?~ paths `[~ ~]
12434− ?: =(0 fuel) ~
12435− =/ p=iapi-path-typed i.paths
12436− =/ parts=(unit iapi-request-parts) (api-request-parts `ev name.path.p)
12437− ?~ parts ~
12438− ?. ?=(?(~ [* ~]) parameters.u.parts) ~
12439− ?: &(?=(^ fold.u.parts) ?=(^ parameters.u.parts)) ~
12440− ?^ scry.path.p ~
12441− ?^ (itype-vars reply-sample.u.parts) ~
12442− ?: (itype-has-tag reply-sample.u.parts) ~
12443− =/ open-fold=?
12444− ?~ fold.u.parts |
12445− |(?=(^ (itype-vars u.fold.u.parts)) (itype-has-tag u.fold.u.parts))
12446− ?: open-fold ~
12447− =/ result=(unit itype) (template-apply ask ~[[%var 0]])
12448− ?~ result ~
12449− =/ callback=itype [%fn reply-sample.u.parts [%var 0]]
12450− =/ sample=itype
12451− ?^ fold.u.parts [%cell callback u.fold.u.parts]
12452− ?~ parameters.u.parts callback
12453− [%cell typ.i.parameters.u.parts callback]
12454− =/ scheme=ischeme [[%fn sample u.result] ~[0]]
12455− =/ prep=iprelude prepared.ev
12456− =/ req=irequest-evidence
12457− [file name.path.p p src public internal values.prep molds.prep externals marks]
12458− =/ rest=(unit imulti-request-gates)
12459− $(paths t.paths, fuel (dec fuel))
12460− ?~ rest ~
12461− `[[[name.path.p scheme] values.u.rest] [req requests.u.rest]]
12462−::
12463−++ api-poke-from-checked
12464− |= [file=path mod=module marks=imark-externals values=(list term) molds=(list term) prelude=(unit ifile)]
12465− ^- (unit [values=ienv derived=(list iderived)])
12466− =/ pokes=(list def)
12467− (skim defs.mod |=(d=def &(?=(%mold -.d) =(%poke name.d))))
12468− ?~ pokes `[~ ~]
12469− ?. ?=([* ~] pokes) ~
12470− =/ declared=(list term) (collect-mark-imports imports.mod)
12471− =/ ns=(unit (list term)) (api-poke-mark-names pokes declared)
12472− ?~ ns ~
12473− ?. ?=([@ ~] u.ns) ~
12474− =/ matching=(list import)
12475− %+ skim imports.mod
12476− |= i=import
12477− ?. ?=(%mark -.i) |
12478− =(mark.i i.u.ns)
12479− ?. ?=([* ~] matching) ~
12480− =/ checked=(unit ifile)
12481− (api-poke-interface file mod(defs pokes, imports matching) marks values molds prelude)
12482− ?~ checked ~
12483− `[values.u.checked derived.u.checked]
12484−::
12485−:: The partial interface is published atomically: all paths, ordinary
12486−:: source definitions, declared marks and the poke must check. Unselected
12487−:: /sur bindings, runtime validation and value watchability remain unproved.
12488−++ multi-request-interface-graph
12489− |= [file=path src=@t externals=iexternals marks=imark-externals modules=jbundle active=(list path) cache=jcache prepared=(unit iprelude)]
12490− ^- (each [iface=ifile cache=jcache] @t)
12491− =/ out (api-support-analysis-graph file src externals marks modules active cache prepared)
12492− ?: ?=(%| -.out) [%| p.out]
12493− =/ support=iapi-support-evidence p.out
12494− =/ ev=iapi-path-evidence paths.support
12495− =/ parsed (parse file src)
12496− ?: ?=(%| -.parsed) [%| 'request source does not parse']
12497− =/ mod=module p.parsed
12498− ?. (levy imports.mod |=(i=import ?=(?(%mark %sur) -.i)))
12499− [%| 'request imports need unsupported inference']
12500− =/ surs=(list term) (collect-sur-imports imports.mod)
12501− ?. (api-sur-covered surs defs.mod externals surs)
12502− [%| 'API source dependency needs unsupported inference']
12503− ?~ paths.ev [%| 'request count needs unsupported inference']
12504− =/ ask=(unit ischeme) (request-compatible-ask prepared.ev)
12505− ?~ ask [%| 'request ask needs unsupported inference']
12506− =/ prep=iprelude prepared.ev
12507− =/ public=ifile iface.prep
12508− ?~ source.public [%| 'request prelude source needs unsupported inference']
12509− =/ private=(list iwidth-dependency)
12510− (skim dependencies.public |=(d=iwidth-dependency =(at.d /lib/jibb/internal/jibb)))
12511− ?. ?=([* ~] private) [%| 'request internal source needs unsupported inference']
12512− ?~ source.i.private [%| 'request internal source needs unsupported inference']
12513− =/ gates=(unit imulti-request-gates)
12514− (api-request-gates paths.ev ev u.ask file src u.source.public u.source.i.private externals marks 256)
12515− ?~ gates [%| 'request paths need unsupported inference']
12516− =/ poke=(unit [values=ienv derived=(list iderived)])
12517− (api-poke-from-checked file mod marks values.prep molds.prep `public)
12518− ?~ poke [%| 'API poke needs unsupported inference']
12519− =/ mark-molds=imold-types
12520− (turn marks.support |=(m=iapi-mark-type [name.m [typ.m ~]]))
12521− =/ exports=imold-types (weld mark-molds molds.support)
12522− =/ names=(list term) (turn exports |=(m=[name=term template=ischeme] name.m))
12523− ?. (levy names |=(n=term (unique-value-name n names)))
12524− [%| 'API exported molds need unsupported inference']
12525− =/ env=ienv (weld values.u.gates (weld values.u.poke values.support))
12526− =/ graph=irequest-graph
12527− [(silt `(list path)`~[file]) requests.u.gates ~ modules `public values.prep molds.prep externals marks]
12528− =/ iface=ifile
12529− [env exports file derived.u.poke elaborations.support ~ `src `graph]
12530− [%& [iface dependencies.ev]]
12531−::
12532−:: A checked program main is only the direct four-component source call.
12533−:: Grouping is transparent, but aliases, qualified wings and other module
12534−:: kinds remain outside this slice.
12535−++ program-main-def
12536− |= ds=(list def)
12537− ^- (unit def)
12538− ?~ ds ~
12539− ?: &(?=(%value -.i.ds) =(%main name.i.ds)) `i.ds
12540− $(ds t.ds)
12541−::
12542−++ program-main-wing
12543− |= e=expr
12544− ^- (unit term)
12545− ?: ?=(%group -.e) $(e inner.e)
12546− ?. ?=(%wing -.e) ~
12547− ?. ?=([@ ~] names.e) ~
12548− `i.names.e
12549−::
12550−++ program-main-args
12551− |= d=def
12552− ^- (unit (list expr))
12553− ?. ?=(%value -.d) ~
12554− |-
12555− ?: ?=(%group -.val.d) $(val.d inner.val.d)
12556− ?. ?=(%call -.val.d) ~
12557− =/ head=(unit term) (program-main-wing head.val.d)
12558− ?~ head ~
12559− ?. =(%program u.head) ~
12560− ?. ?=([* * * * ~] args.val.d) ~
12561− `args.val.d
12562−::
12563−++ program-main-parts
12564− |= d=def
12565− ^- (unit [init=term update=term view=term subs=term])
12566− ?. ?=(%value -.d) ~
12567− |-
12568− ?: ?=(%group -.val.d) $(val.d inner.val.d)
12569− ?. ?=(%call -.val.d) ~
12570− =/ head=(unit term) (program-main-wing head.val.d)
12571− ?~ head ~
12572− ?. =(%program u.head) ~
12573− ?. ?=([* * * * ~] args.val.d) ~
12574− =/ args=(list expr) args.val.d
12575− ?> ?=([* * * * ~] args)
12576− =/ init=(unit term) (program-main-wing i.args)
12577− =/ update=(unit term) (program-main-wing i.t.args)
12578− =/ view=(unit term) (program-main-wing i.t.t.args)
12579− =/ subs=(unit term) (program-main-wing i.t.t.t.args)
12580− ?~ init ~
12581− ?~ update ~
12582− ?~ view ~
12583− ?~ subs ~
12584− `[u.init u.update u.view u.subs]
12585−::
12586−:: A data page is only the direct two-component source call. Grouping is
12587−:: transparent, but page aliases, qualified wings and other kinds are not.
12588−++ page-main-parts
12589− |= d=def
12590− ^- (unit [load=term view=term])
12591− ?. ?=(%value -.d) ~
12592− |-
12593− ?: ?=(%group -.val.d) $(val.d inner.val.d)
12594− ?. ?=(%call -.val.d) ~
12595− =/ head=(unit term) (program-main-wing head.val.d)
12596− ?~ head ~
12597− ?. =(%page u.head) ~
12598− ?. ?=([* * ~] args.val.d) ~
12599− =/ args=(list expr) args.val.d
12600− ?> ?=([* * ~] args)
12601− =/ load=(unit term) (program-main-wing i.args)
12602− =/ view=(unit term) (program-main-wing i.t.args)
12603− ?~ load ~
12604− ?~ view ~
12605− `[u.load u.view]
12606−::
12607−:: A store main is only the direct two-wing source call. The poke declaration
12608−:: is checked here, then removed before every ordinary mold/value inference pass.
12609−++ store-main-parts
12610− |= d=def
12611− ^- (unit [init=term update=term])
12612− ?. ?=(%value -.d) ~
12613− |-
12614− ?: ?=(%group -.val.d) $(val.d inner.val.d)
12615− ?. ?=(%call -.val.d) ~
12616− =/ head=(unit term) (program-main-wing head.val.d)
12617− ?~ head ~
12618− ?. =(%store u.head) ~
12619− ?. ?=([* * ~] args.val.d) ~
12620− =/ args=(list expr) args.val.d
12621− ?> ?=([* * ~] args)
12622− =/ init=(unit term) (program-main-wing i.args)
12623− =/ update=(unit term) (program-main-wing i.t.args)
12624− ?~ init ~
12625− ?~ update ~
12626− `[u.init u.update]
12627−::
12628−+$ istore-declaration [action=term defs=(list def)]
12629−++ store-declaration
12630− |= [mod=module prelude-values=(list term) prelude-molds=(list term)]
12631− ^- (unit istore-declaration)
12632− =/ ds=(list def) defs.mod
12633− =/ pokes=(list def)
12634− (skim ds |=(d=def &(?=(%mold -.d) =(%poke name.d))))
12635− ?. ?=([* ~] pokes) ~
12636− =/ states=(list def)
12637− (skim ds |=(d=def &(?=(%mold -.d) =(%state name.d))))
12638− ?. ?=([* ~] states) ~
12639− =/ poke=def i.pokes
12640− =/ state=def i.states
12641− ?> &(?=(%mold -.poke) ?=(%mold -.state))
12642− ?: ?=(%generic -.shape.state) ~
12643− ?. ?=(%ref -.shape.poke) ~
12644− ?. ?=([@ ~] names.shape.poke) ~
12645− =/ action=term i.names.shape.poke
12646− =/ actions=(list def)
12647− (skim ds |=(d=def &(?=(%mold -.d) =(action name.d))))
12648− ?. ?=([* ~] actions) ~
12649− =/ action-def=def i.actions
12650− ?> ?=(%mold -.action-def)
12651− ?: ?=(%generic -.shape.action-def) ~
12652− =/ ordinary=(list def)
12653− (skim ds |=(d=def !&(?=(%mold -.d) =(%poke name.d))))
12654− ?. (module-scope-valid mod(defs ordinary) prelude-values prelude-molds) ~
12655− =/ derived=(list term) ~[%state action]
12656− ?: (lien derived |=(n=term =(n %proj))) ~
12657− =/ outer=(list term)
12658− (weld prelude-values (weld (global-value-names ordinary) (api-import-faces imports.mod)))
12659− ?. (levy derived |=(n=term &((unique-value-name n derived) !(lien outer |=(x=term =(n x)))))) ~
12660− `[action ordinary]
12661−::
12662−++ program-empty-null
12663− |= e=expr
12664− ^- ?
12665− ?- -.e
12666− %lit =(%null form.lit.e)
12667− %cast $(e val.e)
12668− %group $(e inner.e)
12669− %body ?~(defs.e $(e final.e) |)
12670− * |
12671− ==
12672−::
12673−++ program-subs-empty
12674− |= d=def
12675− ^- ?
12676− ?. ?=(%value -.d) |
12677− ?- -.val.d
12678− %gate (program-empty-null body.val.d)
12679− %gate-wide (program-empty-null body.val.d)
12680− * |
12681− ==
12682−::
12683−++ program-transparent
12684− |= e=expr
12685− ^- expr
12686− ?- -.e
12687− %group $(e inner.e)
12688− %cast $(e val.e)
12689− %body ?~(defs.e $(e final.e) e)
12690− * e
12691− ==
12692−++ program-init-tuple-null
12693− |= d=def
12694− ^- ?
12695− ?. ?=(%value -.d) |
12696− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) |
12697− =/ body=expr
12698− ?- -.val.d
12699− %gate body.val.d
12700− %gate-wide body.val.d
12701− * !!
12702− ==
12703− =. body (program-transparent body)
12704− ?. ?=(%tuple -.body) |
12705− ?~ items.body |
12706− (program-empty-null val:(rear items.body))
12707−::
12708−:: Recover only the update of an already recognized direct program main.
12709−:: Its written sample determines the message/model relationship; the canonical
12710−:: cmd, unit and update slot determine the result context. Publication is
12711−:: component-local so later subscription/view/initializer retries can accumulate.
12712−++ program-update-context
12713− |= [main=def parts=[init=term update=term view=term subs=term] ds=(list def) resolution=iresolved initial=istate]
12714− ^- (unit iresolved)
12715− =/ env=ienv env.resolution
12716− ?^ (ienv-lookup %main env) ~
12717− ?^ (ienv-lookup update.parts env) ~
12718− =/ updates=(list def)
12719− (skim ds |=(d=def &(?=(%value -.d) =(update.parts name.d))))
12720− ?. ?=([* ~] updates) ~
12721− =/ update-def=def i.updates
12722− ?> ?=(%value -.update-def)
12723− =/ written-update=(unit sample) (direct-gate-sample update-def)
12724− ?~ written-update ~
12725− ?. ?=(%cell -.u.written-update) ~
12726− ?. ?=([* * ~] items.u.written-update) ~
12727− ?~ prelude.initial ~
12728− =/ program=(unit ischeme) (ienv-lookup %program values.u.prelude.initial)
12729− ?~ program ~
12730− =/ command=(unit ischeme) (find-jibb-mold %cmd u.prelude.initial)
12731− =/ list-template=(unit ischeme) (find-jibb-mold %list u.prelude.initial)
12732− ?~ command ~
12733− ?~ list-template ~
12734− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude.initial)
12735− ?~ heads ~
12736− =/ written=(unit def) (~(get by gates.u.heads) %program)
12737− ?~ written ~
12738− =/ written-sample=(unit sample) (direct-gate-sample u.written)
12739− ?~ written-sample ~
12740− ?. ?=(%cell -.u.written-sample) ~
12741− ?. ?=([* * * * ~] items.u.written-sample) ~
12742− =/ checked=(map term def)
12743− (~(put by (direct-checked-gates ds env)) update.parts update-def)
12744− =/ templates=ienv
12745− (turn molds.u.prelude.initial |=(x=[name=term template=ischeme] [name.x template.x]))
12746− =/ scanned=(unit dgscan)
12747− (dg-all-env-ids (weld env (weld values.u.prelude.initial templates)) 32.768 ~)
12748− ?~ scanned ~
12749− =. next.initial (dg-next-id ids.u.scanned 0)
12750− =/ update-state=istate (reserve-def-caps val.update-def initial)
12751− =/ sam=isample-result (infer-sample u.written-update env update-state)
12752− ?: ?=(%| -.sam) ~
12753− =/ actual-sample=itype (itype-normalize typ.p.sam sub.state.p.sam)
12754− ?. ?=(%cell -.actual-sample) ~
12755− =/ message=(unit itype)
12756− (direct-slot-body hed.actual-sample (direct-sample-name i.items.u.written-update))
12757− =/ model=(unit itype)
12758− (direct-slot-body tal.actual-sample (direct-sample-name i.t.items.u.written-update))
12759− ?~ message ~
12760− ?~ model ~
12761− =/ cmd=(unit itype) (template-apply u.command ~[u.message])
12762− ?~ cmd ~
12763− =/ command-result=(unit itype) (template-apply u.list-template ~[u.cmd])
12764− ?~ command-result ~
12765− =/ product=itype [%cell u.model u.command-result]
12766− =/ instance=[typ=itype state=istate] (instantiate-scheme u.program state.p.sam)
12767− ?. ?=(%fn -.typ.instance) ~
12768− ?. ?=(%cell -.sample.typ.instance) ~
12769− ?. ?=(%cell -.tal.sample.typ.instance) ~
12770− =/ expected-update=(unit itype)
12771− (direct-slot-body hed.tal.sample.typ.instance (direct-sample-name i.t.items.u.written-sample))
12772− ?~ expected-update ~
12773− ?. ?=(%fn -.u.expected-update) ~
12774− :: Sample binders are not value faces. Strip only those two slot faces
12775− :: for the invariant canonical-gate proof; the source-faced gate is still
12776− :: used by the complete positional call and final ordinary result cast.
12777− =/ canonical-candidate=itype [%fn [%cell u.message u.model] product]
12778− =/ gate-fit=ifit
12779− (direct-invariant canonical-candidate u.expected-update sub.state.instance next.state.instance)
12780− ?. ?=(%ok -.gate-fit) ~
12781− =/ closed=itype
12782− (itype-normalize [%fn typ.p.sam product] sub.gate-fit)
12783− ?. ?=(%fn -.closed) ~
12784− :: The closed product no longer needs the canonical slot substitutions.
12785− :: Start the body at its ordinary sample state so existing branch retries
12786− :: keep their substitution guards, but retain the shared fresh-ID high water.
12787− =/ st=istate state.p.sam(next next.gate-fit, gate-defs checked, head-evidence heads)
12788− =/ body=expr
12789− ?- -.val.update-def
12790− %gate body.val.update-def
12791− %gate-wide body.val.update-def
12792− * !!
12793− ==
12794− =/ inferred=iresult
12795− (infer-call-context-arg body product.closed env.p.sam st (span-of body))
12796− ?: ?=(%| -.inferred) ~
12797− =/ product-fit=ifit
12798− (itype-fit typ.p.inferred product.closed sub.state.p.inferred next.state.p.inferred)
12799− ?. ?=(%ok -.product-fit) ~
12800− =/ merged-product=itype
12801− (itype-merge-faces typ.p.inferred product.closed sub.product-fit)
12802− =/ actual-cast=itype [%fn typ.p.sam merged-product]
12803− =/ cast=ifit
12804− (itype-fit actual-cast closed sub.product-fit next.product-fit)
12805− ?. ?=(%ok -.cast) ~
12806− =/ merged=itype (itype-merge-faces actual-cast closed sub.cast)
12807− =/ adjusted=iresult
12808− [%& merged state.p.inferred(sub sub.cast, next next.cast)]
12809− =/ added=(unit iadded-definition)
12810− (add-supported-result update-def adjusted update-state env checked artifacts.resolution)
12811− ?~ added ~
12812− =/ recovered=(unit ischeme) (ienv-lookup update.parts env.u.added)
12813− ?~ recovered ~
12814− ?. ?=(~ vars.u.recovered) ~
12815− ?. ?=(~ (itype-vars typ.u.recovered)) ~
12816− `[env.u.added grouped.resolution artifacts.u.added]
12817−::
12818−++ program-inferred-slot
12819− |= [typ=itype name=(unit term)]
12820− ^- itype
12821− ?~ name typ
12822− ?: &(?=(%face -.typ) =(name.typ u.name)) body.typ
12823− typ
12824−::
12825−++ program-inferred-sample
12826− |= [typ=itype sam=sample]
12827− ^- itype
12828− (program-inferred-slot typ (direct-sample-name sam))
12829−::
12830−++ program-two-slot-names
12831− |= sam=sample
12832− ^- (unit [first=(unit term) second=(unit term)])
12833− ?- -.sam
12834− %cell
12835− ?. ?=([* * ~] items.sam) ~
12836− `[(direct-sample-name i.items.sam) (direct-sample-name i.t.items.sam)]
12837− %face
12838− ?. ?=(%cell -.shape.sam) ~
12839− ?. ?=([* * ~] fields.shape.sam) ~
12840− `[(direct-field-name i.fields.shape.sam) (direct-field-name i.t.fields.shape.sam)]
12841− * ~
12842− ==
12843−::
12844−:: Read message/model from the checked update and its written source layout.
12845−:: The source names strip only top-level sample binder faces; nested value
12846−:: faces remain part of the canonical message and model.
12847−++ program-update-relation
12848− |= [name=term ds=(list def) env=ienv]
12849− ^- (unit [message=itype model=itype])
12850− =/ update=(unit ischeme) (ienv-lookup name env)
12851− ?~ update ~
12852− ?. ?=(~ vars.u.update) ~
12853− ?. ?=(~ (itype-vars typ.u.update)) ~
12854− ?. ?=(%fn -.typ.u.update) ~
12855− ?. ?=(%cell -.sample.typ.u.update) ~
12856− =/ defs=(list def)
12857− (skim ds |=(d=def &(?=(%value -.d) =(name name.d))))
12858− ?. ?=([* ~] defs) ~
12859− =/ written=(unit sample) (direct-gate-sample i.defs)
12860− ?~ written ~
12861− ?. ?=(%cell -.u.written) ~
12862− ?. ?=([* * ~] items.u.written) ~
12863− =/ message=(unit itype)
12864− (direct-slot-body hed.sample.typ.u.update (direct-sample-name i.items.u.written))
12865− =/ model=(unit itype)
12866− (direct-slot-body tal.sample.typ.u.update (direct-sample-name i.t.items.u.written))
12867− ?~ message ~
12868− ?~ model ~
12869− `[u.message u.model]
12870−::
12871−:: Recover an unannotated direct subscription component from the checked
12872−:: update relation and canonical fourth program slot. This establishes only
12873−:: the value type; the final program watch proof remains separate.
12874−++ program-subs-context
12875− |= [parts=[init=term update=term view=term subs=term] ds=(list def) resolution=iresolved initial=istate]
12876− ^- (unit iresolved)
12877− =/ env=ienv env.resolution
12878− ?^ (ienv-lookup %main env) ~
12879− ?^ (ienv-lookup subs.parts env) ~
12880− =/ relation=(unit [message=itype model=itype])
12881− (program-update-relation update.parts ds env)
12882− ?~ relation ~
12883− =/ subs=(list def)
12884− (skim ds |=(d=def &(?=(%value -.d) =(subs.parts name.d))))
12885− ?. ?=([* ~] subs) ~
12886− =/ subs-def=def i.subs
12887− ?> ?=(%value -.subs-def)
12888− =/ written-subs=(unit sample) (direct-gate-sample subs-def)
12889− ?~ written-subs ~
12890− ?~ prelude.initial ~
12891− =/ program=(unit ischeme) (ienv-lookup %program values.u.prelude.initial)
12892− =/ sub=(unit ischeme) (find-jibb-mold %sub u.prelude.initial)
12893− =/ list-template=(unit ischeme) (find-jibb-mold %list u.prelude.initial)
12894− ?~ program ~
12895− ?~ sub ~
12896− ?~ list-template ~
12897− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude.initial)
12898− ?~ heads ~
12899− =/ written=(unit def) (~(get by gates.u.heads) %program)
12900− ?~ written ~
12901− =/ written-sample=(unit sample) (direct-gate-sample u.written)
12902− ?~ written-sample ~
12903− ?. ?=(%cell -.u.written-sample) ~
12904− ?. ?=([* * * * ~] items.u.written-sample) ~
12905− =/ checked=(map term def) (direct-checked-gates ds env)
12906− =/ templates=ienv
12907− (turn molds.u.prelude.initial |=(x=[name=term template=ischeme] [name.x template.x]))
12908− =/ scanned=(unit dgscan)
12909− (dg-all-env-ids (weld env (weld values.u.prelude.initial templates)) 32.768 ~)
12910− ?~ scanned ~
12911− =. next.initial (dg-next-id ids.u.scanned 0)
12912− =/ subs-state=istate (reserve-def-caps val.subs-def initial)
12913− =/ sam=isample-result (infer-sample u.written-subs env subs-state)
12914− ?: ?=(%| -.sam) ~
12915− =/ actual-model=itype (program-inferred-sample typ.p.sam u.written-subs)
12916− ?. ?=(~ (itype-vars actual-model)) ~
12917− ?: (itype-has-tag actual-model) ~
12918− =/ model-fit=ifit
12919− (direct-invariant actual-model model.u.relation sub.state.p.sam next.state.p.sam)
12920− ?. ?=(%ok -.model-fit) ~
12921− =/ message-sub=(unit itype) (template-apply u.sub ~[message.u.relation])
12922− ?~ message-sub ~
12923− =/ product=(unit itype) (template-apply u.list-template ~[u.message-sub])
12924− ?~ product ~
12925− =/ instance=[typ=itype state=istate]
12926− (instantiate-scheme u.program state.p.sam(sub sub.model-fit, next next.model-fit))
12927− ?. ?=(%fn -.typ.instance) ~
12928− ?. ?=(%cell -.sample.typ.instance) ~
12929− ?. ?=(%cell -.tal.sample.typ.instance) ~
12930− ?. ?=(%cell -.tal.tal.sample.typ.instance) ~
12931− =/ expected-subs=(unit itype)
12932− (direct-slot-body tal.tal.tal.sample.typ.instance (direct-sample-name i.t.t.t.items.u.written-sample))
12933− ?~ expected-subs ~
12934− ?. ?=(%fn -.u.expected-subs) ~
12935− =/ canonical=itype [%fn model.u.relation u.product]
12936− =/ gate-fit=ifit
12937− (direct-invariant canonical u.expected-subs sub.state.instance next.state.instance)
12938− ?. ?=(%ok -.gate-fit) ~
12939− =/ closed=itype
12940− (itype-normalize [%fn typ.p.sam u.product] sub.gate-fit)
12941− ?. ?=(%fn -.closed) ~
12942− =/ body=expr
12943− ?- -.val.subs-def
12944− %gate body.val.subs-def
12945− %gate-wide body.val.subs-def
12946− * !!
12947− ==
12948− =/ st=istate
12949− state.p.sam(next next.gate-fit, gate-defs checked, head-evidence heads)
12950− =/ inferred=iresult
12951− (infer-call-context-arg body product.closed env.p.sam st (span-of body))
12952− ?: ?=(%| -.inferred) ~
12953− =/ product-fit=ifit
12954− (itype-fit typ.p.inferred product.closed sub.state.p.inferred next.state.p.inferred)
12955− ?. ?=(%ok -.product-fit) ~
12956− =/ merged-product=itype
12957− (itype-merge-faces typ.p.inferred product.closed sub.product-fit)
12958− =/ actual-cast=itype [%fn typ.p.sam merged-product]
12959− =/ cast=ifit
12960− (itype-fit actual-cast closed sub.product-fit next.product-fit)
12961− ?. ?=(%ok -.cast) ~
12962− =/ merged=itype (itype-merge-faces actual-cast closed sub.cast)
12963− =/ adjusted=iresult
12964− [%& merged state.p.inferred(sub sub.cast, next next.cast)]
12965− =/ added=(unit iadded-definition)
12966− (add-supported-result subs-def adjusted subs-state env checked artifacts.resolution)
12967− ?~ added ~
12968− =/ recovered=(unit ischeme) (ienv-lookup subs.parts env.u.added)
12969− ?~ recovered ~
12970− ?. ?=(~ vars.u.recovered) ~
12971− ?. ?=(~ (itype-vars typ.u.recovered)) ~
12972− `[env.u.added grouped.resolution artifacts.u.added]
12973−::
12974−+$ iview-site [xs=expr mapper=term]
12975−++ program-view-site
12976− |= e=expr
12977− ^- (unit iview-site)
12978− =. e (program-transparent e)
12979− ?. ?=(%call -.e) ~
12980− ?. ?=([* ~] args.e) ~
12981− =/ each=expr (program-transparent head.e)
12982− ?. ?=(%wing -.each) ~
12983− ?. ?=([%each ~] names.each) ~
12984− =/ turned=expr (program-transparent i.args.e)
12985− ?. ?=(%call -.turned) ~
12986− ?. ?=([* * ~] args.turned) ~
12987− =/ turn=expr (program-transparent head.turned)
12988− ?. ?=(%wing -.turn) ~
12989− ?. ?=([%turn ~] names.turn) ~
12990− =/ xs=expr (program-transparent i.args.turned)
12991− ?. ?=(%wing -.xs) ~
12992− ?~ names.xs ~
12993− =/ mapper=(unit term) (program-main-wing i.t.args.turned)
12994− ?~ mapper ~
12995− `[xs u.mapper]
12996−::
12997−++ program-recovery-names
12998− |= ds=(list def)
12999− ^- (list term)
13000− =/ main=(unit def) (program-main-def ds)
13001− ?~ main ~
13002− =/ parts=(unit [init=term update=term view=term subs=term])
13003− (program-main-parts u.main)
13004− ?~ parts ~
13005− =/ views=(list def)
13006− (skim ds |=(d=def &(?=(%value -.d) =(view.u.parts name.d))))
13007− ?. ?=([* ~] views) ~
13008− =/ view-def=def i.views
13009− ?> ?=(%value -.view-def)
13010− =/ written=(unit sample) (direct-gate-sample view-def)
13011− ?~ written ~
13012− =/ body=expr
13013− ?- -.val.view-def
13014− %gate body.val.view-def
13015− %gate-wide body.val.view-def
13016− * !!
13017− ==
13018− =/ sites=(unit (list iview-site)) (program-view-sites body ~)
13019− ?~ sites ~
13020− ?. ?=([* ~] u.sites) ~
13021− =/ mapper=term mapper.i.u.sites
13022− =/ components=(list term)
13023− :~ init.u.parts
13024− update.u.parts
13025− view.u.parts
13026− subs.u.parts
13027− ==
13028− ?: (lien components |=(n=term =(n mapper))) ~
13029− =/ mappers=(list def)
13030− (skim ds |=(d=def &(?=(%value -.d) =(mapper name.d))))
13031− ?. ?=([* ~] mappers) ~
13032− :~ init.u.parts
13033− update.u.parts
13034− view.u.parts
13035− subs.u.parts
13036− mapper
13037− ==
13038−::
13039−++ program-sample-binders
13040− |= sam=sample
13041− ^- (list term)
13042− ?- -.sam
13043− %bind ~[name.sam]
13044− %face ~[name.sam]
13045− %pun ~[name.sam]
13046− %cell (zing (turn items.sam |=(s=sample (program-sample-binders s))))
13047− * ~
13048− ==
13049−::
13050−++ program-pattern-binders
13051− |= pat=pattern
13052− ^- (list term)
13053− ?- -.pat
13054− %bind ~[name.pat]
13055− %cell (zing (turn items.pat |=(p=pattern (program-pattern-binders p))))
13056− * ~
13057− ==
13058−::
13059−++ program-view-sites-merge
13060− |= [a=(unit (list iview-site)) b=(unit (list iview-site))]
13061− ^- (unit (list iview-site))
13062− ?~ a ~
13063− ?~ b ~
13064− `(weld u.a u.b)
13065−::
13066−++ program-view-sites-exprs
13067− |= [xs=(list expr) locals=(list term)]
13068− ^- (unit (list iview-site))
13069− ?~ xs `~
13070− (program-view-sites-merge (program-view-sites i.xs locals) $(xs t.xs))
13071−::
13072−++ program-view-sites-items
13073− |= [xs=(list item) locals=(list term)]
13074− ^- (unit (list iview-site))
13075− ?~ xs `~
13076− (program-view-sites-merge (program-view-sites val.i.xs locals) $(xs t.xs))
13077−::
13078−++ program-view-sites-pieces
13079− |= [xs=(list piece) locals=(list term)]
13080− ^- (unit (list iview-site))
13081− ?~ xs `~
13082− =/ here=(unit (list iview-site))
13083− ?- -.i.xs
13084− %expr (program-view-sites p.i.xs locals)
13085− %text `~
13086− ==
13087− (program-view-sites-merge here $(xs t.xs))
13088−::
13089−++ program-view-sites-qsegs
13090− |= [xs=(list qseg) locals=(list term)]
13091− ^- (unit (list iview-site))
13092− ?~ xs `~
13093− =/ here=(unit (list iview-site))
13094− ?- -.i.xs
13095− %expr (program-view-sites p.i.xs locals)
13096− %knot `~
13097− ==
13098− (program-view-sites-merge here $(xs t.xs))
13099−::
13100−++ program-view-sites-edits
13101− |= [xs=(list edit) locals=(list term)]
13102− ^- (unit (list iview-site))
13103− ?~ xs `~
13104− (program-view-sites-merge (program-view-sites val.i.xs locals) $(xs t.xs))
13105−::
13106−++ program-view-sites-defs
13107− |= [xs=(list def) locals=(list term)]
13108− ^- (unit (list iview-site))
13109− ?~ xs `~
13110− =/ here=(unit (list iview-site))
13111− ?: ?=(%mold -.i.xs) `~
13112− (program-view-sites val.i.xs locals)
13113− (program-view-sites-merge here $(xs t.xs))
13114−::
13115−++ program-view-sites-arms
13116− |= [xs=(list arm) locals=(list term)]
13117− ^- (unit (list iview-site))
13118− ?~ xs `~
13119− =/ nested=(list term) (weld (program-pattern-binders pat.i.xs) locals)
13120− (program-view-sites-merge (program-view-sites val.i.xs nested) $(xs t.xs))
13121−::
13122−++ program-view-sites
13123− |= [e=expr locals=(list term)]
13124− ^- (unit (list iview-site))
13125− =/ site=(unit iview-site) (program-view-site e)
13126− ?^ site
13127− =/ names=(list term) ~[%each %turn mapper.u.site]
13128− ?> ?=(%wing -.xs.u.site)
13129− =/ root=term (rear names.xs.u.site)
13130− ?: |((lien names |=(n=term (lien locals |=(x=term =(n x))))) (lien locals |=(x=term =(root x))))
13131− ~
13132− `~[u.site]
13133− ?- -.e
13134− %str (program-view-sites-pieces pieces.e locals)
13135− %qath (program-view-sites-qsegs segs.e locals)
13136− %change (program-view-sites-edits edits.e locals)
13137− %pair (program-view-sites val.e locals)
13138− %unit (program-view-sites val.e locals)
13139− %group (program-view-sites inner.e locals)
13140− %list (program-view-sites-exprs items.e locals)
13141− %tuple (program-view-sites-items items.e locals)
13142− %gate
13143− (program-view-sites body.e (weld (program-sample-binders sample.e) locals))
13144− %gate-wide
13145− (program-view-sites body.e (weld (program-sample-binders sample.e) locals))
13146− %call
13147− (program-view-sites-merge (program-view-sites head.e locals) (program-view-sites-exprs args.e locals))
13148− %cast (program-view-sites val.e locals)
13149− %trace
13150− (program-view-sites-merge (program-view-sites val.e locals) (program-view-sites then.e locals))
13151− %branch
13152− (program-view-sites-merge (program-view-sites subject.e locals) (program-view-sites-arms arms.e locals))
13153− %body
13154− =/ nested=(list term) (weld (global-value-names defs.e) locals)
13155− (program-view-sites-merge (program-view-sites-defs defs.e nested) (program-view-sites final.e nested))
13156− * `~
13157− ==
13158−::
13159−++ program-union-tag-case
13160− |= [expected=itype tag=@]
13161− ^- (unit itype)
13162− ?. ?=(%union -.expected) ~
13163− =/ remaining=(list itype) cases.expected
13164− =/ found=(unit itype) ~
13165− =/ seen=(set @) *(set @)
13166− |-
13167− ?~ remaining found
13168− =/ case=itype i.remaining
13169− =/ head=(unit @)
13170− ?: ?=(%const -.case) `val.literal.case
13171− ?. ?=(%cell -.case) ~
13172− ?. ?=(%const -.hed.case) ~
13173− `val.literal.hed.case
13174− ?~ head ~
13175− ?: (~(has in:..zuse seen) u.head) ~
13176− =. seen (~(put in:..zuse seen) u.head)
13177− =? found =(tag u.head)
13178− ?^(found ~ `case)
13179− $(remaining t.remaining)
13180−::
13181−++ program-single-case-fit
13182− |= [actual=itype expected=itype sub=isub next=@ud]
13183− ^- ifit
13184− =. actual (itype-normalize actual sub)
13185− =. expected (itype-normalize expected sub)
13186− ?. ?=(%union -.expected) [%unknown ~]
13187− =/ found=(unit itype)
13188− ?: ?=(%const -.actual) `actual
13189− ?: ?=(%tag -.actual) `actual
13190− ?: ?=(%cell -.actual) `actual
13191− ?. ?=(%union -.actual) ~
13192− ?. ?=([* ~] cases.actual) ~
13193− `i.cases.actual
13194− ?~ found [%unknown ~]
13195− =/ case=itype u.found
13196− =/ tag=(unit lit)
13197− ?: ?=(%const -.case) `literal.case
13198− ?: ?=(%tag -.case) `literal.case
13199− ?. ?=(%cell -.case) ~
13200− =/ head=itype (projection-field-target hed.case)
13201− ?: ?=(%const -.head) `literal.head
13202− ?: ?=(%tag -.head) `literal.head
13203− ~
13204− ?~ tag [%unknown ~]
13205− =/ chosen=(unit itype) (program-union-tag-case expected val.u.tag)
13206− ?~ chosen [%unknown ~]
13207− ?: |(?=(%const -.case) ?=(%tag -.case))
13208− ?. ?=(%const -.u.chosen) [%unknown ~]
13209− (itype-fit case u.chosen sub next)
13210− ?. ?=(%cell -.case) [%unknown ~]
13211− ?. ?=(%cell -.u.chosen) [%unknown ~]
13212− =/ head-fit=ifit (itype-fit hed.case hed.u.chosen sub next)
13213− ?. ?=(%ok -.head-fit) head-fit
13214− (itype-fit tal.case tal.u.chosen sub.head-fit next.head-fit)
13215−::
13216−++ program-single-generic-fit
13217− |= [actual=itype expected=itype sub=isub next=@ud]
13218− ^- ifit
13219− =. actual (itype-normalize actual sub)
13220− =. expected (itype-normalize expected sub)
13221− ?. &(?=(%union -.actual) ?=(%union -.expected)) [%unknown ~]
13222− ?~ origin.actual [%unknown ~]
13223− ?. =(origin.actual origin.expected) [%unknown ~]
13224− ?. ?=([* ~] args.actual) [%unknown ~]
13225− ?. ?=([* ~] args.expected) [%unknown ~]
13226− =/ argument-fit=ifit (direct-invariant i.args.actual i.args.expected sub next)
13227− ?: ?=(%ok -.argument-fit) argument-fit
13228− (program-single-case-fit i.args.actual i.args.expected sub next)
13229−::
13230−++ program-keyed-product-fit
13231− |= [actual=itype expected=itype element=ischeme sub=isub next=@ud]
13232− ^- ifit
13233− =. actual (itype-normalize actual sub)
13234− =. expected (itype-normalize expected sub)
13235− ?. &(?=(%cell -.actual) ?=(%cell -.expected)) [%unknown ~]
13236− =/ key-fit=ifit
13237− (itype-fit (projection-field-target hed.actual) (projection-field-target hed.expected) sub next)
13238− ?. ?=(%ok -.key-fit) key-fit
13239− =/ actual-el=itype
13240− (itype-normalize (projection-field-target tal.actual) sub.key-fit)
13241− =/ expected-el=itype
13242− (itype-normalize (projection-field-target tal.expected) sub.key-fit)
13243− ?. &(?=(%union -.actual-el) ?=(%union -.expected-el)) [%unknown ~]
13244− ?. =(origin.actual-el origin.expected-el) [%unknown ~]
13245− ?. ?=([* ~] args.actual-el) [%unknown ~]
13246− ?. ?=([* ~] args.expected-el) [%unknown ~]
13247− =/ canonical-actual=(unit itype)
13248− (template-apply element ~[i.args.actual-el])
13249− =/ canonical-expected=(unit itype)
13250− (template-apply element ~[i.args.expected-el])
13251− ?~ canonical-actual [%unknown ~]
13252− ?~ canonical-expected [%unknown ~]
13253− =/ actual-check=ifit
13254− (direct-invariant actual-el u.canonical-actual sub.key-fit next.key-fit)
13255− ?. ?=(%ok -.actual-check) actual-check
13256− =/ expected-check=ifit
13257− (direct-invariant expected-el u.canonical-expected sub.actual-check next.actual-check)
13258− ?. ?=(%ok -.expected-check) expected-check
13259− =/ case-fit=ifit
13260− (program-single-case-fit i.args.actual-el i.args.expected-el sub.expected-check next.expected-check)
13261− case-fit
13262−::
13263−:: A direct view without a keyed each/turn site still needs the message type
13264−:: from the checked update. Recover only that closed component; final main
13265−:: checking remains the canonical program-kind boundary.
13266−++ program-plain-view-context
13267− |= [parts=[init=term update=term view=term subs=term] ds=(list def) resolution=iresolved initial=istate]
13268− ^- (unit iresolved)
13269− =/ env=ienv env.resolution
13270− ?^ (ienv-lookup %main env) ~
13271− ?^ (ienv-lookup view.parts env) ~
13272− =/ relation=(unit [message=itype model=itype])
13273− (program-update-relation update.parts ds env)
13274− ?~ relation ~
13275− =/ views=(list def)
13276− (skim ds |=(d=def &(?=(%value -.d) =(view.parts name.d))))
13277− ?. ?=([* ~] views) ~
13278− =/ view-def=def i.views
13279− ?> ?=(%value -.view-def)
13280− =/ written-view=(unit sample) (direct-gate-sample view-def)
13281− ?~ written-view ~
13282− =/ body=expr
13283− ?- -.val.view-def
13284− %gate body.val.view-def
13285− %gate-wide body.val.view-def
13286− * !!
13287− ==
13288− =/ sites=(unit (list iview-site)) (program-view-sites body ~)
13289− ?~ sites ~
13290− ?^ u.sites ~
13291− ?~ prelude.initial ~
13292− ?~ (ienv-lookup %program values.u.prelude.initial) ~
13293− =/ element=(unit ischeme) (find-jibb-mold %element u.prelude.initial)
13294− ?~ element ~
13295− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude.initial)
13296− ?~ heads ~
13297− ?~ (~(get by gates.u.heads) %program) ~
13298− =/ checked=(map term def) (direct-checked-gates ds env)
13299− =/ templates=ienv
13300− (turn molds.u.prelude.initial |=(x=[name=term template=ischeme] [name.x template.x]))
13301− =/ scanned=(unit dgscan)
13302− (dg-all-env-ids (weld env (weld values.u.prelude.initial templates)) 32.768 ~)
13303− ?~ scanned ~
13304− =. next.initial (dg-next-id ids.u.scanned 0)
13305− =/ view-state=istate (reserve-def-caps val.view-def initial)
13306− =/ sam=isample-result (infer-sample u.written-view env view-state)
13307− ?: ?=(%| -.sam) ~
13308− =/ actual-model=itype (program-inferred-sample typ.p.sam u.written-view)
13309− ?. ?=(~ (itype-vars actual-model)) ~
13310− ?: (itype-has-tag actual-model) ~
13311− =/ model-fit=ifit
13312− (direct-invariant actual-model model.u.relation sub.state.p.sam next.state.p.sam)
13313− ?. ?=(%ok -.model-fit) ~
13314− =/ product=(unit itype) (template-apply u.element ~[message.u.relation])
13315− ?~ product ~
13316− =/ st=istate
13317− state.p.sam(sub sub.model-fit, next next.model-fit, gate-defs checked, head-evidence heads)
13318− =/ inferred=iresult
13319− (infer-call-context-arg body u.product env.p.sam st (span-of body))
13320− ?: ?=(%| -.inferred) ~
13321− =/ product-fit=ifit
13322− (itype-fit typ.p.inferred u.product sub.state.p.inferred next.state.p.inferred)
13323− ?. ?=(%ok -.product-fit) ~
13324− =/ merged-product=itype
13325− (itype-merge-faces typ.p.inferred u.product sub.product-fit)
13326− =/ actual-cast=itype [%fn typ.p.sam merged-product]
13327− =/ closed=itype [%fn typ.p.sam u.product]
13328− =/ cast=ifit
13329− (itype-fit actual-cast closed sub.product-fit next.product-fit)
13330− ?. ?=(%ok -.cast) ~
13331− =/ merged=itype (itype-merge-faces actual-cast closed sub.cast)
13332− =/ adjusted=iresult
13333− [%& merged state.p.inferred(sub sub.cast, next next.cast)]
13334− =/ added=(unit iadded-definition)
13335− (add-supported-result view-def adjusted view-state env checked artifacts.resolution)
13336− ?~ added ~
13337− =/ recovered=(unit ischeme) (ienv-lookup view.parts env.u.added)
13338− ?~ recovered ~
13339− ?. ?=(~ vars.u.recovered) ~
13340− ?. ?=(~ (itype-vars typ.u.recovered)) ~
13341− `[env.u.added grouped.resolution artifacts.u.added]
13342−::
13343−:: Recover exactly one direct keyed each/turn row mapper, then its view.
13344−:: The prelude's own each and turn schemes determine the mapper gate: the
13345−:: key is inferred from the mapper body, never selected by this recovery.
13346−++ program-view-context
13347− |= [parts=[init=term update=term view=term subs=term] ds=(list def) resolution=iresolved initial=istate]
13348− ^- (unit iresolved)
13349− =/ env=ienv env.resolution
13350− ?^ (ienv-lookup %main env) ~
13351− ?^ (ienv-lookup view.parts env) ~
13352− =/ relation=(unit [message=itype model=itype])
13353− (program-update-relation update.parts ds env)
13354− ?~ relation ~
13355− =/ views=(list def)
13356− (skim ds |=(d=def &(?=(%value -.d) =(view.parts name.d))))
13357− ?. ?=([* ~] views) ~
13358− =/ view-def=def i.views
13359− ?> ?=(%value -.view-def)
13360− =/ written-view=(unit sample) (direct-gate-sample view-def)
13361− ?~ written-view ~
13362− =/ view-body=expr
13363− ?- -.val.view-def
13364− %gate body.val.view-def
13365− %gate-wide body.val.view-def
13366− * !!
13367− ==
13368− =/ sites=(unit (list iview-site)) (program-view-sites view-body ~)
13369− ?~ sites ~
13370− ?. ?=([* ~] u.sites) ~
13371− =/ site=iview-site i.u.sites
13372− =/ component-names=(list term) ~[init.parts update.parts view.parts subs.parts]
13373− ?: (lien component-names |=(n=term =(n mapper.site))) ~
13374− ?^ (ienv-lookup mapper.site env) ~
13375− =/ mappers=(list def)
13376− (skim ds |=(d=def &(?=(%value -.d) =(mapper.site name.d))))
13377− ?. ?=([* ~] mappers) ~
13378− =/ mapper-def=def i.mappers
13379− ?> ?=(%value -.mapper-def)
13380− =/ written-mapper=(unit sample) (direct-gate-sample mapper-def)
13381− ?~ written-mapper ~
13382− ?~ prelude.initial ~
13383− =/ program=(unit ischeme) (ienv-lookup %program values.u.prelude.initial)
13384− =/ each-scheme=(unit ischeme) (ienv-lookup %each values.u.prelude.initial)
13385− =/ turn-scheme=(unit ischeme) (ienv-lookup %turn values.u.prelude.initial)
13386− =/ element=(unit ischeme) (find-jibb-mold %element u.prelude.initial)
13387− =/ list-template=(unit ischeme) (find-jibb-mold %list u.prelude.initial)
13388− ?~ program ~
13389− ?~ each-scheme ~
13390− ?~ turn-scheme ~
13391− ?~ element ~
13392− ?~ list-template ~
13393− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude.initial)
13394− ?~ heads ~
13395− =/ written-program=(unit def) (~(get by gates.u.heads) %program)
13396− =/ written-each=(unit def) (~(get by gates.u.heads) %each)
13397− =/ written-turn=(unit def) (~(get by gates.u.heads) %turn)
13398− ?~ written-program ~
13399− ?~ written-each ~
13400− ?~ written-turn ~
13401− =/ program-sample=(unit sample) (direct-gate-sample u.written-program)
13402− =/ each-sample=(unit sample) (direct-gate-sample u.written-each)
13403− =/ turn-sample=(unit sample) (direct-gate-sample u.written-turn)
13404− ?~ program-sample ~
13405− ?~ each-sample ~
13406− ?~ turn-sample ~
13407− ?. ?=(%cell -.u.program-sample) ~
13408− ?. ?=([* * * * ~] items.u.program-sample) ~
13409− =/ turn-names=(unit [first=(unit term) second=(unit term)])
13410− (program-two-slot-names u.turn-sample)
13411− ?~ turn-names ~
13412− =/ checked=(map term def) (direct-checked-gates ds env)
13413− =/ templates=ienv
13414− (turn molds.u.prelude.initial |=(x=[name=term template=ischeme] [name.x template.x]))
13415− =/ scanned=(unit dgscan)
13416− (dg-all-env-ids (weld env (weld values.u.prelude.initial templates)) 32.768 ~)
13417− ?~ scanned ~
13418− =. next.initial (dg-next-id ids.u.scanned 0)
13419− =/ view-state=istate (reserve-def-caps val.view-def initial)
13420− =/ sam=isample-result (infer-sample u.written-view env view-state)
13421− ?: ?=(%| -.sam) ~
13422− =/ actual-model=itype (program-inferred-sample typ.p.sam u.written-view)
13423− =/ model-fit=ifit
13424− (direct-invariant actual-model model.u.relation sub.state.p.sam next.state.p.sam)
13425− ?. ?=(%ok -.model-fit) ~
13426− =/ xs-result=iresult
13427− (infer-fragment xs.site env.p.sam state.p.sam(sub sub.model-fit, next next.model-fit))
13428− ?: ?=(%| -.xs-result) ~
13429− =/ element-var=itype [%var next.state.p.xs-result]
13430− =/ list-a=(unit itype) (template-apply u.list-template ~[element-var])
13431− ?~ list-a ~
13432− =/ xs-fit=ifit
13433− (itype-fit typ.p.xs-result u.list-a sub.state.p.xs-result +(next.state.p.xs-result))
13434− ?. ?=(%ok -.xs-fit) ~
13435− =/ closed-xs=itype (itype-normalize u.list-a sub.xs-fit)
13436− ?^ (itype-vars closed-xs) ~
13437− ?: (itype-has-tag closed-xs) ~
13438− =/ each-instance=[typ=itype state=istate]
13439− (instantiate-scheme u.each-scheme state.p.xs-result(sub sub.xs-fit, next next.xs-fit))
13440− ?. ?=(%fn -.typ.each-instance) ~
13441− =/ turn-instance=[typ=itype state=istate]
13442− (instantiate-scheme u.turn-scheme state.each-instance)
13443− ?. ?=(%fn -.typ.turn-instance) ~
13444− ?. ?=(%cell -.sample.typ.turn-instance) ~
13445− =/ element-message=(unit itype)
13446− (template-apply u.element ~[message.u.relation])
13447− ?~ element-message ~
13448− =/ each-fit=ifit
13449− (itype-fit product.typ.each-instance u.element-message sub.state.turn-instance next.state.turn-instance)
13450− ?. ?=(%ok -.each-fit) ~
13451− =/ each-input=itype
13452− (program-inferred-sample sample.typ.each-instance u.each-sample)
13453− =/ turn-fit=ifit
13454− (itype-fit product.typ.turn-instance each-input sub.each-fit next.each-fit)
13455− ?. ?=(%ok -.turn-fit) ~
13456− =/ turn-list=itype
13457− (program-inferred-slot hed.sample.typ.turn-instance first.u.turn-names)
13458− =/ list-fit=ifit
13459− (itype-fit closed-xs turn-list sub.turn-fit next.turn-fit)
13460− ?. ?=(%ok -.list-fit) ~
13461− =/ mapper-type=itype
13462− (program-inferred-slot tal.sample.typ.turn-instance second.u.turn-names)
13463− =/ expected-mapper=itype (itype-normalize mapper-type sub.list-fit)
13464− ?. ?=(%fn -.expected-mapper) ~
13465− ?^ (itype-vars sample.expected-mapper) ~
13466− ?: (itype-has-tag sample.expected-mapper) ~
13467− :: These faces come from the source-backed each sample. Keeping them in
13468− :: the expected mapper product lets ordinary tuple inference supply key/el.
13469− ?. ?=(%cell -.product.expected-mapper) ~
13470− ?. ?=(%face -.hed.product.expected-mapper) ~
13471− ?. =(%key name.hed.product.expected-mapper) ~
13472− ?. ?=(%face -.tal.product.expected-mapper) ~
13473− ?. =(%el name.tal.product.expected-mapper) ~
13474− =/ mapper-state=istate
13475− (reserve-def-caps val.mapper-def initial(next next.list-fit))
13476− =/ mapper-sam=isample-result (infer-sample u.written-mapper env mapper-state)
13477− ?: ?=(%| -.mapper-sam) ~
13478− =/ mapper-input=itype (program-inferred-sample typ.p.mapper-sam u.written-mapper)
13479− =/ mapper-sample-fit=ifit
13480− (direct-invariant mapper-input sample.expected-mapper sub.state.p.mapper-sam next.state.p.mapper-sam)
13481− ?. ?=(%ok -.mapper-sample-fit) ~
13482− =/ mapper-product=itype
13483− (itype-normalize product.expected-mapper sub.mapper-sample-fit)
13484− =/ mapper-body=expr
13485− ?- -.val.mapper-def
13486− %gate body.val.mapper-def
13487− %gate-wide body.val.mapper-def
13488− * !!
13489− ==
13490− =/ mapper-inferred=iresult
13491− (infer-call-context-arg mapper-body mapper-product env.p.mapper-sam state.p.mapper-sam(sub sub.mapper-sample-fit, next next.mapper-sample-fit) (span-of mapper-body))
13492− ?: ?=(%| -.mapper-inferred) ~
13493− =/ ordinary-product-fit=ifit
13494− (itype-fit typ.p.mapper-inferred mapper-product sub.state.p.mapper-inferred next.state.p.mapper-inferred)
13495− =/ mapper-product-fit=ifit
13496− ?: ?=(%ok -.ordinary-product-fit) ordinary-product-fit
13497− (program-keyed-product-fit typ.p.mapper-inferred mapper-product u.element sub.state.p.mapper-inferred next.state.p.mapper-inferred)
13498− ?. ?=(%ok -.mapper-product-fit) ~
13499− =/ closed-mapper-product=itype
13500− (itype-normalize mapper-product sub.mapper-product-fit)
13501− ?^ (itype-vars closed-mapper-product) ~
13502− ?: (itype-has-tag closed-mapper-product) ~
13503− =/ merged-mapper-product=itype
13504− (itype-merge-faces typ.p.mapper-inferred closed-mapper-product sub.mapper-product-fit)
13505− =/ mapper-cast=itype [%fn typ.p.mapper-sam merged-mapper-product]
13506− =/ closed-mapper=itype [%fn typ.p.mapper-sam closed-mapper-product]
13507− =/ mapper-cast-fit=ifit
13508− (itype-fit mapper-cast closed-mapper sub.mapper-product-fit next.mapper-product-fit)
13509− ?. ?=(%ok -.mapper-cast-fit) ~
13510− =/ merged-mapper=itype
13511− (itype-merge-faces mapper-cast closed-mapper sub.mapper-cast-fit)
13512− =/ mapper-adjusted=iresult
13513− [%& merged-mapper state.p.mapper-inferred(sub sub.mapper-cast-fit, next next.mapper-cast-fit)]
13514− =/ mapper-added=(unit iadded-definition)
13515− (add-supported-result mapper-def mapper-adjusted mapper-state env checked artifacts.resolution)
13516− ?~ mapper-added ~
13517− =/ mapper-scheme=(unit ischeme) (ienv-lookup mapper.site env.u.mapper-added)
13518− ?~ mapper-scheme ~
13519− ?. ?=(~ vars.u.mapper-scheme) ~
13520− ?. ?=(~ (itype-vars typ.u.mapper-scheme)) ~
13521− =/ program-instance=[typ=itype state=istate]
13522− (instantiate-scheme u.program state.p.sam(next next.mapper-cast-fit))
13523− ?. ?=(%fn -.typ.program-instance) ~
13524− ?. ?=(%cell -.sample.typ.program-instance) ~
13525− ?. ?=(%cell -.tal.sample.typ.program-instance) ~
13526− ?. ?=(%cell -.tal.tal.sample.typ.program-instance) ~
13527− =/ expected-view=(unit itype)
13528− (direct-slot-body hed.tal.tal.sample.typ.program-instance (direct-sample-name i.t.t.items.u.program-sample))
13529− ?~ expected-view ~
13530− ?. ?=(%fn -.u.expected-view) ~
13531− =/ canonical-view=itype [%fn model.u.relation u.element-message]
13532− =/ view-fit=ifit
13533− (direct-invariant canonical-view u.expected-view sub.state.program-instance next.state.program-instance)
13534− ?. ?=(%ok -.view-fit) ~
13535− =/ closed-view=itype
13536− (itype-normalize [%fn typ.p.sam u.element-message] sub.view-fit)
13537− ?. ?=(%fn -.closed-view) ~
13538− =/ view-env=ienv [[mapper.site u.mapper-scheme] env.p.sam]
13539− =/ final-view-state=istate
13540− (reserve-def-caps val.view-def state.p.sam(next next.view-fit, gate-defs checked.u.mapper-added, head-evidence heads))
13541− =/ inferred=iresult
13542− (infer-call-context-arg view-body product.closed-view view-env final-view-state (span-of view-body))
13543− ?: ?=(%| -.inferred) ~
13544− =/ product-fit=ifit
13545− (itype-fit typ.p.inferred product.closed-view sub.state.p.inferred next.state.p.inferred)
13546− ?. ?=(%ok -.product-fit) ~
13547− =/ merged-product=itype
13548− (itype-merge-faces typ.p.inferred product.closed-view sub.product-fit)
13549− =/ actual-cast=itype [%fn typ.p.sam merged-product]
13550− =/ cast=ifit
13551− (itype-fit actual-cast closed-view sub.product-fit next.product-fit)
13552− ?. ?=(%ok -.cast) ~
13553− =/ merged=itype (itype-merge-faces actual-cast closed-view sub.cast)
13554− =/ adjusted=iresult
13555− [%& merged state.p.inferred(sub sub.cast, next next.cast)]
13556− =/ added=(unit iadded-definition)
13557− (add-supported-result view-def adjusted final-view-state env.u.mapper-added checked.u.mapper-added artifacts.u.mapper-added)
13558− ?~ added ~
13559− =/ recovered=(unit ischeme) (ienv-lookup view.parts env.u.added)
13560− ?~ recovered ~
13561− ?. ?=(~ vars.u.recovered) ~
13562− ?. ?=(~ (itype-vars typ.u.recovered)) ~
13563− `[env.u.added grouped.resolution artifacts.u.added]
13564−::
13565−++ program-init-null-sample
13566− |= d=def
13567− ^- ?
13568− =/ written=(unit sample) (direct-gate-sample d)
13569− ?~ written |
13570− ?. ?=(%bare -.u.written) |
13571− =/ sh=shape shape.u.written
13572− ?. ?=(%const -.sh) |
13573− =(%null form.lit.sh)
13574−::
13575−:: The tuple-ending-null initializer retry above intentionally keeps its own
13576−:: boundary. A direct null-sample initializer can instead receive the closed
13577−:: model already established by update, view and subscriptions.
13578−++ program-plain-init-context
13579− |= [parts=[init=term update=term view=term subs=term] ds=(list def) resolution=iresolved initial=istate]
13580− ^- (unit iresolved)
13581− =/ env=ienv env.resolution
13582− ?^ (ienv-lookup %main env) ~
13583− ?^ (ienv-lookup init.parts env) ~
13584− ?~ (ienv-lookup update.parts env) ~
13585− ?~ (ienv-lookup view.parts env) ~
13586− ?~ (ienv-lookup subs.parts env) ~
13587− =/ relation=(unit [message=itype model=itype])
13588− (program-update-relation update.parts ds env)
13589− ?~ relation ~
13590− =/ inits=(list def)
13591− (skim ds |=(d=def &(?=(%value -.d) =(init.parts name.d))))
13592− ?. ?=([* ~] inits) ~
13593− =/ init-def=def i.inits
13594− ?> ?=(%value -.init-def)
13595− ?. (program-init-null-sample init-def) ~
13596− =/ written=(unit sample) (direct-gate-sample init-def)
13597− ?~ written ~
13598− =/ body=expr
13599− ?- -.val.init-def
13600− %gate body.val.init-def
13601− %gate-wide body.val.init-def
13602− * !!
13603− ==
13604− ?~ prelude.initial ~
13605− ?~ (ienv-lookup %program values.u.prelude.initial) ~
13606− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude.initial)
13607− ?~ heads ~
13608− ?~ (~(get by gates.u.heads) %program) ~
13609− =/ checked=(map term def) (direct-checked-gates ds env)
13610− =/ templates=ienv
13611− (turn molds.u.prelude.initial |=(x=[name=term template=ischeme] [name.x template.x]))
13612− =/ scanned=(unit dgscan)
13613− (dg-all-env-ids (weld env (weld values.u.prelude.initial templates)) 32.768 ~)
13614− ?~ scanned ~
13615− =. next.initial (dg-next-id ids.u.scanned 0)
13616− =/ init-state=istate (reserve-def-caps val.init-def initial)
13617− =/ sam=isample-result (infer-sample u.written env init-state)
13618− ?: ?=(%| -.sam) ~
13619− ?. ?=(~ (itype-vars typ.p.sam)) ~
13620− ?: (itype-has-tag typ.p.sam) ~
13621− =/ st=istate state.p.sam(gate-defs checked, head-evidence heads)
13622− =/ inferred=iresult
13623− (infer-call-context-arg body model.u.relation env.p.sam st (span-of body))
13624− ?: ?=(%| -.inferred) ~
13625− =/ product-fit=ifit
13626− (itype-fit typ.p.inferred model.u.relation sub.state.p.inferred next.state.p.inferred)
13627− ?. ?=(%ok -.product-fit) ~
13628− =/ merged-product=itype
13629− (itype-merge-faces typ.p.inferred model.u.relation sub.product-fit)
13630− =/ actual-cast=itype [%fn typ.p.sam merged-product]
13631− =/ closed=itype [%fn typ.p.sam model.u.relation]
13632− =/ cast=ifit
13633− (itype-fit actual-cast closed sub.product-fit next.product-fit)
13634− ?. ?=(%ok -.cast) ~
13635− =/ merged=itype (itype-merge-faces actual-cast closed sub.cast)
13636− =/ adjusted=iresult
13637− [%& merged state.p.inferred(sub sub.cast, next next.cast)]
13638− =/ added=(unit iadded-definition)
13639− (add-supported-result init-def adjusted init-state env checked artifacts.resolution)
13640− ?~ added ~
13641− =/ recovered=(unit ischeme) (ienv-lookup init.parts env.u.added)
13642− ?~ recovered ~
13643− ?. ?=(~ vars.u.recovered) ~
13644− ?. ?=(~ (itype-vars typ.u.recovered)) ~
13645− `[env.u.added grouped.resolution artifacts.u.added]
13646−::
13647−:: Recover only the initializer of an already recognized direct program main.
13648−:: The derived call is evidence for an ordinary init/main retry, never an
13649−:: interface to publish on its own. Any failure returns the original resolution.
13650−++ program-init-context
13651− |= [main=def parts=[init=term update=term view=term subs=term] ds=(list def) resolution=iresolved initial=istate]
13652− ^- (unit iresolved)
13653− =/ env=ienv env.resolution
13654− ?^ (ienv-lookup %main env) ~
13655− ?^ (ienv-lookup init.parts env) ~
13656− =/ update=(unit ischeme) (ienv-lookup update.parts env)
13657− =/ view=(unit ischeme) (ienv-lookup view.parts env)
13658− =/ subs=(unit ischeme) (ienv-lookup subs.parts env)
13659− ?~ update ~
13660− ?~ view ~
13661− ?~ subs ~
13662− =/ inits=(list def)
13663− (skim ds |=(d=def &(?=(%value -.d) =(init.parts name.d))))
13664− ?. ?=([* ~] inits) ~
13665− =/ init-def=def i.inits
13666− ?> ?=(%value -.init-def)
13667− ?. (program-init-tuple-null init-def) ~
13668− =/ args=(unit (list expr)) (program-main-args main)
13669− ?~ args ~
13670− ?~ prelude.initial ~
13671− =/ program=(unit ischeme) (ienv-lookup %program values.u.prelude.initial)
13672− ?~ program ~
13673− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude.initial)
13674− ?~ heads ~
13675− =/ written=(unit def) (~(get by gates.u.heads) %program)
13676− ?~ written ~
13677− =/ written-sample=(unit sample) (direct-gate-sample u.written)
13678− ?~ written-sample ~
13679− ?. ?=(%cell -.u.written-sample) ~
13680− ?~ items.u.written-sample ~
13681− =/ checked=(map term def) (direct-checked-gates ds env)
13682− =/ templates=ienv
13683− (turn molds.u.prelude.initial |=(x=[name=term template=ischeme] [name.x template.x]))
13684− =/ scanned=(unit dgscan)
13685− (dg-all-env-ids (weld env (weld values.u.prelude.initial templates)) 32.768 ~)
13686− ?~ scanned ~
13687− =. next.initial (dg-next-id ids.u.scanned 0)
13688− =/ instance=[typ=itype state=istate] (instantiate-scheme u.program initial)
13689− ?. ?=(%fn -.typ.instance) ~
13690− ?. ?=(%cell -.sample.typ.instance) ~
13691− =/ expected-init=(unit itype)
13692− (direct-slot-body hed.sample.typ.instance (direct-sample-name i.items.u.written-sample))
13693− ?~ expected-init ~
13694− ?. ?=(%fn -.u.expected-init) ~
13695− ?. ?=(%var -.sample.u.expected-init) ~
13696− =/ data=@ud id.sample.u.expected-init
13697− =/ init-var=itype [%var next.state.instance]
13698− =/ st=istate state.instance(next +(next.state.instance))
13699− =/ up=[typ=itype state=istate] (instantiate-scheme u.update st)
13700− =/ vw=[typ=itype state=istate] (instantiate-scheme u.view state.up)
13701− =/ sb=[typ=itype state=istate] (instantiate-scheme u.subs state.vw)
13702− =. st state.sb(gate-defs checked, head-evidence heads)
13703− =/ actual=itype [%cell init-var [%cell typ.up [%cell typ.vw typ.sb]]]
13704− =/ fit=ifit
13705− (direct-positional-fit u.args items.u.written-sample actual sample.typ.instance env st sub.st next.st)
13706− ?. ?=(%ok -.fit) ~
13707− =/ actual-final=itype (itype-normalize actual sub.fit)
13708− =/ expected-final=itype (itype-normalize sample.typ.instance sub.fit)
13709− =/ open=(list @ud)
13710− (unique-type-vars (weld (itype-vars actual-final) (itype-vars expected-final)))
13711− ?. (levy open |=(n=@ud =(data n))) ~
13712− ?: |((itype-has-tag actual-final) (itype-has-tag expected-final)) ~
13713− =/ replay=ifit
13714− (direct-positional-fit u.args items.u.written-sample actual sample.typ.instance env st sub.fit next.fit)
13715− ?. ?=(%ok -.replay) ~
13716− ?. &(=(sub.fit sub.replay) =(next.fit next.replay)) ~
13717− =/ expected=itype (itype-normalize u.expected-init sub.fit)
13718− ?. ?=(%fn -.expected) ~
13719− =. st st(sub sub.fit, next next.fit)
13720− =/ init-state=istate (reserve-def-caps val.init-def st)
13721− =/ inferred=iresult (infer-fragment val.init-def env init-state)
13722− =? inferred ?=(%| -.inferred) (infer-recursive-gate init-def env init-state)
13723− ?: ?=(%| -.inferred) ~
13724− ?. ?=(%fn -.typ.p.inferred) ~
13725− =/ data-fit=ifit
13726− (itype-fit sample.typ.p.inferred sample.expected sub.state.p.inferred next.state.p.inferred)
13727− ?. ?=(%ok -.data-fit) ~
13728− =/ closed=itype (itype-normalize expected sub.data-fit)
13729− ?. ?=(%fn -.closed) ~
13730− :: Resolve the ordinary tuple cast first, then check the complete gate.
13731− :: General function fit remains unchanged; only this recovered candidate
13732− :: receives the derived result context before its whole-type cast fit.
13733− =/ product-fit=ifit
13734− (itype-fit product.typ.p.inferred product.closed sub.data-fit next.data-fit)
13735− ?. ?=(%ok -.product-fit) ~
13736− =/ product=itype
13737− (itype-merge-faces product.typ.p.inferred product.closed sub.product-fit)
13738− =/ actual-cast=itype [%fn sample.typ.p.inferred product]
13739− =/ cast=ifit
13740− (itype-fit actual-cast closed sub.product-fit next.product-fit)
13741− ?. ?=(%ok -.cast) ~
13742− =/ merged=itype (itype-merge-faces actual-cast closed sub.cast)
13743− =/ adjusted=iresult
13744− [%& merged state.p.inferred(sub sub.cast, next next.cast)]
13745− =/ added=(unit iadded-definition)
13746− (add-supported-result init-def adjusted init-state env checked artifacts.resolution)
13747− ?~ added ~
13748− =/ recovered=(unit ischeme) (ienv-lookup init.parts env.u.added)
13749− ?~ recovered ~
13750− ?. ?=(~ vars.u.recovered) ~
13751− ?. ?=(~ (itype-vars typ.u.recovered)) ~
13752− `[env.u.added grouped.resolution artifacts.u.added]
13753−::
13754−++ store-derived-schemes
13755− |= [prelude=ifile values=(list term) molds=(list term) state=itype action=itype]
13756− ^- (unit [state=ischeme action=ischeme])
13757− =/ prep=iprelude [prelude values molds]
13758− =/ ask=(unit ischeme) (request-compatible-ask prep)
13759− ?~ ask ~
13760− =/ poke=(unit ischeme) (store-compatible-poke prep)
13761− ?~ poke ~
13762− ?^ (itype-vars state) ~
13763− ?^ (itype-vars action) ~
13764− ?: |((itype-has-tag state) (itype-has-tag action)) ~
13765− =/ result=(unit itype) (template-apply u.ask ~[[%var 0]])
13766− ?~ result ~
13767− =/ request=ischeme [[%fn [%fn state [%var 0]] u.result] ~[0]]
13768− =/ constructor=ischeme [[%fn action typ.u.poke] ~]
13769− `[request constructor]
13770−::
13771−++ program-subs-watch
13772− |= [d=def imports=ijimports graph=irequest-graph prelude=ifile]
13773− ^- ?
13774− ?. ?=(%value -.d) |
13775− ?. |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) |
13776− =/ body=expr
13777− ?- -.val.d
13778− %gate body.val.d
13779− %gate-wide body.val.d
13780− * val.d
13781− ==
13782− =. body (program-transparent body)
13783− ?. ?=(%list -.body) |
13784− ?. ?=([* ~] items.body) |
13785− =/ watch=expr (program-transparent i.items.body)
13786− ?. ?=(%tuple -.watch) |
13787− ?. ?=([* * ~] items.watch) |
13788− =/ tag=item i.items.watch
13789− =/ payload=item i.t.items.watch
13790− ?. &(?=(~ face.tag) ?=(~ face.payload)) |
13791− =/ tag-expr=expr (program-transparent val.tag)
13792− ?. ?=(%lit -.tag-expr) |
13793− ?. &(?=(%term form.lit.tag-expr) =(%watch val.lit.tag-expr)) |
13794− =/ request=expr (program-transparent val.payload)
13795− ?. ?=(%call -.request) |
13796− ?. ?=([* ~] args.request) |
13797− =/ head=expr (program-transparent head.request)
13798− ?. ?=(%wing -.head) |
13799− ?. ?=([@ @ ~] names.head) |
13800− =/ case=term i.names.head
13801− =/ face=term i.t.names.head
13802− =/ callback=expr (program-transparent i.args.request)
13803− ?. ?=(%ctor -.callback) |
13804− ?. ?=(%term form.tag.callback) |
13805− ?| ?=(^ (derived-request-member case face imports graph prelude))
13806− ?=(^ (derived-store-request-member case face imports graph prelude))
13807− ==
13808−::
13809−:: Exact derived-member and request-evidence identity, shared by direct
13810−:: program watches and direct data-page loads. Only a plain request in the
13811−:: selected interface's own source-backed graph can establish this shape.
13812−++ derived-request-member
13813− |= [case=term face=term imports=ijimports graph=irequest-graph prelude=ifile]
13814− ^- (unit ischeme)
13815− =/ selected=(list [face=term interface=ifile])
13816− (skim imports |=(j=[face=term interface=ifile] =(face face.j)))
13817− ?. ?=([* ~] selected) ~
13818− =/ iface=ifile interface.i.selected
13819− =/ member=(unit ischeme) (ienv-lookup case values.iface)
13820− ?~ member ~
13821− ?~ source.iface ~
13822− =/ evidence=(list irequest-evidence)
13823− (skim requests.graph |=(r=irequest-evidence &(=(api-at.r at.iface) =(name.r case))))
13824− ?. ?=([* ~] evidence) ~
13825− =/ request-evidence=irequest-evidence i.evidence
13826− ?. =(u.source.iface api-source.request-evidence) ~
13827− ?. =(name.path.path.request-evidence case) ~
13828− ?~ graph.iface ~
13829− ?. (lien requests.u.graph.iface |=(r=irequest-evidence =(r request-evidence))) ~
13830− ?. ?=(~ scry.path.path.request-evidence) ~
13831− ?. &(?=(~ diffs.path.request-evidence) ?=(~ diffs.path.path.request-evidence)) ~
13832− ?: (lien segments.path.path.request-evidence |=(p=pseg !?=(%knot -.p))) ~
13833− ?. ?=([@ ~] vars.u.member) ~
13834− =/ message=@ud i.vars.u.member
13835− ?. ?=(%fn -.typ.u.member) ~
13836− ?. ?=(%fn -.sample.typ.u.member) ~
13837− ?. =(sample.sample.typ.u.member full.path.request-evidence) ~
13838− ?. =(product.sample.typ.u.member [%var message]) ~
13839− =/ prep=iprelude [prelude prelude-values.graph prelude-molds.graph]
13840− =/ ask=(unit ischeme) (request-compatible-ask prep)
13841− ?~ ask ~
13842− =/ result=(unit itype) (template-apply u.ask ~[[%var message]])
13843− ?~ result ~
13844− ?. =(product.typ.u.member u.result) ~
13845− member
13846−::
13847−:: Store state is watchable by definition, but only the actual derived member
13848−:: of the uniquely selected source-bound store interface proves that fact.
13849−++ derived-store-request-member
13850− |= [case=term face=term imports=ijimports graph=irequest-graph prelude=ifile]
13851− ^- (unit ischeme)
13852− ?. =(%state case) ~
13853− =/ selected=(list [face=term interface=ifile])
13854− (skim imports |=(j=[face=term interface=ifile] =(face face.j)))
13855− ?. ?=([* ~] selected) ~
13856− =/ iface=ifile interface.i.selected
13857− =/ member=(unit ischeme) (ienv-lookup %state values.iface)
13858− ?~ member ~
13859− ?~ source.iface ~
13860− =/ evidence=(list istore-request-evidence)
13861− (skim stores.graph |=(r=istore-request-evidence =(store-at.r at.iface)))
13862− ?. ?=([* ~] evidence) ~
13863− =/ request=istore-request-evidence i.evidence
13864− ?. =(u.source.iface source.request) ~
13865− ?~ graph.iface ~
13866− ?. (lien stores.u.graph.iface |=(r=istore-request-evidence =(r request))) ~
13867− =/ derived=(unit [state=ischeme action=ischeme])
13868− (store-derived-schemes prelude prelude-values.graph prelude-molds.graph state.request action.request)
13869− ?~ derived ~
13870− ?. =(u.member state.u.derived) ~
13871− =/ constructor=(unit ischeme) (ienv-lookup action-name.request values.iface)
13872− ?~ constructor ~
13873− ?. =(u.constructor action.u.derived) ~
13874− member
13875−::
13876−++ program-main-context
13877− |= [main=def ds=(list def) resolution=iresolved initial=istate]
13878− ^- iresolved
13879− ?^ (ienv-lookup %main env.resolution) resolution
13880− =/ heads=(unit igate-prelude-evidence)
13881− (direct-prelude-evidence ds prelude.initial)
13882− ?~ heads resolution
13883− =/ checked=(map term def) (direct-checked-gates ds env.resolution)
13884− =/ completed=[env=ienv artifacts=(list iwidth-definition)]
13885− (add-supported-defs-core ~[main] ds checked heads env.resolution molds.initial globals.initial externals.initial surs.initial mark-externals.initial marks.initial jimports.initial reserved-molds.initial at.initial prelude.initial artifacts.resolution grec-index.initial)
13886− [env.completed grouped.resolution artifacts.completed]
13887−::
13888−:: A static main may retain a generic element message in its ordinary
13889−:: scheme. Instantiate that scheme, specialize it to canonical element !!,
13890−:: and publish only the resulting closed scheme.
13891−++ static-main-specialized
13892− |= [env=ienv prelude=(unit ifile)]
13893− ^- (unit ischeme)
13894− ?~ prelude ~
13895− =/ element=(unit ischeme) (find-jibb-mold %element u.prelude)
13896− ?~ element ~
13897− =/ main=(unit ischeme) (ienv-lookup %main env)
13898− ?~ main ~
13899− =/ canonical=(unit itype) (template-apply u.element ~[[%empty ~]])
13900− ?~ canonical ~
13901− =/ instance=[typ=itype state=istate] (instantiate-scheme u.main *istate)
13902− =/ fit=ifit (itype-fit typ.instance u.canonical ~ next.state.instance)
13903− ?. ?=(%ok -.fit) ~
13904− =/ closed=itype (itype-normalize typ.instance sub.fit)
13905− ?^ (itype-vars closed) ~
13906− ?: (itype-has-tag closed) ~
13907− ?. ?=(%union -.closed) ~
13908− ?. ?=(%union -.u.canonical) ~
13909− ?. &(=(origin.closed origin.u.canonical) =(args.closed args.u.canonical)) ~
13910− =/ exact=ifit (direct-invariant closed u.canonical ~ next.fit)
13911− ?. ?=(%ok -.exact) ~
13912− `[u.canonical ~]
13913−::
13914−:: The load of a direct data page must itself be a direct gate whose
13915−:: transparent body is one plain derived request with a wing or ctor reply.
13916−++ page-load-derived
13917− |= [name=term ds=(list def) imports=ijimports graph=irequest-graph prelude=ifile]
13918− ^- ?
13919− =/ loads=(list def)
13920− (skim ds |=(d=def &(?=(%value -.d) =(name name.d))))
13921− ?. ?=([* ~] loads) |
13922− =/ load=def i.loads
13923− ?> ?=(%value -.load)
13924− ?. |(?=(%gate -.val.load) ?=(%gate-wide -.val.load)) |
13925− =/ body=expr
13926− ?- -.val.load
13927− %gate body.val.load
13928− %gate-wide body.val.load
13929− * !!
13930− ==
13931− =. body (program-transparent body)
13932− ?. ?=(%call -.body) |
13933− ?. ?=([* ~] args.body) |
13934− =/ head=expr (program-transparent head.body)
13935− ?. ?=(%wing -.head) |
13936− ?. ?=([@ @ ~] names.head) |
13937− =/ reply=expr (program-transparent i.args.body)
13938− ?. ?| &(?=(%wing -.reply) ?=([@ ~] names.reply))
13939− &(?=(%ctor -.reply) ?=(%term form.tag.reply))
13940− ==
13941− |
13942− ?=(^ (derived-request-member i.names.head i.t.names.head imports graph prelude))
13943−::
13944−++ page-main-closed
13945− |= [parts=[load=term view=term] ds=(list def) env=ienv prelude=(unit ifile) imports=ijimports graph=irequest-graph]
13946− ^- ?
13947− ?~ prelude |
13948− =/ page=(unit ischeme) (find-jibb-mold %page u.prelude)
13949− ?~ page |
13950− =/ main=(unit ischeme) (ienv-lookup %main env)
13951− ?~ main |
13952− ?. ?=(~ vars.u.main) |
13953− ?. ?=(~ (itype-vars typ.u.main)) |
13954− =/ instance=[typ=itype state=istate] (instantiate-scheme u.page *istate)
13955− =/ main-fit=ifit (direct-invariant typ.u.main typ.instance ~ next.state.instance)
13956− ?. ?=(%ok -.main-fit) |
13957− (page-load-derived load.parts ds imports graph u.prelude)
13958−::
13959−++ program-main-closed
13960− |= [parts=[init=term update=term view=term subs=term] ds=(list def) env=ienv prelude=(unit ifile) imports=ijimports graph=irequest-graph]
13961− ^- ?
13962− ?~ prelude |
13963− ?~ (ienv-lookup %program values.u.prelude) |
13964− =/ program=(unit ischeme) (find-jibb-mold %program u.prelude)
13965− ?~ program |
13966− =/ main=(unit ischeme) (ienv-lookup %main env)
13967− ?~ main |
13968− ?. ?=(~ vars.u.main) |
13969− ?. ?=(~ (itype-vars typ.u.main)) |
13970− =/ instance=[typ=itype state=istate] (instantiate-scheme u.program *istate)
13971− =/ main-fit=ifit (direct-invariant typ.u.main typ.instance ~ next.state.instance)
13972− ?. ?=(%ok -.main-fit) |
13973− =/ init=(unit ischeme) (ienv-lookup init.parts env)
13974− ?~ init |
13975− ?. ?=(~ vars.u.init) |
13976− ?. ?=(%fn -.typ.u.init) |
13977− ?. ?=(~ (itype-vars sample.typ.u.init)) |
13978− ?. ?=(~ (itype-vars product.typ.u.init)) |
13979− =/ data=igate-free (gate-free-type sample.typ.u.init 256 ~)
13980− ?. =(%yes verdict.data) |
13981− =/ model=igate-free (gate-free-type product.typ.u.init left.data ~)
13982− ?. =(%yes verdict.model) |
13983− =/ subs=(list def)
13984− (skim ds |=(d=def &(?=(%value -.d) =(subs.parts name.d))))
13985− ?. ?=([* ~] subs) |
13986− |((program-subs-empty i.subs) (program-subs-watch i.subs imports graph u.prelude))
13987−::
13988−:: The two outer sample faces are binder names, not part of the action/state
13989−:: relation. Leave every face inside either component untouched.
13990−++ store-update-unfaced
13991− |= typ=itype
13992− ^- itype
13993− ?. ?=(%fn -.typ) typ
13994− ?. ?=(%cell -.sample.typ) typ
13995− =/ head=itype hed.sample.typ
13996− =/ tail=itype tal.sample.typ
13997− =? head ?=(%face -.head) body.head
13998− =? tail ?=(%face -.tail) body.tail
13999− typ(sample [%cell head tail])
14000−::
14001−:: The builder erases the action from main. Recover it only from the direct
14002−:: local poke declaration and check both ordinary components invariantly.
14003−++ store-main-closed
14004− |= [parts=[init=term update=term] action=term env=ienv molds=imold-types prelude=(unit ifile)]
14005− ^- (unit ischeme)
14006− ?~ prelude ~
14007− =/ builder=(unit ischeme) (ienv-lookup %store values.u.prelude)
14008− ?~ builder ~
14009− ?. ?=([@ @ ~] vars.u.builder) ~
14010− =/ state-var=@ud i.vars.u.builder
14011− =/ action-var=@ud i.t.vars.u.builder
14012− ?: =(state-var action-var) ~
14013− =/ builder-sample=itype
14014− [%cell [%face %init [%var state-var]] [%face %update [%fn [%cell [%var action-var] [%var state-var]] [%var state-var]]]]
14015− =/ builder-product=itype [%cell [%face %init [%var state-var]] [%face %update [%noun ~]]]
14016− ?. =(typ.u.builder [%fn builder-sample builder-product]) ~
14017− =/ store=(unit ischeme) (find-jibb-mold %store u.prelude)
14018− ?~ store ~
14019− ?. ?=([@ ~] vars.u.store) ~
14020− ?. =(typ.u.store [%cell [%face %init [%var i.vars.u.store]] [%face %update [%noun ~]]]) ~
14021− =/ state=(unit ischeme) (find-jibb-mold %state [~ molds /tmp ~ ~ ~ ~ ~])
14022− ?~ state ~
14023− =/ action-mold=(unit ischeme) (find-jibb-mold action [~ molds /tmp ~ ~ ~ ~ ~])
14024− ?~ action-mold ~
14025− ?. &(?=(~ vars.u.state) ?=(~ (itype-vars typ.u.state))) ~
14026− ?. &(?=(~ vars.u.action-mold) ?=(~ (itype-vars typ.u.action-mold))) ~
14027− =/ canonical=(unit itype) (template-apply u.store ~[typ.u.state])
14028− ?~ canonical ~
14029− =/ main=(unit ischeme) (ienv-lookup %main env)
14030− =/ main-fit=(unit ifit)
14031− ?~(main ~ `(direct-invariant typ.u.main u.canonical ~ 0))
14032− =/ main-ok=?
14033− ?~ main &
14034− ?. ?=(~ vars.u.main) |
14035− ?. ?=(~ (itype-vars typ.u.main)) |
14036− ?~ main-fit |
14037− ?=(%ok -.u.main-fit)
14038− ?. main-ok ~
14039− =/ init=(unit ischeme) (ienv-lookup init.parts env)
14040− ?~ init ~
14041− ?. ?=(~ vars.u.init) ~
14042− ?. ?=(~ (itype-vars typ.u.init)) ~
14043− =/ init-fit=ifit (direct-invariant typ.u.init typ.u.state ~ 0)
14044− ?. ?=(%ok -.init-fit) ~
14045− =/ update=(unit ischeme) (ienv-lookup update.parts env)
14046− ?~ update ~
14047− ?. ?=(~ vars.u.update) ~
14048− ?. ?=(~ (itype-vars typ.u.update)) ~
14049− =/ expected=itype [%fn [%cell typ.u.action-mold typ.u.state] typ.u.state]
14050− =/ update-fit=ifit (direct-invariant (store-update-unfaced typ.u.update) expected ~ 0)
14051− ?. ?=(%ok -.update-fit) ~
14052− `[u.canonical ~]
10690+ `[~[[n sc]] (api-mark-exports marks marks mark-externals) at ~[[n i.t.t.at n]] ~ ~ ~]
1405310691::
1405410692++ infer-jibb-file
1405510693 |= [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)]
1405610694 ^- jfile-result
14057− =/ out=jfile-detailed-result
14058− (infer-jibb-file-detailed at src externals mark-externals modules active prelude-values prelude-molds cache prelude)
14059− ?: ?=(%| -.out) [%| message.p.out]
14060− [%& p.out]
14061−:: Returns structured root-source overlap evidence after the same full check.
14062−++ infer-jibb-file-detailed
14063− |= [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)]
14064− ^- jfile-detailed-result
1406510695 =/ parsed (parse at src)
14066− ?: ?=(%| -.parsed) [%| [(crip "module source does not parse: {(spud at)}") ~]]
10696+ ?: ?=(%| -.parsed) [%| (crip "module source does not parse: {(spud at)}")]
1406710697 =/ mod=module p.parsed
1406810698 =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
14069− ?^ duplicate [%| [(show-duplicate-fields at src u.duplicate) ~]]
14070− ?: &(?=([%ui %api *] at) ?=(^ (program-main-def defs.mod)))
14071− [%| [(crip "module kind needs unsupported inference: {(spud at)}") ~]]
10699+ ?^ duplicate [%| (show-duplicate-fields at src u.duplicate)]
1407210700 ?: ?=([%ui %api *] at)
1407310701 =/ iface=(unit ifile) (api-poke-interface at mod mark-externals prelude-values prelude-molds prelude)
14074− ?^ iface
14075− =/ checked=ifile u.iface(source `src, graph `[(silt `(list path)`~[at]) ~ ~ modules prelude prelude-values prelude-molds externals mark-externals])
14076− [%& [checked [[at checked] cache]]]
14077− ?~ prelude [%| [(crip "API module needs unsupported inference: {(spud at)}") ~]]
14078− =/ prepared=iprelude [u.prelude prelude-values prelude-molds]
14079− =/ narrow=?
14080− ?. ?=([[%mark *] ~] imports.mod) |
14081− ?. ?=([[%mold *] ~] defs.mod) |
14082− ?. =(%paths name.i.defs.mod) |
14083− !?=(%union -.shape.i.defs.mod)
14084− ?: narrow
14085− =/ request=(each ione-request-interface @t)
14086− (one-request-interface-graph at src externals mark-externals modules active cache `prepared)
14087− ?: ?=(%| -.request) [%| [(crip "API module needs unsupported inference: {(spud at)}") ~]]
14088− =/ checked=ifile iface.p.request
14089− [%& [checked [[at checked] dependencies.paths.support.p.request]]]
14090− =/ multi=(each [iface=ifile cache=jcache] @t)
14091− (multi-request-interface-graph at src externals mark-externals modules active cache `prepared)
14092− ?: ?=(%| -.multi) [%| [(crip "API module needs unsupported inference: {(spud at)}") ~]]
14093− [%& [iface.p.multi [[at iface.p.multi] cache.p.multi]]]
14094− =/ main=(unit def) (program-main-def defs.mod)
14095− =/ main-parts=(unit [init=term update=term view=term subs=term])
14096− ?~(main ~ (program-main-parts u.main))
14097− =/ page-parts=(unit [load=term view=term])
14098− ?~(main ~ (page-main-parts u.main))
14099− =/ store-parts=(unit [init=term update=term])
14100− ?~(main ~ (store-main-parts u.main))
14101− =/ declared=(unit istore-declaration)
14102− ?~(store-parts ~ (store-declaration mod prelude-values prelude-molds))
14103− ?: &(?=(^ store-parts) ?=(~ declared))
14104− [%| [(crip "module kind or scope needs unsupported inference: {(spud at)}") ~]]
14105− ?: &(?=([%ui %stores *] at) ?=(^ main) ?=(~ store-parts))
14106− [%| [(crip "module kind needs unsupported inference: {(spud at)}") ~]]
14107− =/ ds=(list def) ?~(declared defs.mod defs.u.declared)
14108− =/ checking=module mod(defs ds)
14109− ?. (module-scope-valid checking prelude-values prelude-molds)
10702+ ?~ iface [%| (crip "API module needs unsupported inference: {(spud at)}")]
10703+ =/ checked=ifile u.iface(source `src)
10704+ [%& [checked [[at checked] cache]]]
10705+ ?. (module-scope-valid mod prelude-values prelude-molds)
1411010706 ?: (pending-declared-poke at mod prelude-values prelude-molds)
14111− [%| [(crip "module kind or scope needs unsupported inference: {(spud at)}") ~]]
14112− [%| [(crip "module has conflicting names: {(spud at)}") ~]]
14113− =/ vals=(list term) (global-value-names ds)
14114− =/ js=jimports-detailed-result (resolve-jibb-imports-detailed imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
10707+ [%| (crip "module kind or scope needs unsupported inference: {(spud at)}")]
10708+ [%| (crip "module has conflicting names: {(spud at)}")]
10709+ =/ vals=(list term) (global-value-names defs.mod)
10710+ ?: (lien vals |=(n=term =(n %main)))
10711+ [%| (crip "module kind needs unsupported inference: {(spud at)}")]
10712+ =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
1411510713 ?: ?=(%| -.js) [%| p.js]
14116− =/ collected=grec-collected
14117− ?^ imports.mod [(collect-simple-molds ds) *(map term shape)]
14118− (grec-collect-molds ds)
14119− =/ molds=imolds molds.collected
10714+ =/ molds=imolds (collect-simple-molds defs.mod)
1412010715 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
1412110716 =/ surs=(list term) (collect-sur-imports imports.mod)
1412210717 =/ marks=(list term) (collect-mark-imports imports.mod)
1412310718 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
1412410719 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
14125− =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~ ~ ~]
14126− :: Source and scope were checked above; preserve that exact root and prelude.
14127− :: This first integration only indexes import-free library sources.
14128− =/ index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])
14129− ?^ imports.mod ~
14130− ?~ prelude ~
14131− =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude)
14132− ?~ standard ~
14133− ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]]) ~
14134− =/ index=(map term shape) proofs.collected
14135− ?. !=(index *(map term shape)) ~
14136− ?: (lien molds |=(m=[name=term body=shape] =(%list name.m))) ~
14137− `[at src u.prelude index]
14138− =. grec-index.state index
14139− =/ mts=(each imold-types imold-failure) (module-mold-types-detail molds state)
14140− ?: ?=(%| -.mts)
14141− ?~ overlap.p.mts [%| [(crip "{(trip message.p.mts)}: {(spud at)}") ~]]
14142− =/ witness=[name=term cases=upair] u.overlap.p.mts
14143− =/ first=@t (show-error src [at line.beg.first.cases.witness col.beg.first.cases.witness "first union case"])
14144− =/ second=@t (show-error src [at line.beg.second.cases.witness col.beg.second.cases.witness "overlapping case"])
14145− =/ msg=@t (of-wain:format ~[(crip "module mold {(trip name.witness)} has overlapping cases") first second])
14146− [%| [msg `[at src name.witness cases.witness]]]
14147− =/ resolution=iresolved
14148− ?~ index
14149− (resolve-groups ds molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
14150− (resolve-groups-core ds molds globals externals surs mark-externals marks resolved.p.js reserved at prelude index)
10720+ =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude ~ 256 ~]
10721+ =/ mts=(each imold-types @t) (module-mold-types molds state)
10722+ ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
10723+ =/ resolution=iresolved (resolve-groups defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
1415110724 =/ env=ienv env.resolution
14152− =/ recovered=iresolved
14153− ?~ main resolution
14154− ?~ main-parts resolution
14155− =/ updated=(unit iresolved)
14156− (program-update-context u.main u.main-parts ds resolution state)
14157− =/ with-update=iresolved ?~(updated resolution u.updated)
14158− =/ subscribed=(unit iresolved)
14159− (program-subs-context u.main-parts ds with-update state)
14160− =/ with-subs=iresolved ?~(subscribed with-update u.subscribed)
14161− =/ viewed=(unit iresolved)
14162− (program-view-context u.main-parts ds with-subs state)
14163− =/ with-keyed-view=iresolved ?~(viewed with-subs u.viewed)
14164− =/ plain-view=(unit iresolved)
14165− ?^(viewed ~ (program-plain-view-context u.main-parts ds with-keyed-view state))
14166− =/ with-view=iresolved ?~(plain-view with-keyed-view u.plain-view)
14167− =/ initialized=(unit iresolved)
14168− (program-init-context u.main u.main-parts ds with-view state)
14169− =/ with-initialized=iresolved ?~(initialized with-view u.initialized)
14170− =/ plain-init=(unit iresolved)
14171− ?^(initialized ~ (program-plain-init-context u.main-parts ds with-initialized state))
14172− =/ components=iresolved ?~(plain-init with-initialized u.plain-init)
14173− (program-main-context u.main ds components state)
14174− =. env env.recovered
14175− =. artifacts.resolution artifacts.recovered
14176− =. env
14177− ?: (module-values-complete ds env) env
14178− ?: |(?=([%ui %stores *] at) ?=(^ imports.mod) ?=(^ prelude) ?=(^ prelude-values) ?=(^ prelude-molds)) env
14179− ?: (gth (met 3 src) 65.536) env
14180− ?: (gth (lent ds) 64) env
14181− ?. (dg-source-candidate ds 64) env
14182− =/ transaction=(unit dgcommit) (dg-root-source at src)
14183− ?~ transaction env
14184− ?: (dg-interface-safe env.u.transaction) env.u.transaction
14185− env
14186− =/ required=(list def)
14187− ?~ store-parts ds
14188− (skim ds |=(d=def !&(?=(%value -.d) =(%main name.d))))
14189− ?. (module-values-complete required env)
14190− [%| [(crip "module definitions need unsupported inference: {(spud at)}") ~]]
14191− =/ initial=irequest-graph [(silt `(list path)`~[at]) ~ ~ modules prelude prelude-values prelude-molds externals mark-externals]
14192− =/ graph=(unit irequest-graph) (request-graph-merge resolved.p.js initial (add 1 (lent resolved.p.js)))
14193− ?~ graph [%| ['module request evidence needs unsupported inference' ~]]
14194− =/ static-main=(unit ischeme)
14195− ?~ main ~
14196− ?^ main-parts ~
14197− ?^ page-parts ~
14198− ?^ store-parts ~
14199− (static-main-specialized env prelude)
14200− =? env ?=(^ static-main)
14201− [[%main u.static-main] (skim env |=(entry=[name=term scheme=ischeme] !=(%main name.entry)))]
14202− =/ store-main=(unit ischeme)
14203− ?~ store-parts ~
14204− ?~ declared ~
14205− (store-main-closed u.store-parts action.u.declared env p.mts prelude)
14206− =? env ?=(^ store-main)
14207− [[%main u.store-main] (skim env |=(entry=[name=term scheme=ischeme] !=(%main name.entry)))]
14208− =/ kind-ok=?
14209− ?~ main &
14210− ?^ main-parts (program-main-closed u.main-parts ds env prelude resolved.p.js u.graph)
14211− ?^ page-parts (page-main-closed u.page-parts ds env prelude resolved.p.js u.graph)
14212− ?^ store-parts ?=(^ store-main)
14213− ?=(^ static-main)
14214− ?. kind-ok
14215− [%| [(crip "module kind needs unsupported inference: {(spud at)}") ~]]
14216− =/ store-derived=(unit [values=ienv evidence=istore-request-evidence])
14217− ?~ declared ~
14218− ?~ prelude ~
14219− =/ state=(unit ischeme) (find-jibb-mold %state [~ p.mts at ~ ~ ~ ~ ~])
14220− ?~ state ~
14221− =/ action-mold=(unit ischeme) (find-jibb-mold action.u.declared [~ p.mts at ~ ~ ~ ~ ~])
14222− ?~ action-mold ~
14223− =/ schemes=(unit [state=ischeme action=ischeme])
14224− (store-derived-schemes u.prelude prelude-values prelude-molds typ.u.state typ.u.action-mold)
14225− ?~ schemes ~
14226− =/ evidence=istore-request-evidence
14227− [at src typ.u.state action.u.declared typ.u.action-mold]
14228− `[~[[%state state.u.schemes] [action.u.declared action.u.schemes]] evidence]
14229− ?: &(?=(^ declared) ?=(~ store-derived))
14230− [%| [(crip "store derived gates need unsupported inference: {(spud at)}") ~]]
14231− =? env ?=(^ store-derived) (weld values.u.store-derived env)
14232− =? graph ?=(^ store-derived)
14233− `u.graph(stores [evidence.u.store-derived stores.u.graph])
14234− ?. (request-graph-bounded u.graph)
14235− [%| ['module request evidence needs unsupported inference' ~]]
14236− =/ iface=ifile [env p.mts at ~ artifacts.resolution ~ `src graph]
10725+ ?. (module-values-complete defs.mod env)
10726+ [%| (crip "module definitions need unsupported inference: {(spud at)}")]
10727+ =/ iface=ifile [env p.mts at ~ artifacts.resolution ~ `src]
1423710728 [%& [iface [[at iface] cache.p.js]]]
1423810729::
14239−:: A source-bound analysis of one named mold, not a module, island,
14240−:: request, watchability or runtime check. The host owns the trusted
14241−:: prepared prelude, canonical paths and reader/source version identities.
14242−:: The 256-node cap covers only classification, not source/graph work.
14243−+$ igate-free-mold
14244− [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]
14245−++ gate-free-mold-source
14246− |= [file=path src=@t name=term externals=iexternals marks=imark-externals modules=jbundle prepared=(unit iprelude) fuel=@ud]
14247− ^- (each igate-free-mold @t)
14248− ?~ file [%| 'mold analysis needs a path ending in jibb']
14249− ?. =(%jibb (rear file)) [%| 'mold analysis needs a path ending in jibb']
14250− ?: |(=(file /lib/jibb/internal/jibb) =(file /lib/jibb/primitives/jibb))
14251− [%| 'the prelude internal modules are private']
14252− ?: ?=([%ui %api *] file) [%| 'API declarations need unsupported mold analysis']
14253− ?: ?=([%ui %stores *] file) [%| 'store declarations need unsupported mold analysis']
14254− =/ entries=jbundle (skim modules |=(m=jsource =(file at.m)))
14255− ?: (gth (lent entries) 1) [%| 'duplicate root module sources']
14256− =/ wrong-root=? ?~(entries | !=(source.i.entries src))
14257− ?: wrong-root [%| 'root module source does not match bundle']
14258− =/ parsed (parse file src)
14259− ?: ?=(%| -.parsed) [%| 'mold source does not parse']
14260− =/ mod=module p.parsed
14261− =/ duplicate=(unit idiag) (duplicate-defs defs.mod)
14262− ?^ duplicate [%| (show-duplicate-fields file src u.duplicate)]
14263− ?~ prepared [%| 'mold analysis needs the prepared prelude']
14264− ?. (module-scope-valid mod values.u.prepared molds.u.prepared)
14265− [%| 'mold source has conflicting or unsupported scope']
14266− =/ selected=(list def)
14267− (skim defs.mod |=(d=def &(?=(%mold -.d) =(name.d name))))
14268− ?~ selected [%| 'selected mold is not declared']
14269− ?^ t.selected [%| 'selected mold is not unique']
14270− ?> ?=(%mold -.i.selected)
14271− =/ public=ifile iface.u.prepared
14272− =/ js=jimports-result
14273− (resolve-jibb-imports imports.mod externals marks modules ~[file] values.u.prepared molds.u.prepared ~ `public)
14274− ?: ?=(%| -.js) [%| p.js]
14275− =/ ms=imolds (collect-simple-molds defs.mod)
14276− =/ vals=(list term) (global-value-names defs.mod)
14277− =/ globals=(list term) (weld values.u.prepared (weld (import-binding-names imports.mod) vals))
14278− =/ surs=(list term) (collect-sur-imports imports.mod)
14279− =/ declared=(list term) (collect-mark-imports imports.mod)
14280− =/ reserved=(list term) (weld molds.u.prepared (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
14281− =/ top=(list term) (turn ms |=(m=[name=term body=shape] name.m))
14282− =/ state=istate [0 ~ ~ ~ ms globals externals surs marks declared resolved.p.js reserved ~ ~ ~ | file top `public ~ 256 ~ ~ ~ ~ ~ ~]
14283− =/ inferred=(unit [template=ischeme state=istate])
14284− (infer-mold-template shape.i.selected state(active ~[name], in-mold &))
14285− ?~ inferred [%| 'selected mold needs unsupported inference']
14286− =/ template=ischeme template.u.inferred
14287− =. typ.template (label-direct-union typ.template shape.i.selected name state)
14288− =. typ.template (itype-normalize typ.template sub.state.u.inferred)
14289− =/ cap=@ud (min fuel 256)
14290− =/ analysis=igate-free (gate-free-type typ.template cap ~)
14291− [%& [file src name u.prepared externals marks modules cache.p.js template fuel cap analysis]]
14292−::
1429310730:: +golden-types-with-modules fails closed for imports without prelude
1429410731:: scope. +golden-types-with-prelude resolves supported library graphs;
1429510732:: its report remains partial and unreachable sources are not examined.
@@ -14350,7 +10787,7 @@
1435010787 ?: ?=(%| -.js) (of-wain:format ~['partial inference; module not checked' p.js])
1435110788 =/ scope-values=(list term)
1435210789 (weld prelude-values (weld (collect-sur-imports imports.p.parsed) (collect-mark-imports imports.p.parsed)))
14353− (golden-types-in-context-core file src externals mark-externals resolved.p.js scope-values prelude-molds iface prepared)
10790+ (golden-types-in-context file src externals mark-externals resolved.p.js scope-values prelude-molds iface)
1435410791::
1435510792:: +golden-types-with-marks: supply declared mark types separately from /sur
1435610793:: entries, as [mark result] with the result from +read-mark:jibb-import.
@@ -14381,10 +10818,6 @@
1438110818++ golden-types-in-context
1438210819 |= [file=path src=@t externals=iexternals mark-externals=imark-externals jimports=ijimports prelude-values=(list term) reserved-molds=(list term) prelude=(unit ifile)]
1438310820 ^- @t
14384− (golden-types-in-context-core file src externals mark-externals jimports prelude-values reserved-molds prelude ~)
14385−++ golden-types-in-context-core
14386− |= [file=path src=@t externals=iexternals mark-externals=imark-externals jimports=ijimports prelude-values=(list term) reserved-molds=(list term) prelude=(unit ifile) prepared=(unit iprelude)]
14387− ^- @t
1438810821 =. reserved-molds (weld reserved-molds (turn jimports |=(j=[face=term interface=ifile] face.j)))
1438910822 =/ parsed (parse file src)
1439010823 ?: ?=(%| -.parsed) (show-error src p.parsed)
@@ -14400,41 +10833,6 @@
1440010833 =/ resolution=iresolved (resolve-groups ds molds globals externals surs mark-externals marks jimports reserved-molds file prelude)
1440110834 =/ cycles=(list icycle) (definite-value-cycles ds globals)
1440210835 =/ env=ienv env.resolution
14403− =/ recovered=(list term) ~
14404− =/ eligible=?
14405− ?& ?=(~ imports.p.parsed)
14406− ?=(~ jimports)
14407− !?=([%ui %api *] file)
14408− !?=([%ui %stores *] file)
14409− !(lien (global-value-names ds) |=(n=term =(n %main)))
14410− !(module-values-complete ds env)
14411− (lte (met 3 src) 65.536)
14412− (lte (lent ds) 64)
14413− ?| &(?=(~ prepared) ?=(~ prelude) ?=(~ prelude-values) ?=(~ reserved-molds) (module-scope-valid p.parsed ~ ~) (dg-source-candidate ds 64))
14414− ?& ?=(^ prepared)
14415− ?=(^ prelude)
14416− =(u.prelude iface.u.prepared)
14417− =(prelude-values values.u.prepared)
14418− =(reserved-molds molds.u.prepared)
14419− (module-scope-valid p.parsed values.u.prepared molds.u.prepared)
14420− (dg-prepared-candidate ds 64)
14421− ==
14422− ==
14423− ==
14424− =/ transaction=(unit dgcommit)
14425− ?. eligible ~
14426− ?~ prepared (dg-root-source file src)
14427− (dg-root-prepared file src u.prepared)
14428− =. recovered
14429− ?~ transaction ~
14430− ?. &((module-values-complete ds env.u.transaction) (dg-interface-safe env.u.transaction)) ~
14431− (turn (skim env.u.transaction |=(entry=[name=term scheme=ischeme] ?=(~ (ienv-lookup name.entry env)))) |=(entry=[name=term scheme=ischeme] name.entry))
14432− =. env
14433− ?~ transaction env
14434− ?: &((module-values-complete ds env.u.transaction) (dg-interface-safe env.u.transaction)) env.u.transaction
14435− env
14436− =/ source-defs=(map term def) (direct-checked-gates ds env)
14437− =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude)
1443810836 =/ lines=(list @t) ~
1443910837 |-
1444010838 ?~ ds (of-wain:format ['partial inference; module not checked' (flop lines)])
@@ -14447,16 +10845,6 @@
1444710845 ?^ cycle
1444810846 =/ diag=idiag ["non-gate value depends on itself through a cycle" ~[[first.i.cycle "value in cycle"] [next.i.cycle "dependency in cycle"]]]
1444910847 $(ds t.ds, lines [(show-inference-diagnostic file src name.d diag) lines])
14450− ?: (lien recovered |=(n=term =(n name.d)))
14451− =/ found=(unit ischeme) (ienv-lookup name.d env)
14452− ?~ found $(ds t.ds, lines [(crip "++ {(trip name.d)}: committed definition unavailable") lines])
14453− ?: (itype-has-hidden-recursive typ.u.found)
14454− $(ds t.ds, lines [(crip "++ {(trip name.d)}: recursive mold name is not available in this scope") lines])
14455− ?: (itype-has-hidden-generic typ.u.found)
14456− $(ds t.ds, lines [(crip "++ {(trip name.d)}: generic union name is not available in this scope") lines])
14457− =/ typ=itype (canonical-itype typ.u.found vars.u.found)
14458− =/ line=@t (crip "++ {(trip name.d)}: {(show-itype typ ~)}{(show-atom-constraint typ)}")
14459− $(ds t.ds, lines [line lines])
1446010848 ?: (lien grouped.resolution |=(n=term =(n name.d)))
1446110849 =/ found=(unit ischeme) (ienv-lookup name.d env)
1446210850 ?~ found $(ds t.ds, lines [(crip "++ {(trip name.d)}: recursive group unavailable") lines])
@@ -14464,9 +10852,7 @@
1446410852 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype typ ~)}{(show-atom-constraint typ)}")
1446510853 $(ds t.ds, lines [line lines])
1446610854 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
14467− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~ ~ ~]
14468− =. gate-defs.initial source-defs
14469− =. head-evidence.initial heads
10855+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude ~ 256 ~]
1447010856 =. initial (reserve-def-caps val.d initial)
1447110857 =/ result=iresult
1447210858 ?: |(?=(%gate -.val.d) ?=(%gate-wide -.val.d))
@@ -14506,667 +10892,4 @@
1450610892 =/ printable=itype (canonical-itype typ vars)
1450710893 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
1450810894 $(ds t.ds, lines [line lines])
14509−:: Experimental module-owned pending-constraint generalization only.
14510−:: Inputs, IDs and substitution come from one checker-owned transaction.
14511−+$ dgscan [ids=(list @ud) fuel=@ud]
14512−++ dg-scan
14513− |= [todo=(list itype) sub=isub fuel=@ud ids=(list @ud)]
14514− ^- (unit dgscan)
14515− ?~ todo `[ids fuel]
14516− ?: =(0 fuel) ~
14517− =. fuel (dec fuel)
14518− =/ t=itype i.todo
14519− ?: ?=(?(%var %avar %rvar %nvar %rnvar %tag) -.t)
14520− =/ node-id=@ud ?:(?=(%tag -.t) id.t +.t)
14521− =/ found=(unit itype) (itype-lookup node-id sub)
14522− ?~ found $(todo t.todo, ids [node-id ids])
14523− ?: &(?=(?(%rvar %rnvar) -.u.found) =(node-id +.u.found))
14524− $(todo t.todo, ids [node-id ids])
14525− $(todo [u.found t.todo])
14526− ?: ?=(%jrec -.t) $(todo t.todo)
14527− ?+ -.t ~
14528− %collection $(todo (weld args.t t.todo))
14529− %union $(todo (weld args.t (weld cases.t t.todo)))
14530− %face $(todo [body.t t.todo])
14531− %fn $(todo [sample.t product.t t.todo])
14532− %cell $(todo [hed.t tal.t t.todo])
14533− %atom $(todo t.todo)
14534− %any-atom $(todo t.todo)
14535− %flag $(todo t.todo)
14536− %noun $(todo t.todo)
14537− %empty $(todo t.todo)
14538− %const $(todo t.todo)
14539− ==
14540−::
14541−++ dg-scan-ids
14542− |= [ids=(list @ud) sub=isub fuel=@ud blocked=(list @ud)]
14543− ^- (unit dgscan)
14544− ?~ ids `[blocked fuel]
14545− =/ one=(unit dgscan) (dg-scan ~[[%var i.ids]] sub fuel blocked)
14546− ?~ one ~
14547− $(ids t.ids, fuel fuel.u.one, blocked ids.u.one)
14548−::
14549−++ dg-env
14550− |= [env=ienv sub=isub fuel=@ud blocked=(list @ud)]
14551− ^- (unit dgscan)
14552− ?~ env `[blocked fuel]
14553− =/ sc=ischeme scheme.i.env
14554− :: Quantifiers are local to the scheme: first find raw free IDs, then
14555− :: follow those IDs in the module substitution without capturing them.
14556− =/ raw=(unit dgscan) (dg-scan ~[typ.sc] ~ fuel ~)
14557− ?~ raw ~
14558− =/ free=(list @ud) (skim ids.u.raw |=(n=@ud !(lien vars.sc |=(q=@ud =(q n)))))
14559− =/ resolved=(unit dgscan) (dg-scan-ids free sub fuel.u.raw blocked)
14560− ?~ resolved ~
14561− $(env t.env, fuel fuel.u.resolved, blocked ids.u.resolved)
14562−::
14563−++ dg-obligations
14564− |= [pending=(list dgo) sub=isub fuel=@ud blocked=(list @ud)]
14565− ^- (unit dgscan)
14566− ?~ pending `[blocked fuel]
14567− =/ found=(unit dgscan) (dg-scan ~[left.i.pending right.i.pending] sub fuel blocked)
14568− ?~ found ~
14569− $(pending t.pending, fuel fuel.u.found, blocked ids.u.found)
14570−::
14571−++ dg-tags
14572− |= [tags=(list ipending) sub=isub fuel=@ud blocked=(list @ud)]
14573− ^- (unit dgscan)
14574− ?~ tags `[blocked fuel]
14575− ?: =(0 fuel) ~
14576− =/ found=(unit itype) (itype-lookup id.i.tags sub)
14577− ?~ found $(tags t.tags, fuel (dec fuel), blocked [id.i.tags blocked])
14578− :: Until this entry is explicitly discharged, retain variables reachable
14579− :: through its binding; mere existence of a substitution is not proof.
14580− =/ reached=(unit dgscan) (dg-scan ~[u.found] sub (dec fuel) blocked)
14581− ?~ reached ~
14582− $(tags t.tags, fuel fuel.u.reached, blocked ids.u.reached)
14583−::
14584−++ dg-generalize
14585− |= [typ=itype env=ienv pending=(list dgo) tags=(list ipending) captured=(list @ud) state=istate fuel=@ud]
14586− ^- (unit ischeme)
14587− :: Bound the obligation list and all graph/substitution walks. The
14588− :: substitution is assumed checker-owned and occurs-checked.
14589− ?: (gth (lent pending) 64) ~
14590− =/ capt=(unit dgscan) (dg-scan-ids captured sub.state fuel ~)
14591− ?~ capt ~
14592− =/ env-free=(unit dgscan) (dg-env env sub.state fuel.u.capt ids.u.capt)
14593− ?~ env-free ~
14594− =/ obligations=(unit dgscan) (dg-obligations pending sub.state fuel.u.env-free ids.u.env-free)
14595− ?~ obligations ~
14596− =/ tagged=(unit dgscan) (dg-tags tags sub.state fuel.u.obligations ids.u.obligations)
14597− ?~ tagged ~
14598− =/ bounded=(unit dgscan) (dg-scan ~[typ] sub.state fuel.u.tagged ~)
14599− ?~ bounded ~
14600− =/ normalized=itype (itype-normalize typ sub.state)
14601− =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
14602− =/ quantified=(list @ud) (skim vars |=(n=@ud !(lien ids.u.tagged |=(b=@ud =(b n)))))
14603− `[[normalized quantified]]
14604−::
14605−+$ dgcommit [env=ienv state=istate]
14606−:: A branch literal must not acquire a value face through replay.
14607−++ dg-literal-target-safe
14608− |= target=itype
14609− ^- ?
14610− ?: ?=(%union -.target)
14611− (levy cases.target |=(c=itype ?=(?(%const %cell) -.c)))
14612− ?=(?(%const %atom %any-atom %flag %noun) -.target)
14613−::
14614−++ dg-replay-edges
14615− |= [edges=(list dgo) state=istate fuel=@ud]
14616− ^- (unit istate)
14617− ?~ edges `state
14618− ?: =(0 fuel) ~
14619− =/ trial=ifit (itype-fit left.i.edges right.i.edges sub.state next.state)
14620− ?. ?=(%ok -.trial) ~
14621− =/ valid=?
14622− ?: ?=(%tag -.left.i.edges)
14623− ?. constructor.left.i.edges
14624− =/ closed=(unit dgscan) (dg-scan ~[right.i.edges] sub.trial 512 ~)
14625− ?~ closed |
14626− ?^ ids.u.closed |
14627− (dg-literal-target-safe (itype-normalize right.i.edges sub.trial))
14628− =((itype-walk left.i.edges sub.trial) (itype-walk right.i.edges sub.trial))
14629− =((itype-walk left.i.edges sub.trial) (itype-walk right.i.edges sub.trial))
14630− ?. valid ~
14631− $(edges t.edges, state state(sub sub.trial, next next.trial), fuel (dec fuel))
14632−::
14633−++ dg-close-env
14634− |= [env=ienv sub=isub fuel=@ud]
14635− ^- (unit ienv)
14636− ?~ env `~
14637− ?: =(0 fuel) ~
14638− =/ s=ischeme scheme.i.env
14639− :: Quantified IDs are scheme-local and cannot be rewritten on publication.
14640− ?. (levy vars.s |=(n=@ud ?=(~ (itype-lookup n sub)))) ~
14641− =/ bounded=(unit dgscan) (dg-scan ~[typ.s] sub (dec fuel) ~)
14642− ?~ bounded ~
14643− =/ normalized=itype (itype-normalize typ.s sub)
14644− ?: (itype-has-tag normalized) ~
14645− =/ vars=(list @ud) (unique-type-vars (itype-vars normalized))
14646− ?. (levy vars |=(n=@ud (lien vars.s |=(v=@ud =(v n))))) ~
14647− =/ rest=(unit ienv) (dg-close-env t.env sub fuel.u.bounded)
14648− ?~ rest ~
14649− `[[name.i.env [normalized vars.s]] u.rest]
14650−::
14651−:: A deferred boolean branch has exactly the two literal flag patterns.
14652−:: Arms are inferred in order. Equal types are retained; two direct pending
14653−:: literals may instead retain source-owned obligations for later context.
14654−++ dg-boolean-patterns
14655− |= e=expr
14656− ^- ?
14657− ?. ?=(%branch -.e) |
14658− ?~ arms.e |
14659− ?~ t.arms.e |
14660− ?^ t.t.arms.e |
14661− =/ x=arm i.arms.e
14662− =/ y=arm i.t.arms.e
14663− ?. &(?=(%lit -.pat.x) ?=(%lit -.pat.y)) |
14664− ?. &(=(%loobean form.lit.pat.x) =(%loobean form.lit.pat.y)) |
14665− !=(val.lit.pat.x val.lit.pat.y)
14666−:: Only a direct source literal which created its own unbound pending tag
14667−:: may create a branch edge. The caller must retain the exact source and state.
14668−++ dg-owned-arm-literal
14669− |= [e=expr t=itype tags=(list ipending) sub=isub initial=@ud]
14670− ^- ?
14671− ?. ?=(%lit -.e) |
14672− ?. ?=(%tag -.t) |
14673− ?: constructor.t |
14674− ?. =(lit.e literal.t) |
14675− ?: (lth id.t initial) |
14676− ?^ (itype-lookup id.t sub) |
14677− (lien tags |=(x=ipending &(=(id.x id.t) =(literal.x literal.t))))
14678−++ dg-boolean-branch
14679− |= [e=expr env=ienv state=istate]
14680− ^- iresult
14681− ?. (dg-boolean-patterns e) [%| ["deferred branch patterns need unsupported inference" ~]]
14682− ?> ?=(%branch -.e)
14683− ?> ?=(^ arms.e)
14684− ?> ?=(^ t.arms.e)
14685− =/ x=arm i.arms.e
14686− =/ y=arm i.t.arms.e
14687− =/ subject=iresult (infer-fragment subject.e env state)
14688− ?: ?=(%| -.subject) subject
14689− =/ su=(unit isub) (itype-unify typ.p.subject [%flag ~] sub.state.p.subject)
14690− ?~ su [%| ["deferred branch subject does not unify with ?" ~]]
14691− =/ left=iresult (infer-fragment val.x env state.p.subject(sub u.su))
14692− ?: ?=(%| -.left) left
14693− =/ right=iresult (infer-fragment val.y env state.p.left)
14694− ?: ?=(%| -.right) right
14695− ?. (dg-stable-fit typ.p.left typ.p.right sub.state.p.right)
14696− =/ st=istate state.p.right
14697− ?. (dg-owned-arm-literal val.x typ.p.left tags.st sub.st next.state)
14698− [%| ["deferred branch arm context needs unsupported inference" ~]]
14699− ?. (dg-owned-arm-literal val.y typ.p.right tags.st sub.st next.state)
14700− [%| ["deferred branch arm context needs unsupported inference" ~]]
14701− ?> ?=(%tag -.typ.p.left)
14702− ?> ?=(%tag -.typ.p.right)
14703− ?: =(id.typ.p.left id.typ.p.right)
14704− [%| ["deferred branch arm context needs unsupported inference" ~]]
14705− ?: (gth (lent obligations.st) 62)
14706− [%| ["deferred branch arm context needs unsupported inference" ~]]
14707− =/ result=itype [%var next.st]
14708− =/ ex=dgo [typ.p.left result (span-of val.x) (span-of e)]
14709− =/ ey=dgo [typ.p.right result (span-of val.y) (span-of e)]
14710− [%& result st(next +(next.st), obligations [ex ey obligations.st])]
14711− [%& typ.p.left state.p.right]
14712−::
14713−:: A direct tuple literal may wait for a later exact result context.
14714−:: Each pending literal retains its source tag and its own fit obligation.
14715−++ dg-infer-tuple-items
14716− |= [items=(list item) env=ienv state=istate]
14717− ^- iresult
14718− ?~ items [%| ["empty cell is not supported by partial inference" ~]]
14719− =/ head=iresult (infer-fragment val.i.items env state)
14720− ?: ?=(%| -.head) head
14721− =/ typ=itype typ.p.head
14722− =/ st=istate state.p.head
14723− =/ adjusted=(unit [typ=itype state=istate])
14724− ?. (dg-owned-arm-literal val.i.items typ tags.st sub.st next.state) `[typ st]
14725− ?: (gth (lent obligations.st) 63) ~
14726− =/ pending=itype [%var next.st]
14727− =/ edge=dgo [typ pending (span-of val.i.items) at.i.items]
14728− `[pending st(next +(next.st), obligations [edge obligations.st])]
14729− ?~ adjusted [%| ["deferred tuple context needs unsupported inference" ~]]
14730− =. typ typ.u.adjusted
14731− =. st state.u.adjusted
14732− =. typ ?~(face.i.items typ [%face u.face.i.items typ])
14733− ?~ t.items [%& typ st]
14734− =/ tail=iresult $(items t.items, state st)
14735− ?: ?=(%| -.tail) tail
14736− [%& [%cell typ typ.p.tail] state.p.tail]
14737−::
14738−:: Deferred inference uses only source forms whose successful fit sites are
14739−:: guarded below; a shared source-node budget bounds this screen.
14740−++ dg-safe-expressions
14741− |= [todo=(list expr) fuel=@ud]
14742− ^- (unit @ud)
14743− ?~ todo `fuel
14744− =/ first=(unit @ud) (dg-safe-expression i.todo fuel)
14745− ?~ first ~
14746− $(todo t.todo, fuel u.first)
14747−++ dg-safe-items
14748− |= [items=(list item) fuel=@ud]
14749− ^- (unit @ud)
14750− ?~ items `fuel
14751− =/ first=(unit @ud) (dg-safe-expression val.i.items fuel)
14752− ?~ first ~
14753− $(items t.items, fuel u.first)
14754−++ dg-safe-expression
14755− |= [e=expr fuel=@ud]
14756− ^- (unit @ud)
14757− ?: =(0 fuel) ~
14758− =. fuel (dec fuel)
14759− ?+ -.e ~
14760− ?(%lit %ctor) `fuel
14761− %wing ?:(?=([@ ~] names.e) `fuel ~)
14762− %str
14763− ?. (levy pieces.e |=(p=piece ?=(%text -.p))) ~
14764− `fuel
14765− %group $(e inner.e, fuel fuel)
14766− %body
14767− ?^ defs.e ~
14768− $(e final.e, fuel fuel)
14769− %gate $(e body.e, fuel fuel)
14770− %gate-wide $(e body.e, fuel fuel)
14771− %tuple (dg-safe-items items.e fuel)
14772− %branch
14773− ?. (dg-boolean-patterns e) ~
14774− ?> ?=(^ arms.e)
14775− ?> ?=(^ t.arms.e)
14776− =/ subject=(unit @ud) $(e subject.e, fuel fuel)
14777− ?~ subject ~
14778− (dg-safe-expressions ~[val.i.arms.e val.i.t.arms.e] u.subject)
14779− %cast $(e val.e, fuel fuel)
14780− %call
14781− =/ head=(unit @ud) $(e head.e, fuel fuel)
14782− ?~ head ~
14783− (dg-safe-expressions args.e u.head)
14784− ==
14785−:: Exact normalized equality is preserved by all later substitutions.
14786−:: The bounded scan declines opaque types and oversized inputs.
14787−++ dg-stable-fit
14788− |= [actual=itype expected=itype sub=isub]
14789− ^- ?
14790− ?~ (dg-scan ~[actual expected] sub 512 ~) |
14791− =((itype-normalize actual sub) (itype-normalize expected sub))
14792−::
14793−:: A positional call peels sample-slot faces during its separate face check.
14794−:: Require its argument, sample and result closed so that check stays valid.
14795−++ dg-stable-call-fit
14796− |= [actual=itype expected=itype product=itype sub=isub positional=?]
14797− ^- ?
14798− =/ checked=(unit dgscan) (dg-scan ~[actual expected product] sub 512 ~)
14799− ?~ checked |
14800− ?: &(positional ?=(^ ids.u.checked)) |
14801− =((itype-normalize actual sub) (itype-normalize expected sub))
14802−::
14803−:: One definition attempt retains state only when inference succeeds.
14804−+$ dg-step [env=ienv state=istate pending=(list dgo)]
14805−++ dg-stage-one
14806− |= [d=def env=ienv state=istate]
14807− ^- (unit dg-step)
14808− ?> ?=(%value -.d)
14809− ?~ (dg-safe-expression val.d 512) ~
14810− =/ local=istate (reserve-def-caps val.d state)
14811− :: This first slice declines all written capitals and holes/projections.
14812− ?^ caps.local ~
14813− =/ ordinary=iresult (infer-fragment val.d env local)
14814− ?: ?=(%| -.ordinary) ~
14815− =/ typ=itype typ.p.ordinary
14816− =/ after=istate state.p.ordinary
14817− =/ edges=(list dgo) obligations.after
14818− ?. =(binders.after binders.state) ~
14819− ?. =(molds.after molds.state) ~
14820− ?. =(globals.after globals.state) ~
14821− ?. =(externals.after externals.state) ~
14822− ?. =(surs.after surs.state) ~
14823− ?. =(mark-externals.after mark-externals.state) ~
14824− ?. =(marks.after marks.state) ~
14825− ?. =(jimports.after jimports.state) ~
14826− ?. =(reserved-molds.after reserved-molds.state) ~
14827− ?. =(params.after params.state) ~
14828− ?. =(active.after active.state) ~
14829− ?. =(in-mold.after in-mold.state) ~
14830− ?. =(at.after at.state) ~
14831− ?. =(top-molds.after top-molds.state) ~
14832− ?. =(prelude.after prelude.state) ~
14833− ?. =(gate-defs.after gate-defs.state) ~
14834− ?. =(head-evidence.after head-evidence.state) ~
14835− ?. =(grec-index.after grec-index.state) ~
14836− ?. =(defer.after defer.state) ~
14837− ?. =(holes.after holes.state) ~
14838− ?. =(caps.after caps.state) ~
14839− ?. =(projections.after projections.state) ~
14840− ?: (unsupported-atom-vars (itype-normalize typ sub.after) caps.after binders.after sub.after) ~
14841− ?: (itype-has-nvar (itype-normalize typ sub.after)) ~
14842− =/ scheme=(unit ischeme) (dg-generalize typ env edges tags.after ~ after 32.768)
14843− ?~ scheme ~
14844− `[[[name.d u.scheme] env] after edges]
14845−:: Retry only definitions that did not infer. Successful definitions are
14846−:: committed into the local transaction, never published until all close.
14847−++ dg-stage
14848− |= [ds=(list def) base=ienv env=ienv state=istate pending=(list dgo) fuel=@ud]
14849− ^- (unit dgcommit)
14850− ?: (gth fuel 64) ~
14851− ?: (gth (lent ds) fuel) ~
14852− =/ remaining=(list def) ds
14853− =/ waiting=(list def) ~
14854− =/ progress=? |
14855− =/ attempts=@ud (mul fuel fuel)
14856− |-
14857− ?~ remaining
14858− ?^ waiting
14859− ?. progress ~
14860− $(remaining (flop waiting), waiting ~, progress |)
14861− =/ replayed=(unit istate) (dg-replay-edges pending state 64)
14862− ?~ replayed ~
14863− ?: (pending-tags tags.u.replayed sub.u.replayed) ~
14864− =/ closed-edges=(unit dgscan) (dg-obligations pending sub.u.replayed 32.768 ~)
14865− ?~ closed-edges ~
14866− ?^ ids.u.closed-edges ~
14867− =/ rechecked=(unit istate) (dg-replay-edges pending u.replayed 64)
14868− ?~ rechecked ~
14869− ?. =(sub.u.rechecked sub.u.replayed) ~
14870− ?. =(next.u.rechecked next.u.replayed) ~
14871− =/ closed=(unit ienv) (dg-close-env env sub.u.replayed 32.768)
14872− ?~ closed ~
14873− `[[u.closed u.replayed(defer ~, obligations ~)]]
14874− ?: =(0 attempts) ~
14875− =. attempts (dec attempts)
14876− =/ d=def i.remaining
14877− ?: ?=(%mold -.d) $(remaining t.remaining)
14878− ?^ (ienv-lookup name.d base) $(remaining t.remaining)
14879− ?^ (ienv-lookup name.d env) ~
14880− =/ done=(unit dg-step) (dg-stage-one d env state)
14881− ?~ done $(remaining t.remaining, waiting [d waiting])
14882− $(remaining t.remaining, env env.u.done, state state.u.done, pending pending.u.done, progress &)
14883−::
14884−:: Cheap bounded eligibility check on the already parsed source. This
14885−:: deliberately covers only direct constructor calls beneath transparent
14886−:: groups, gates, casts and definition-free bodies. Other shapes decline
14887−:: this fallback without a second parse or resolution pass.
14888−++ dg-direct-source
14889− |= [e=expr fuel=@ud]
14890− ^- ?
14891− ?: =(0 fuel) |
14892− ?+ -.e |
14893− %group $(e inner.e, fuel (dec fuel))
14894− %gate $(e body.e, fuel (dec fuel))
14895− %gate-wide $(e body.e, fuel (dec fuel))
14896− %cast $(e val.e, fuel (dec fuel))
14897− %body ?~(defs.e $(e final.e, fuel (dec fuel)) |)
14898− %call
14899− ?. ?=([* ~] args.e) |
14900− ?=(%ctor -.i.args.e)
14901− ==
14902−++ dg-source-candidate
14903− |= [ds=(list def) fuel=@ud]
14904− ^- ?
14905− ?~ ds |
14906− ?: =(0 fuel) |
14907− ?. ?=(%value -.i.ds) $(ds t.ds, fuel (dec fuel))
14908− ?: (dg-direct-source val.i.ds 64) &
14909− $(ds t.ds, fuel (dec fuel))
14910−::
14911−++ dg-prepared-source
14912− |= [e=expr fuel=@ud]
14913− ^- ?
14914− ?: (dg-direct-source e fuel) &
14915− ?: =(0 fuel) |
14916− ?+ -.e |
14917− %group $(e inner.e, fuel (dec fuel))
14918− %gate $(e body.e, fuel (dec fuel))
14919− %gate-wide $(e body.e, fuel (dec fuel))
14920− %cast $(e val.e, fuel (dec fuel))
14921− %body ?~(defs.e $(e final.e, fuel (dec fuel)) |)
14922− %tuple &
14923− ==
14924−++ dg-prepared-candidate
14925− |= [ds=(list def) fuel=@ud]
14926− ^- ?
14927− ?~ ds |
14928− ?: =(0 fuel) |
14929− ?. ?=(%value -.i.ds) $(ds t.ds, fuel (dec fuel))
14930− ?: (dg-prepared-source val.i.ds 64) &
14931− $(ds t.ds, fuel (dec fuel))
14932−::
14933−++ dg-interface-safe
14934− |= [env=ienv]
14935− ^- ?
14936− ?~ env &
14937− =/ sc=ischeme scheme.i.env
14938− ?: |((itype-has-hidden-recursive typ.sc) (itype-has-hidden-generic typ.sc)) |
14939− ?: (gth (lent vars.sc) 26) |
14940− $(env t.env)
14941−:: Parse status and the transaction result come from the same source parse.
14942−+$ dgparse [parsed=? result=(unit dgcommit)]
14943−++ dg-root-source
14944− |= [at=path src=@t]
14945− ^- (unit dgcommit)
14946− result:(dg-root-detail at src)
14947−++ dg-root-detail
14948− |= [at=path src=@t]
14949− ^- dgparse
14950− =/ parsed (parse at src)
14951− ?: ?=(%| -.parsed) [| ~]
14952− =/ transact
14953− |.
14954− ?^ imports.p.parsed ~
14955− ?. (module-scope-valid p.parsed ~ ~) ~
14956− ?^ (duplicate-defs defs.p.parsed) ~
14957− =/ defs=(list def) defs.p.parsed
14958− ?: (gth (lent defs) 64) ~
14959− =/ molds=imolds (collect-simple-molds defs)
14960− =/ globals=(list term) (global-value-names defs)
14961− =/ resolution=iresolved (resolve-groups defs molds globals ~ ~ ~ ~ ~ ~ at ~)
14962− ?^ grouped.resolution ~
14963− ?^ artifacts.resolution ~
14964− =/ base=ienv env.resolution
14965− =/ free=(unit dgscan) (dg-env base ~ 32.768 ~)
14966− ?~ free ~
14967− ?^ ids.u.free ~
14968− =/ all=(unit dgscan) (dg-all-env-ids base 32.768 ~)
14969− ?~ all ~
14970− =/ fresh=@ud (dg-next-id ids.u.all 0)
14971− =/ st=istate *istate
14972− =. st st(next fresh, defer `~, molds molds, globals globals, at at, top-molds (turn molds |=(m=[name=term body=shape] name.m)), in-mold |, jrec-fuel 256)
14973− =/ checked-molds=(each imold-types @t) (module-mold-types molds st)
14974− ?: ?=(%| -.checked-molds) ~
14975− (dg-stage defs base base st ~ 64)
14976− ::
14977− [& (transact)]
14978−:: The caller supplies the trusted prepared prelude. This transaction is
14979−:: only report evidence; the ordinary module resolver does not publish it.
14980−++ dg-root-prepared
14981− |= [at=path src=@t prepared=iprelude]
14982− ^- (unit dgcommit)
14983− ?: ?=([%ui %api *] at) ~
14984− ?: ?=([%ui %stores *] at) ~
14985− ?: (gth (met 3 src) 65.536) ~
14986− =/ parsed (parse at src)
14987− ?: ?=(%| -.parsed) ~
14988− ?^ imports.p.parsed ~
14989− ?. (module-scope-valid p.parsed values.prepared molds.prepared) ~
14990− ?^ (duplicate-defs defs.p.parsed) ~
14991− =/ defs=(list def) defs.p.parsed
14992− ?: (gth (lent defs) 64) ~
14993− ?: (lien (global-value-names defs) |=(n=term =(n %main))) ~
14994− ?. (dg-prepared-candidate defs 64) ~
14995− =/ local-molds=imolds (collect-simple-molds defs)
14996− =/ globals=(list term) (weld values.prepared (global-value-names defs))
14997− =/ iface=ifile iface.prepared
14998− =/ prelude=(unit ifile) `iface
14999− =/ resolution=iresolved
15000− (resolve-groups defs local-molds globals ~ ~ ~ ~ ~ molds.prepared at prelude)
15001− ?^ grouped.resolution ~
15002− ?^ artifacts.resolution ~
15003− =/ base=ienv env.resolution
15004− =/ templates=ienv
15005− (turn molds.iface |=(x=[name=term template=ischeme] [name.x template.x]))
15006− =/ all-env=ienv (weld base (weld values.iface templates))
15007− =/ free=(unit dgscan) (dg-env all-env ~ 32.768 ~)
15008− ?~ free ~
15009− ?^ ids.u.free ~
15010− =/ all=(unit dgscan) (dg-all-env-ids all-env 32.768 ~)
15011− ?~ all ~
15012− =/ fresh=@ud (dg-next-id ids.u.all 0)
15013− =/ st=istate *istate
15014− =. st st(next fresh, defer `~, molds local-molds, globals globals, at at, reserved-molds molds.prepared, prelude prelude, top-molds (turn local-molds |=(m=[name=term body=shape] name.m)), in-mold |, jrec-fuel 256)
15015− =/ checked-molds=(each imold-types @t) (module-mold-types local-molds st)
15016− ?: ?=(%| -.checked-molds) ~
15017− (dg-stage defs base base st ~ 64)
15018−::
15019−++ dg-all-env-ids
15020− |= [env=ienv fuel=@ud ids=(list @ud)]
15021− ^- (unit dgscan)
15022− ?~ env `[ids fuel]
15023− ?: =(0 fuel) ~
15024− =/ sc=ischeme scheme.i.env
15025− ?: (itype-has-tag typ.sc) ~
15026− =/ raw=(unit dgscan) (dg-scan ~[typ.sc] ~ (dec fuel) ids)
15027− ?~ raw ~
15028− =/ quant=(unit dgscan) (dg-scan-ids vars.sc ~ fuel.u.raw ids.u.raw)
15029− ?~ quant ~
15030− $(env t.env, fuel fuel.u.quant, ids ids.u.quant)
15031−::
15032−++ dg-next-id
15033− |= [ids=(list @ud) largest=@ud]
15034− ^- @ud
15035− ?~ ids +(largest)
15036− $(ids t.ids, largest (max largest i.ids))
15037−::
15038−++ dg-eligible-ctor
15039− |= [e=expr head=itype actual=itype expected=itype state=istate]
15040− ^- (unit dgo)
15041− ?. ?=(%call -.e) ~
15042− ?. ?=([* ~] args.e) ~
15043− ?. ?=(%ctor -.i.args.e) ~
15044− ?. ?=(%fn -.head) ~
15045− ?. ?=(%fn -.expected) ~
15046− ?. ?=(%tag -.actual) ~
15047− ?. constructor.actual ~
15048− ?. ?=(%var -.product.expected) ~
15049− ?^ (itype-lookup id.product.expected sub.state) ~
15050− =/ bounded=(unit dgscan) (dg-scan ~[sample.expected] sub.state 256 ~)
15051− ?~ bounded ~
15052− ?^ ids.u.bounded ~
15053− `[[actual expected (span-of i.args.e) (span-of head.e)]]
15054−::
15055−:: Experimental per-module, source-derived recursive tree index.
15056−:: The two tags and the exact children/list/self layout are fixed-shape
15057−:: checks, so ordinary definitions incur no type-tree or source scans.
15058−++ grec-tagged-fields
15059− |= sh=shape
15060− ^- (unit [tag=@ fields=(list field)])
15061− ?. ?=(%cell -.sh) ~
15062− ?~ fields.sh ~
15063− =/ head=field i.fields.sh
15064− ?. ?=(%bare -.head) ~
15065− ?. ?=(%const -.shape.head) ~
15066− ?. &(?=(%term form.lit.shape.head) =(%tas aura.lit.shape.head)) ~
15067− `[val.lit.shape.head t.fields.sh]
15068−++ grec-tree-children
15069− |= [fs=(list field) param=@t]
15070− ^- (unit field)
15071− ?~ fs ~
15072− ?~ t.fs `i.fs
15073− ?^ t.t.fs ~
15074− =/ event=field i.fs
15075− =/ kids=field i.t.fs
15076− ?. &(?=(%face -.event) ?=(%face -.kids)) ~
15077− ?. !=(name.event name.kids) ~
15078− ?. ?=(%fn -.shape.event) ~
15079− ?. ?=(%aura -.sample.shape.event) ~
15080− ?. =(%t aura.sample.shape.event) ~
15081− ?. ?=(%tvar -.product.shape.event) ~
15082− ?. =(param name.product.shape.event) ~
15083− `kids
15084−::
15085−++ grec-tree-proof
15086− |= [name=term sh=shape]
15087− ^- ?
15088− ?. ?=(%generic -.sh) |
15089− ?. ?=([@ ~] vars.sh) |
15090− =/ param=@t i.vars.sh
15091− ?. ?=(%union -.body.sh) |
15092− ?. ?=([* [* ~]] cases.body.sh) |
15093− =/ a=(unit [tag=@ fields=(list field)]) (grec-tagged-fields i.cases.body.sh)
15094− =/ b=(unit [tag=@ fields=(list field)]) (grec-tagged-fields i.t.cases.body.sh)
15095− ?~ a |
15096− ?~ b |
15097− ?. !=(tag.u.a tag.u.b) |
15098− ?. ?=([* ~] fields.u.a) |
15099− =/ value=field i.fields.u.a
15100− ?. ?=(%face -.value) |
15101− ?. ?=(%aura -.shape.value) |
15102− ?. =(%t aura.shape.value) |
15103− =/ selected=(unit field) (grec-tree-children fields.u.b param)
15104− ?~ selected |
15105− =/ kids=field u.selected
15106− ?. ?=(%face -.kids) |
15107− ?. ?=(%apply -.shape.kids) |
15108− ?. =(ref.shape.kids ~[%list]) |
15109− ?. ?=([* ~] args.shape.kids) |
15110− =/ self=shape i.args.shape.kids
15111− ?. ?=(%apply -.self) |
15112− ?. =(ref.self ~[name]) |
15113− ?. ?=([* ~] args.self) |
15114− ?. ?=(%tvar -.i.args.self) |
15115− =(name.i.args.self param)
15116−+$ grec-collected [molds=imolds proofs=(map term shape)]
15117−:: Experimental one-layer analysis view, never an exported mold identity.
15118−++ grec-unfold-view
15119− |= [typ=itype fuel=@ud]
15120− ^- (unit [view=itype left=@ud])
15121− ?. ?=(%grec -.typ) ~
15122− ?: =(fuel 0) ~
15123− ?. ?=([* ~] args.typ) ~
15124− =/ sh=shape proof.typ
15125− ?. (grec-tree-proof name.typ sh) ~
15126− ?> ?=(%generic -.sh)
15127− ?> ?=([@ ~] vars.sh)
15128− ?> ?=(%union -.body.sh)
15129− ?> ?=([* [* ~]] cases.body.sh)
15130− =/ ca=shape i.cases.body.sh
15131− =/ cb=shape i.t.cases.body.sh
15132− ?> ?=(%cell -.ca)
15133− ?> ?=(%cell -.cb)
15134− ?> ?=([* [* ~]] fields.ca)
15135− ?> ?=([* *] fields.cb)
15136− =/ tag-a=field i.fields.ca
15137− =/ tag-b=field i.fields.cb
15138− ?> ?=(%bare -.tag-a)
15139− ?> ?=(%bare -.tag-b)
15140− ?> ?=(%const -.shape.tag-a)
15141− ?> ?=(%const -.shape.tag-b)
15142− =/ text-field=field i.t.fields.ca
15143− ?> ?=(%face -.text-field)
15144− =/ branch=(list field) t.fields.cb
15145− =/ kids=(unit field) (grec-tree-children branch i.vars.sh)
15146− ?~ kids ~
15147− ?> ?=(%face -.u.kids)
15148− =/ children=itype [%face name.u.kids [%collection %list ~[typ]]]
15149− ?> ?=(^ branch)
15150− =/ payload=itype
15151− ?~ t.branch children
15152− =/ event=field i.branch
15153− ?> ?=(%face -.event)
15154− [%cell [%face name.event [%fn [%atom %t] i.args.typ]] children]
15155− =/ leaf=itype [%cell [%const lit.shape.tag-a] [%face name.text-field [%atom %t]]]
15156− =/ node=itype [%cell [%const lit.shape.tag-b] payload]
15157− `[[%union ~[leaf node] ~ ~ ~] (dec fuel)]
15158−::
15159−++ grec-collect-molds
15160− |= ds=(list def)
15161− ^- grec-collected
15162− ?~ ds [~ *(map term shape)]
15163− =/ rest=grec-collected $(ds t.ds)
15164− ?. ?=(%mold -.i.ds) rest
15165− =/ name=term name.i.ds
15166− =/ body=shape shape.i.ds
15167− =/ proofs=(map term shape) proofs.rest
15168− =? proofs (grec-tree-proof name body) (~(put by proofs) name body)
15169− [[[name body] molds.rest] proofs]
15170−::
15171−
1517210895--