@@ -4672,6 +4672,7 @@
46724672 [%collection name=term args=(list itype)]
46734673 [%recursive module=term name=term label=(unit @t)]
46744674 [%jrec at=path name=term label=(unit @t) head=term aura=@ta tail=term]
4675+ [%grec at=path name=term label=(unit @t) proof=shape args=(list itype)]
46754676 [%union cases=(list itype) origin=(unit [at=path name=term]) label=(unit @t) args=(list itype)]
46764677 [%face name=term body=itype]
46774678 [%fn sample=itype product=itype]
@@ -4743,6 +4744,7 @@
47434744 %union |((lien cases.t |=(c=itype (itype-occurs n c sub))) (lien args.t |=(c=itype (itype-occurs n c sub))))
47444745 %recursive |
47454746 %jrec |
4747+ %grec (lien args.t |=(c=itype (itype-occurs n c sub)))
47464748 %collection (lien args.t |=(c=itype (itype-occurs n c sub)))
47474749 %face $(t body.t)
47484750 %fn |($(t sample.t) $(t product.t))
@@ -4761,6 +4763,9 @@
47614763 =. a (itype-walk a sub)
47624764 =. b (itype-walk b sub)
47634765 ?: =(a b) `sub
4766+ ?: &(?=(%grec -.a) ?=(%grec -.b))
4767+ ?. &(=(at.a at.b) =(name.a name.b)) ~
4768+ (itype-unify-args args.a args.b sub)
47644769 ?: &(?=(%jrec -.a) ?=(%jrec -.b))
47654770 ?:(&(=(at.a at.b) =(name.a name.b) =(head.a head.b) =(aura.a aura.b) =(tail.a tail.b)) `sub ~)
47664771 ?: &(?=(%recursive -.a) ?=(%recursive -.b))
@@ -4871,6 +4876,7 @@
48714876 %union |((lien cases.t |=(c=itype (itype-has-any-atom c sub))) (lien args.t |=(c=itype (itype-has-any-atom c sub))))
48724877 %recursive |
48734878 %jrec |
4879+ %grec (lien args.t |=(c=itype (itype-has-any-atom c sub)))
48744880 %collection (lien args.t |=(c=itype (itype-has-any-atom c sub)))
48754881 %face $(t body.t)
48764882 %fn |($(t sample.t) $(t product.t))
@@ -4945,6 +4951,7 @@
49454951 %union |((lien cases.typ |=(c=itype (itype-has-fixed-atom c))) (lien args.typ |=(c=itype (itype-has-fixed-atom c))))
49464952 %recursive |
49474953 %jrec |
4954+ %grec (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
49484955 %collection (lien args.typ |=(c=itype (itype-has-fixed-atom c)))
49494956 %face $(typ body.typ)
49504957 %fn |($(typ sample.typ) $(typ product.typ))
@@ -4973,6 +4980,7 @@
49734980 ^- ?
49744981 =. t (itype-walk t sub)
49754982 ?- -.t
4983+ %grec (lien args.t |=(c=itype (itype-has-face c sub)))
49764984 %collection (lien args.t |=(c=itype (itype-has-face c sub)))
49774985 %face &
49784986 %cell |($(t hed.t) $(t tal.t))
@@ -5029,6 +5037,9 @@
50295037 ^- ?
50305038 =. a (itype-walk a sub)
50315039 =. b (itype-walk b sub)
5040+ ?: &(?=(%grec -.a) ?=(%grec -.b))
5041+ ?. &(=(at.a at.b) =(name.a name.b)) |
5042+ (itype-face-asym-collection-args args.a args.b sub)
50325043 ?: &(?=(%collection -.a) ?=(%collection -.b))
50335044 ?. =(name.a name.b) |
50345045 (itype-face-asym-collection-args args.a args.b sub)
@@ -5091,6 +5102,7 @@
50915102 %union &
50925103 %recursive &
50935104 %jrec &
5105+ %grec &
50945106 %noun &
50955107 %collection &
50965108 %face $(t body.t)
@@ -5120,6 +5132,7 @@
51205132 ^- ?
51215133 ?- -.t
51225134 %tag &
5135+ %grec (lien args.t |=(c=itype (itype-has-tag c)))
51235136 %collection (lien args.t |=(c=itype (itype-has-tag c)))
51245137 %face $(t body.t)
51255138 %fn |($(t sample.t) $(t product.t))
@@ -5133,6 +5146,7 @@
51335146 ^- ?
51345147 ?- -.t
51355148 %union &
5149+ %grec (lien args.t |=(c=itype (itype-has-union c)))
51365150 %collection (lien args.t |=(c=itype (itype-has-union c)))
51375151 %face $(t body.t)
51385152 %fn |($(t sample.t) $(t product.t))
@@ -5151,6 +5165,7 @@
51515165 %union
51525166 ?: &(?=(~ label.t) ?=(^ args.t)) &
51535167 (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-generic c)))
5168+ %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-generic c))))
51545169 %collection (lien args.t |=(c=itype (itype-has-hidden-generic c)))
51555170 %face $(t body.t)
51565171 %fn |($(t sample.t) $(t product.t))
@@ -5164,6 +5179,7 @@
51645179 ?- -.t
51655180 %recursive &
51665181 %jrec &
5182+ %grec &
51675183 %collection (lien args.t |=(c=itype (itype-has-recursive c)))
51685184 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-recursive c)))
51695185 %face $(t body.t)
@@ -5178,6 +5194,7 @@
51785194 ?- -.t
51795195 %recursive ?=(~ label.t)
51805196 %jrec ?=(~ label.t)
5197+ %grec |(?=(~ label.t) (lien args.t |=(c=itype (itype-has-hidden-recursive c))))
51815198 %collection (lien args.t |=(c=itype (itype-has-hidden-recursive c)))
51825199 %union (lien (weld args.t cases.t) |=(c=itype (itype-has-hidden-recursive c)))
51835200 %face $(t body.t)
@@ -5223,7 +5240,7 @@
52235240 ?: ?=(%var -.raw)
52245241 $(cases t.cases, pending &)
52255242 =/ c=itype (itype-walk raw sub)
5226− ?: ?=(?(%var %tag %recursive %jrec %union %face) -.c)
5243+ ?: ?=(?(%var %tag %recursive %jrec %grec %union %face) -.c)
52275244 $(cases t.cases, pending &)
52285245 ?. ?=(%cell -.c) $(cases t.cases)
52295246 =/ raw-head=itype hed.c
@@ -5236,7 +5253,7 @@
52365253 ?: ?=(?(%atom %any-atom %flag %avar %rvar %nvar %rnvar) -.body.head)
52375254 $(cases t.cases)
52385255 $(cases t.cases, pending &)
5239− ?: ?=(?(%var %tag %recursive %jrec %union) -.head)
5256+ ?: ?=(?(%var %tag %recursive %jrec %grec %union) -.head)
52405257 $(cases t.cases, pending &)
52415258 ?. ?=(%const -.head) $(cases t.cases)
52425259 ?. =(val.literal.head val.tag) $(cases t.cases)
@@ -5285,6 +5302,14 @@
52855302 [%ok sub next]
52865303 :: An arbitrary noun is not known to fit a narrower type.
52875304 ?: &(?=(%noun -.actual) !?=(%var -.expected)) [%unknown ~]
5305+ ?: &(!uncertain ?=(%grec -.actual) ?=(%face -.expected)) $(expected body.expected)
5306+ ?: &(!uncertain ?=(%face -.actual) ?=(%grec -.expected)) $(actual body.actual)
5307+ ?: &(?=(%grec -.actual) ?=(%grec -.expected))
5308+ ?. &(=(at.actual at.expected) =(name.actual name.expected)) [%unknown ~]
5309+ =/ matched=(unit isub) (itype-unify-args args.actual args.expected sub)
5310+ ?~ matched [%unknown ~]
5311+ [%ok u.matched next]
5312+ ?: &(|(?=(%grec -.actual) ?=(%grec -.expected)) !|(?=(%var -.actual) ?=(%var -.expected))) [%unknown ~]
52885313 ?: &(!uncertain ?=(%jrec -.actual) ?=(%face -.expected)) $(expected body.expected)
52895314 ?: &(!uncertain ?=(%face -.actual) ?=(%jrec -.expected)) $(actual body.actual)
52905315 ?: &(?=(%jrec -.actual) ?=(%jrec -.expected))
@@ -5674,10 +5699,11 @@
56745699 %tag [%unknown | fuel ~]
56755700 %recursive [%unknown | fuel ~]
56765701 %jrec [%yes & fuel ~]
5702+ %grec [%unknown | fuel ~]
56775703 ==
56785704::
56795705+$ igate-prelude-evidence [iface=ifile gates=(map term def)]
5680−+$ 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)]
5706++$ istate [next=@ud sub=isub caps=icaps binders=(list @ud) molds=imolds globals=(list term) externals=iexternals surs=(list term) mark-externals=imark-externals marks=(list term) jimports=ijimports reserved-molds=(list term) params=iparams active=(list term) tags=(list ipending) in-mold=? at=path top-molds=(list term) prelude=(unit ifile) holes=(list ihole) jrec-fuel=@ud projections=(list iwprojection) gate-defs=(map term def) head-evidence=(unit igate-prelude-evidence) grec-index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])]
56815707+$ idiag [msg=tape sites=(list [at=span note=tape])]
56825708+$ iresult (each [typ=itype state=istate] idiag)
56835709+$ isample-result (each [typ=itype env=ienv state=istate] tape)
@@ -5697,6 +5723,7 @@
56975723 |= [t=itype sub=isub]
56985724 ^- itype
56995725 =. t (itype-walk t sub)
5726+ ?: ?=(%grec -.t) t(args (turn args.t |=(c=itype (itype-normalize c sub))))
57005727 ?: ?=(%collection -.t) [%collection name.t (turn args.t |=(c=itype (itype-normalize c sub)))]
57015728 ?: ?=(%union -.t)
57025729 [%union (turn cases.t |=(c=itype (itype-normalize c sub))) origin.t label.t (turn args.t |=(c=itype (itype-normalize c sub)))]
@@ -5723,6 +5750,7 @@
57235750 %cell |($(t hed.t) $(t tal.t))
57245751 %recursive |
57255752 %jrec |
5753+ %grec &
57265754 %collection (lien args.t |=(c=itype (itype-has-gate c)))
57275755 %face $(t body.t)
57285756 %union (lien cases.t |=(c=itype (itype-has-gate c)))
@@ -5746,6 +5774,7 @@
57465774 ?- -.t
57475775 %nvar [%atom %ud]
57485776 %rnvar [%atom %ud]
5777+ %grec t(args (turn args.t |=(c=itype (default-decimals c))))
57495778 %collection [%collection name.t (turn args.t |=(c=itype (default-decimals c)))]
57505779 %face [%face name.t $(t body.t)]
57515780 %cell [%cell $(t hed.t) $(t tal.t)]
@@ -5787,6 +5816,7 @@
57875816 %tag |
57885817 %any-atom &
57895818 %union &((levy cases.t |=(c=itype (hole-known c state))) (levy args.t |=(c=itype (hole-known c state))))
5819+ %grec (levy args.t |=(c=itype (hole-known c state)))
57905820 %collection (levy args.t |=(c=itype (hole-known c state)))
57915821 %face $(t body.t)
57925822 %fn &($(t sample.t) $(t product.t))
@@ -5834,6 +5864,7 @@
58345864 ?- -.t
58355865 ?(%tag %nvar %rnvar %avar %rvar) !(hole-known t state)
58365866 %union |((lien cases.t |=(c=itype (hole-uncertain c state))) (lien args.t |=(c=itype (hole-uncertain c state))))
5867+ %grec (lien args.t |=(c=itype (hole-uncertain c state)))
58375868 %collection (lien args.t |=(c=itype (hole-uncertain c state)))
58385869 %face $(t body.t)
58395870 %fn |($(t sample.t) $(t product.t))
@@ -5870,6 +5901,7 @@
58705901 %union (zing (turn (weld args.t cases.t) |=(c=itype (itype-vars c))))
58715902 %recursive ~
58725903 %jrec ~
5904+ %grec (zing (turn args.t |=(c=itype (itype-vars c))))
58735905 %collection (zing (turn args.t |=(c=itype (itype-vars c))))
58745906 %face $(t body.t)
58755907 %fn (weld $(t sample.t) $(t product.t))
@@ -5918,6 +5950,7 @@
59185950 %union [%union (turn cases.t |=(c=itype (itype-rename c ren))) origin.t label.t (turn args.t |=(c=itype (itype-rename c ren)))]
59195951 %recursive t
59205952 %jrec t
5953+ %grec t(args (turn args.t |=(c=itype (itype-rename c ren))))
59215954 %collection [%collection name.t (turn args.t |=(c=itype (itype-rename c ren)))]
59225955 %face [%face name.t $(t body.t)]
59235956 %fn [%fn $(t sample.t) $(t product.t)]
@@ -5945,6 +5978,7 @@
59455978 %union |((lien cases.t |=(c=itype (itype-var-is-atom n c))) (lien args.t |=(c=itype (itype-var-is-atom n c))))
59465979 %recursive |
59475980 %jrec |
5981+ %grec (lien args.t |=(c=itype (itype-var-is-atom n c)))
59485982 %collection (lien args.t |=(c=itype (itype-var-is-atom n c)))
59495983 %face $(t body.t)
59505984 %fn |($(t sample.t) $(t product.t))
@@ -5968,6 +6002,7 @@
59686002 %union |((lien cases.t |=(c=itype (itype-var-is-restricted n c))) (lien args.t |=(c=itype (itype-var-is-restricted n c))))
59696003 %recursive |
59706004 %jrec |
6005+ %grec (lien args.t |=(c=itype (itype-var-is-restricted n c)))
59716006 %collection (lien args.t |=(c=itype (itype-var-is-restricted n c)))
59726007 %face $(t body.t)
59736008 %fn |($(t sample.t) $(t product.t))
@@ -6398,6 +6433,16 @@
63986433 ?: &(?=(~ vars.template) ?=(%jrec -.typ.template) =(at.typ.template origin) =(name.typ.template name)) `name.i.molds
63996434 $(molds t.molds)
64006435::
6436+++ grec-visible-alias
6437+ |= [origin=path name=term proof=shape args=(list itype) molds=imold-types]
6438+ ^- (unit term)
6439+ ?~ molds ~
6440+ =/ template=ischeme template.i.molds
6441+ ?. ?=(%grec -.typ.template) $(molds t.molds)
6442+ ?. &(=(at.typ.template origin) =(name.typ.template name) =(proof.typ.template proof)) $(molds t.molds)
6443+ ?. &((identity-union-parameters vars.template args.typ.template) =((lent vars.template) (lent args))) $(molds t.molds)
6444+ `name.i.molds
6445+::
64016446++ itype-in-import
64026447 |= [t=itype iface=ifile face=term prelude=(unit ifile)]
64036448 ^- itype
@@ -6417,6 +6462,11 @@
64176462 `(crip "{(trip u.alias)}.{(trip face)}")
64186463 [%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)))]
64196464 %recursive [%recursive module.t name.t ~]
6465+ %grec
6466+ =/ public=(unit term) ?~(prelude ~ (grec-visible-alias at.t name.t proof.t args.t molds.u.prelude))
6467+ =/ alias=(unit term) ?~(public (grec-visible-alias at.t name.t proof.t args.t molds.iface) public)
6468+ =/ label=(unit @t) ?~(alias ~ ?~(public `(crip "{(trip u.alias)}.{(trip face)}") `u.alias))
6469+ t(label label, args (turn args.t |=(c=itype (itype-in-import c iface face prelude))))
64206470 %jrec
64216471 =/ public=(unit term) ?~(prelude ~ (jrec-alias at.t name.t molds.u.prelude))
64226472 ?^ public t(label `u.public)
@@ -6529,9 +6579,29 @@
65296579 ?. =(names.tail ~[name]) ~
65306580 `[%jrec at.state name `name name.i.fs aura.shape.i.fs name.i.t.fs]
65316581::
6582+++ simple-source-generic-recursive
6583+ |= [name=term sh=shape args=(list itype) state=istate]
6584+ ^- (unit itype)
6585+ ?. ?=(%generic -.sh) ~
6586+ ?. ?=([@ ~] vars.sh) ~
6587+ ?. ?=([* ~] args) ~
6588+ ?~ grec-index.state ~
6589+ ?. =(at.u.grec-index.state at.state) ~
6590+ ?~ prelude.state ~
6591+ ?. =(prelude.u.grec-index.state u.prelude.state) ~
6592+ =/ proof=(unit shape) (~(get by shapes.u.grec-index.state) name)
6593+ ?~ proof ~
6594+ ?. =(u.proof sh) ~
6595+ `[%grec at.state name `name sh args]
6596+::
6597+
65326598++ infer-mold-template
65336599 |= [sh=shape state=istate]
65346600 ^- (unit [template=ischeme state=istate])
6601+ =/ generic=(unit itype)
6602+ ?. ?=([@ ~] active.state) ~
6603+ (simple-source-generic-recursive i.active.state sh ~[[%var next.state]] state)
6604+ ?^ generic `[[u.generic ~[next.state]] state(next +(next.state))]
65356605 =/ direct=(unit itype)
65366606 ?. ?=([@ ~] active.state) ~
65376607 (simple-source-recursive i.active.state sh state)
@@ -6744,6 +6814,8 @@
67446814 ?~ applied ~
67456815 `[u.applied state.u.args]
67466816 ?. ?=(%generic -.u.found) ~
6817+ =/ grec=(unit itype) (simple-source-generic-recursive n u.found types.u.args state.u.args)
6818+ ?^ grec `[u.grec state.u.args]
67476819 ?. (distinct-params vars.u.found) ~
67486820 =/ params=(unit iparams) (bind-params vars.u.found types.u.args)
67496821 ?~ params ~
@@ -8982,7 +9054,7 @@
89829054 ?~ t.names |
89839055 =. typ (itype-walk typ sub)
89849056 ?: ?=(%cell -.typ) $(typ tal.typ, names t.names)
8985− |(?=(%union -.typ) ?=(%collection -.typ) ?=(%recursive -.typ) ?=(%jrec -.typ) ?=(%noun -.typ) ?=(%fn -.typ) ?=(%tag -.typ))
9057+ |(?=(%union -.typ) ?=(%collection -.typ) ?=(%recursive -.typ) ?=(%jrec -.typ) ?=(%grec -.typ) ?=(%noun -.typ) ?=(%fn -.typ) ?=(%tag -.typ))
89869058::
89879059++ cell-binder-pattern
89889060 |= e=expr
@@ -9061,6 +9133,7 @@
90619133 "({(trip u.label.t)} {(show-itype-cases args.t sub)})"
90629134 %recursive ?~(label.t "recursive mold" (trip u.label.t))
90639135 %jrec ?~(label.t "recursive mold" (trip u.label.t))
9136+ %grec ?~(label.t "recursive mold" "({(trip u.label.t)} {(show-itype-cases args.t sub)})")
90649137 %collection "({(trip name.t)} {(show-itype-cases args.t sub)})"
90659138 %face "[{(trip name.t)}={(show-itype-context body.t sub)}]"
90669139 %fn "$-({(show-itype-context sample.t sub)} {(show-itype-context product.t sub)})"
@@ -9109,6 +9182,7 @@
91099182 %union |((lien cases.typ |=(c=itype (itype-has-nvar c))) (lien args.typ |=(c=itype (itype-has-nvar c))))
91109183 %recursive |
91119184 %jrec |
9185+ %grec (lien args.typ |=(c=itype (itype-has-nvar c)))
91129186 %collection (lien args.typ |=(c=itype (itype-has-nvar c)))
91139187 %face $(typ body.typ)
91149188 %fn |($(typ sample.typ) $(typ product.typ))
@@ -9225,6 +9299,7 @@
92259299 %union |((lien cases.t |=(c=itype (has-atom-var n c))) (lien args.t |=(c=itype (has-atom-var n c))))
92269300 %recursive |
92279301 %jrec |
9302+ %grec (lien args.t |=(c=itype (has-atom-var n c)))
92289303 %collection (lien args.t |=(c=itype (has-atom-var n c)))
92299304 %face $(t body.t)
92309305 %fn |($(t sample.t) $(t product.t))
@@ -9633,36 +9708,9 @@
96339708++ add-supported-defs
96349709 |= [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)]
96359710 ^- [env=ienv artifacts=(list iwidth-definition)]
9636− ?~ ds [env artifacts]
9637− =/ d=def i.ds
9638− ?: ?=(%mold -.d) $(ds t.ds)
9639− ?. (unique-value-name name.d globals) $(ds t.ds)
9640− ?^ (ienv-lookup name.d env) $(ds t.ds)
9641− =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9642− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~]
9643− =. gate-defs.initial checked
9644− =. head-evidence.initial heads
9645− =. initial (reserve-def-caps val.d initial)
9646− =/ result=iresult (infer-fragment val.d env initial)
9647− =? result ?=(%| -.result) (infer-recursive-gate d env initial)
9648− ?: ?=(%| -.result) $(ds t.ds)
9649− =. state.p.result (promote-restricted-numbers state.p.result env)
9650− =. 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)))
9651− ?^ (unresolved-hole holes.state.p.result holes.initial state.p.result) $(ds t.ds)
9652− ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
9653− =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
9654− ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
9655− ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
9656− =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
9657− ?: (gth (lent vars) 26) $(ds t.ds)
9658− =/ finalized=(unit (list iwprojection))
9659− (width-finalize projections.state.p.result sub.state.p.result vars)
9660− ?~ finalized $(ds t.ds)
9661− =? artifacts ?=(^ u.finalized)
9662− [[name.d val.d typ sub.state.p.result (flop u.finalized)] artifacts]
9663− =? checked |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) (~(put by checked) name.d d)
9664− $(ds t.ds, env [[name.d [typ vars]] env], checked checked)
9711+ (add-supported-defs-core ds all-defs checked heads env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts ~)
96659712::
9713+
96669714+$ iresolved [env=ienv grouped=(list term) artifacts=(list iwidth-definition)]
96679715+$ iadj (map term (list term))
96689716+$ ivisited (map term ?)
@@ -9776,6 +9824,46 @@
97769824++ resolve-groups
97779825 |= [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)]
97789826 ^- iresolved
9827+ (resolve-groups-core ds molds globals externals surs mark-externals marks jimports reserved-molds at prelude ~)
9828+::
9829+
9830+++ add-supported-defs-core
9831+ |= [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)])]
9832+ ^- [env=ienv artifacts=(list iwidth-definition)]
9833+ ?~ ds [env artifacts]
9834+ =/ d=def i.ds
9835+ ?: ?=(%mold -.d) $(ds t.ds)
9836+ ?. (unique-value-name name.d globals) $(ds t.ds)
9837+ ?^ (ienv-lookup name.d env) $(ds t.ds)
9838+ =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
9839+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~]
9840+ =. grec-index.initial index
9841+ =. gate-defs.initial checked
9842+ =. head-evidence.initial heads
9843+ =. initial (reserve-def-caps val.d initial)
9844+ =/ result=iresult (infer-fragment val.d env initial)
9845+ =? result ?=(%| -.result) (infer-recursive-gate d env initial)
9846+ ?: ?=(%| -.result) $(ds t.ds)
9847+ =. state.p.result (promote-restricted-numbers state.p.result env)
9848+ =. 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)))
9849+ ?^ (unresolved-hole holes.state.p.result holes.initial state.p.result) $(ds t.ds)
9850+ ?: (constrained-capitals caps.state.p.result sub.state.p.result) $(ds t.ds)
9851+ =/ typ=itype (default-decimals (itype-normalize typ.p.result sub.state.p.result))
9852+ ?: |((pending-tags tags.state.p.result sub.state.p.result) (itype-has-tag typ)) $(ds t.ds)
9853+ ?: (unsupported-atom-vars typ caps.state.p.result binders.state.p.result sub.state.p.result) $(ds t.ds)
9854+ =/ vars=(list @ud) (unique-type-vars (itype-vars typ))
9855+ ?: (gth (lent vars) 26) $(ds t.ds)
9856+ =/ finalized=(unit (list iwprojection))
9857+ (width-finalize projections.state.p.result sub.state.p.result vars)
9858+ ?~ finalized $(ds t.ds)
9859+ =? artifacts ?=(^ u.finalized)
9860+ [[name.d val.d typ sub.state.p.result (flop u.finalized)] artifacts]
9861+ =? checked |(?=(%gate -.val.d) ?=(%gate-wide -.val.d)) (~(put by checked) name.d d)
9862+ $(ds t.ds, env [[name.d [typ vars]] env], checked checked)
9863+::
9864+++ resolve-groups-core
9865+ |= [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)])]
9866+ ^- iresolved
97799867 =/ env=ienv ~
97809868 =/ grouped=(list term) ~
97819869 =/ artifacts=(list iwidth-definition) ~
@@ -9787,8 +9875,9 @@
97879875 =/ heads=(unit igate-prelude-evidence) (direct-prelude-evidence ds prelude)
97889876 |-
97899877 =/ next=[env=ienv artifacts=(list iwidth-definition)]
9790− (add-supported-defs ds ds (direct-checked-gates ds env) heads env molds globals externals surs mark-externals marks jimports reserved-molds at prelude artifacts)
9791− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~]
9878+ (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)
9879+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~]
9880+ =. grec-index.initial index
97929881 =/ out=iresolved (add-groups ds components graph env.next grouped artifacts.next initial)
97939882 ?: =(env env.out) out
97949883 $(env env.out, grouped grouped.out, artifacts artifacts.out)
@@ -10588,6 +10677,9 @@
1058810677 |= [typ=itype name=term vars=(list @ud)]
1058910678 ^- itype
1059010679 ?: ?=(%jrec -.typ) typ(label `name)
10680+ ?: ?=(%grec -.typ)
10681+ ?. (identity-union-parameters vars args.typ) typ(label ~)
10682+ typ(label `name)
1059110683 ?. ?=(%union -.typ) typ
1059210684 ?. (identity-union-parameters vars args.typ)
1059310685 ?~ origin.typ typ
@@ -10661,7 +10753,7 @@
1066110753 =/ source-unit=(unit ischeme)
1066210754 ?~ unit-decl ~
1066310755 =/ unit-molds=imolds ~[[%unit u.unit-decl]]
10664− =/ unit-state=istate [0 ~ ~ ~ unit-molds ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | /lib/jibb/prelude/jibb ~[%unit] ~ ~ 256 ~ ~ ~]
10756+ =/ unit-state=istate [0 ~ ~ ~ unit-molds ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | /lib/jibb/prelude/jibb ~[%unit] ~ ~ 256 ~ ~ ~ ~]
1066510757 =/ unit-types=imold-types (partial-prelude-molds unit-molds unit-state)
1066610758 =/ unit-iface=ifile [~ unit-types /lib/jibb/prelude/jibb ~ ~ ~ ~ ~]
1066710759 =/ found=(unit ischeme) (find-jibb-mold %unit unit-iface)
@@ -10676,7 +10768,7 @@
1067610768 =/ js=ijimports ~[[face.i.imports.mod primitive]]
1067710769 =/ reserved=(list term) ~[face.i.imports.mod]
1067810770 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
10679− =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ js reserved ~ ~ ~ | at top ~ ~ 256 ~ ~ ~]
10771+ =/ state=istate [0 ~ ~ ~ molds globals ~ ~ ~ ~ js reserved ~ ~ ~ | at top ~ ~ 256 ~ ~ ~ ~]
1068010772 =/ mts=(each imold-types @t) (module-mold-types molds state)
1068110773 =/ usable=(unit imold-types)
1068210774 ?: ?=(%& -.mts) `p.mts
@@ -10732,7 +10824,7 @@
1073210824 =? env-molds declared
1073310825 (skim molds |=(m=[name=term body=shape] !=(%list name.m)))
1073410826 =/ reserved=(list term) ?:(declared ~[%list] ~)
10735− =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ u.private reserved ~ ~ ~ | at names ~ ~ 256 ~ ~ ~]
10827+ =/ state=istate [0 ~ ~ ~ env-molds globals ~ ~ ~ ~ u.private reserved ~ ~ ~ | at names ~ ~ 256 ~ ~ ~ ~]
1073610828 :: Other prelude molds may use list only after its source has passed
1073710829 :: the standard-list check. The raw declaration remains removed.
1073810830 =/ declared-list=(unit shape) (find-simple-mold %list molds)
@@ -11261,7 +11353,7 @@
1126111353 =/ surs=(list term) (collect-sur-imports imports.mod)
1126211354 =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
1126311355 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11264− =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~]
11356+ =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~]
1126511357 =/ mts=(each imold-types @t) (module-mold-types molds state)
1126611358 ?: ?=(%| -.mts) [%| p.mts]
1126711359 =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
@@ -11295,7 +11387,7 @@
1129511387 =/ surs=(list term) (collect-sur-imports imports.mod)
1129611388 =/ reserved=(list term) (weld molds.prep (turn resolved.p.deps |=(j=[face=term interface=ifile] face.j)))
1129711389 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11298− =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~]
11390+ =/ state=istate [0 ~ ~ ~ molds globals externals surs marks declared resolved.p.deps reserved ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~]
1129911391 =/ mts=(each imold-types @t) (module-mold-types molds state)
1130011392 ?: ?=(%| -.mts) [%| p.mts]
1130111393 =/ resolution=iresolved (resolve-groups ordinary molds globals externals surs marks declared resolved.p.deps reserved file prelude)
@@ -11671,16 +11763,35 @@
1167111763 [%| (crip "module kind needs unsupported inference: {(spud at)}")]
1167211764 =/ js=jimports-result (resolve-jibb-imports imports.mod externals mark-externals modules active prelude-values prelude-molds cache prelude)
1167311765 ?: ?=(%| -.js) [%| p.js]
11674− =/ molds=imolds (collect-simple-molds defs.mod)
11766+ =/ collected=grec-collected
11767+ ?^ imports.mod [(collect-simple-molds defs.mod) *(map term shape)]
11768+ (grec-collect-molds defs.mod)
11769+ =/ molds=imolds molds.collected
1167511770 =/ globals=(list term) (weld prelude-values (weld (import-binding-names imports.mod) vals))
1167611771 =/ surs=(list term) (collect-sur-imports imports.mod)
1167711772 =/ marks=(list term) (collect-mark-imports imports.mod)
1167811773 =/ reserved=(list term) (weld prelude-molds (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
1167911774 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11680− =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude ~ 256 ~ ~ ~]
11775+ =/ state=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks resolved.p.js reserved ~ ~ ~ | at top prelude ~ 256 ~ ~ ~ ~]
11776+ :: Source and scope were checked above; preserve that exact root and prelude.
11777+ :: This first integration only indexes import-free library sources.
11778+ =/ index=(unit [at=path source=@t prelude=ifile shapes=(map term shape)])
11779+ ?^ imports.mod ~
11780+ ?~ prelude ~
11781+ =/ standard=(unit ischeme) (find-jibb-mold %list u.prelude)
11782+ ?~ standard ~
11783+ ?. =(u.standard [[%collection %list ~[[%var 0]]] ~[0]]) ~
11784+ =/ index=(map term shape) proofs.collected
11785+ ?. !=(index *(map term shape)) ~
11786+ ?: (lien molds |=(m=[name=term body=shape] =(%list name.m))) ~
11787+ `[at src u.prelude index]
11788+ =. grec-index.state index
1168111789 =/ mts=(each imold-types @t) (module-mold-types molds state)
1168211790 ?: ?=(%| -.mts) [%| (crip "{(trip p.mts)}: {(spud at)}")]
11683− =/ resolution=iresolved (resolve-groups defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
11791+ =/ resolution=iresolved
11792+ ?~ index
11793+ (resolve-groups defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude)
11794+ (resolve-groups-core defs.mod molds globals externals surs mark-externals marks resolved.p.js reserved at prelude index)
1168411795 =/ env=ienv env.resolution
1168511796 ?. (module-values-complete defs.mod env)
1168611797 [%| (crip "module definitions need unsupported inference: {(spud at)}")]
@@ -11733,7 +11844,7 @@
1173311844 =/ declared=(list term) (collect-mark-imports imports.mod)
1173411845 =/ reserved=(list term) (weld molds.u.prepared (turn resolved.p.js |=(j=[face=term interface=ifile] face.j)))
1173511846 =/ top=(list term) (turn ms |=(m=[name=term body=shape] name.m))
11736− =/ state=istate [0 ~ ~ ~ ms globals externals surs marks declared resolved.p.js reserved ~ ~ ~ | file top `public ~ 256 ~ ~ ~]
11847+ =/ state=istate [0 ~ ~ ~ ms globals externals surs marks declared resolved.p.js reserved ~ ~ ~ | file top `public ~ 256 ~ ~ ~ ~]
1173711848 =/ inferred=(unit [template=ischeme state=istate])
1173811849 (infer-mold-template shape.i.selected state(active ~[name], in-mold &))
1173911850 ?~ inferred [%| 'selected mold needs unsupported inference']
@@ -11871,7 +11982,7 @@
1187111982 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype typ ~)}{(show-atom-constraint typ)}")
1187211983 $(ds t.ds, lines [line lines])
1187311984 =/ top=(list term) (turn molds |=(m=[name=term body=shape] name.m))
11874− =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude ~ 256 ~ ~ ~]
11985+ =/ initial=istate [0 ~ ~ ~ molds globals externals surs mark-externals marks jimports reserved-molds ~ ~ ~ | file top prelude ~ 256 ~ ~ ~ ~]
1187511986 =. gate-defs.initial source-defs
1187611987 =. head-evidence.initial heads
1187711988 =. initial (reserve-def-caps val.d initial)
@@ -11913,4 +12024,79 @@
1191312024 =/ printable=itype (canonical-itype typ vars)
1191412025 =/ line=@t (crip "++ {(trip name.d)}: {(show-itype printable ~)}{(show-atom-constraint printable)}")
1191512026 $(ds t.ds, lines [line lines])
12027+:: Experimental per-module, source-derived recursive tree index.
12028+:: The two tags and the exact children/list/self layout are fixed-shape
12029+:: checks, so ordinary definitions incur no type-tree or source scans.
12030+++ grec-tagged-fields
12031+ |= sh=shape
12032+ ^- (unit [tag=@ fields=(list field)])
12033+ ?. ?=(%cell -.sh) ~
12034+ ?~ fields.sh ~
12035+ =/ head=field i.fields.sh
12036+ ?. ?=(%bare -.head) ~
12037+ ?. ?=(%const -.shape.head) ~
12038+ ?. &(?=(%term form.lit.shape.head) =(%tas aura.lit.shape.head)) ~
12039+ `[val.lit.shape.head t.fields.sh]
12040+++ grec-tree-children
12041+ |= [fs=(list field) param=@t]
12042+ ^- (unit field)
12043+ ?~ fs ~
12044+ ?~ t.fs `i.fs
12045+ ?^ t.t.fs ~
12046+ =/ event=field i.fs
12047+ =/ kids=field i.t.fs
12048+ ?. &(?=(%face -.event) ?=(%face -.kids)) ~
12049+ ?. !=(name.event name.kids) ~
12050+ ?. ?=(%fn -.shape.event) ~
12051+ ?. ?=(%aura -.sample.shape.event) ~
12052+ ?. =(%t aura.sample.shape.event) ~
12053+ ?. ?=(%tvar -.product.shape.event) ~
12054+ ?. =(param name.product.shape.event) ~
12055+ `kids
12056+::
12057+++ grec-tree-proof
12058+ |= [name=term sh=shape]
12059+ ^- ?
12060+ ?. ?=(%generic -.sh) |
12061+ ?. ?=([@ ~] vars.sh) |
12062+ =/ param=@t i.vars.sh
12063+ ?. ?=(%union -.body.sh) |
12064+ ?. ?=([* [* ~]] cases.body.sh) |
12065+ =/ a=(unit [tag=@ fields=(list field)]) (grec-tagged-fields i.cases.body.sh)
12066+ =/ b=(unit [tag=@ fields=(list field)]) (grec-tagged-fields i.t.cases.body.sh)
12067+ ?~ a |
12068+ ?~ b |
12069+ ?. !=(tag.u.a tag.u.b) |
12070+ ?. ?=([* ~] fields.u.a) |
12071+ =/ value=field i.fields.u.a
12072+ ?. ?=(%face -.value) |
12073+ ?. ?=(%aura -.shape.value) |
12074+ ?. =(%t aura.shape.value) |
12075+ =/ selected=(unit field) (grec-tree-children fields.u.b param)
12076+ ?~ selected |
12077+ =/ kids=field u.selected
12078+ ?. ?=(%face -.kids) |
12079+ ?. ?=(%apply -.shape.kids) |
12080+ ?. =(ref.shape.kids ~[%list]) |
12081+ ?. ?=([* ~] args.shape.kids) |
12082+ =/ self=shape i.args.shape.kids
12083+ ?. ?=(%apply -.self) |
12084+ ?. =(ref.self ~[name]) |
12085+ ?. ?=([* ~] args.self) |
12086+ ?. ?=(%tvar -.i.args.self) |
12087+ =(name.i.args.self param)
12088++$ grec-collected [molds=imolds proofs=(map term shape)]
12089+++ grec-collect-molds
12090+ |= ds=(list def)
12091+ ^- grec-collected
12092+ ?~ ds [~ *(map term shape)]
12093+ =/ rest=grec-collected $(ds t.ds)
12094+ ?. ?=(%mold -.i.ds) rest
12095+ =/ name=term name.i.ds
12096+ =/ body=shape shape.i.ds
12097+ =/ proofs=(map term shape) proofs.rest
12098+ =? proofs (grec-tree-proof name body) (~(put by proofs) name body)
12099+ [[[name body] molds.rest] proofs]
12100+::
12101+
1191612102--