++musk committed, still testing.

This commit is contained in:
C. Guy Yarvin 2017-11-21 19:55:32 -08:00
parent c78ed1b93c
commit b3245ae96b
4 changed files with 378 additions and 341 deletions

View File

@ -1,303 +1,4 @@
|%
::
++ musk :: nock with block set
=> |%
++ block
:: identity of resource awaited
::
noun
::
++ result
:: internal interpreter result
::
$@(~ seminoun)
::
++ seminoun
:: partial noun; blocked subtrees are ~
::
(pair stencil noun)
::
++ stencil
:: noun knowledge map
::
%+ each
:: yes; noun is either fully complete, or fully blocked
::
(set block)
:: no; noun has partial block substructure
::
(pair stencil stencil)
::
++ output
:: optional partial result
::
%- unit
:: complete noun or block set
::
(each noun (set block))
--
:: execute nock on partial subject
::
|= $: :: sub: subject, a partial noun
:: fol: formula, a complete noun
::
sub/seminoun
fol/noun
==
^- output
=< apex
|%
++ abet
:: simplify raw result
::
|= $: :: noy: raw result
::
noy/result
==
^- output
:: interpreter stopped
::
?~ noy ~
:: simplify internal result
::
[~ =+((squash p.noy) ?~(- [%& q.noy] [%| ~(tap in -)]))]
::
++ apex
:: simplify result
::
%- abet
:: interpreter loop
::
|- ^- result
?@ fol
:: bad formula, stop
::
~
?: ?=(^ -.fol)
:: hed: interpret head
::
=+ hed=$(fol -.fol)
:: propagate stop
::
?: ?=(~ -.hed) ~
:: tal: interpret tail
::
=+ tal=$(fol +.fol)
:: propagate stop
::
?: ?=(~ -.tal) ~
:: combine
::
`(combine +.hed +.tal)
?+ fol
:: bad formula; stop
::
~
:: 0; fragment
::
{$0 b/@}
:: if bad axis, stop
::
?: =(0 b.fol) ~
:: reduce to fragment
::
(fragment b.fol)
::
:: 1; constant
::
{$1 b/*}
:: constant is complete
::
`[[%& ~] b.fol]
::
:: 2; recursion
::
{$2 b/* c/*}
:: require complete formula
::
%+ require
:: compute formula with current subject
::
$(fol c.fol)
|= :: ryf: next formula
::
ryf/noun
:: lub: next subject
::
=+ lub=$(fol b.fol)
:: propagate stop
::
?~ lub ~
:: recurse
::
$(fol ryf, sub lub)
::
:: 3; probe
::
{$3 b/*}
%+ require
$(fol b.fol)
|= :: fig: probe input
::
fig/noun
:: yes if cell, no if atom
::
`[[%& ~] .?(fig)]
::
:: 4; increment
::
{$4 b/*}
%+ require
$(fol b.fol)
|= :: fig: increment input
::
fig/noun
:: stop for cells, increment for atoms
::
?^(fig ~ `[[%& ~] +(fig))
::
:: 5; compare
::
{$5 b/*}
%+ require
$(fol b.fol)
|= :: fig: operator input
::
fig/noun
:: stop for atoms, compare cells
::
?@(fig ~ `[[%& ~] =(-.fig +.fig))
::
:: 6; if-then-else
::
{$6 b/* c/* d/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b]))
::
:: 7; composition
::
{$7 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [2 b 1 c]))
::
:: 8; declaration
::
{$8 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [7 [[0 1] b] c]))
::
:: 9; invocation
::
{$9 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [7 c 0 b]))
::
:: 10; static hint
::
{$10 @ c/*}
:: ignore hint
::
$(fol c.fol)
::
:: 10; dynamic hint
::
{$10 {b/* c/*} d/*}
:: noy: dynamic hint
::
=+ noy=$(fol c.fol)
:: propagate stop
::
?~ noy ~
:: otherwise, ignore hint
::
$(fol d.fol)
--
:: require complete result
::
++ require
|= $: noy/result
yen/$-(noun result)
==
^- result
:: propagate stop
::
?~ noy ~
:: if partial block, squash blocks and stop
::
?: ?=($| -.p.noy) `[[%& (squash p.noy)] ~]
:: if full block, propagate block
::
?: ?=(^ p.p.noy) `[[%& p.p.noy] ~]
:: otherwise use complete noun
::
(yen q.noy)
::
++ squash
:: convert stencil to block set
::
|= tyn/stencil
^- (set block)
?- -.tyn
$& p.tyn
$| (~(uni in $(tyn p.tyn)) $(tyn q.tyn))
==
::
++ combine
:: combine a pair of seminouns
::
|= $: :: hed: head of pair
:: tal: tail of pair
::
hed/seminoun
tal/seminoun
==
?: &(?=($& p.hed) ?=($& p.tal))
:: yin: merged block set
::
=/ yin (~(uni in p.p.hed) p.p.tal
:- [%& yin]
:: don't accumulate stubs
::
?~(yin ~ [q.hed q.tal])
:: partial cell
::
[[%| p.hed p.tal] [q.hed q.tal]]
::
++ fragment
:: seek to an axis in a seminoun
::
|= $: :: axe: tree address of subtree
::
axe/axis
==
^- result
:: 1 is the root
::
?: =(1 axe) sub
:: now: 2 or 3, top of axis
:: lat: rest of axis
::
=+ [now=(cap axe) lat=(mas axe)]
?- -.p.sub
:: subject is fully blocked or complete
::
$& :: if fully blocked, produce self
::
?^ p.p.sub sub
:: descending into atom, stop
::
?@ q.sub ~
:: descend into complete cell
::
$(axe lat, sub [[%& ~] ?:(=(2 now) -.q.sub +.q.sub))
:: subject is partly blocked
::
$| :: descend into partial cell
::
$(axe lat, sub ?:(=(2 now) [p.p.sub -.q.sub] [q.p.sub +.q.sub]))
==
--
:- %say
|= *
:- %noun
=- "hello"

View File

@ -21,7 +21,7 @@
=+ txt=.^(@t %cx (weld pax `path`[%hoon ~]))
=+ rax=.^(@t %cx (weld arp `path`[%hoon ~]))
=+ ^= ken
=- ?>(?=($& -.res) p.res)
=- ?:(?=($& -.res) p.res ((slog p.res) ~))
^= res %- mule |.
~& %solid-loaded
=+ gen=(rain pax txt)

View File

@ -7,7 +7,6 @@
:::: 0: version stub ::
:: ::
~% %k.143 ~ ~ ::
!:
|%
++ hoon-version +
-- =>
@ -1550,7 +1549,6 @@
si:nl
::
++ nl
^%
|%
:: ::
++ le :: construct list
@ -5295,27 +5293,320 @@
|= {{sub/* fol/*} gul/$-({* *} (unit (unit)))}
(mook (mink [sub fol] gul))
::
:: ++ moop
:: |= pon/(list {@ta *}) ^+ pon
:: ?~ pon ~
:: :- i.pon
:: ?. ?=({$spot * ^} i.pon)
:: $(pon t.pon)
:: ?. ?=({{$spot * ^} *} t.pon)
:: $(pon t.pon)
:: => .(pon t.pon)
:: =+ sot=+.i.pon
:: |- ^- (list {@ta *})
:: ?. ?=({{$spot * ^} *} t.pon)
:: [[%spot sot] ^$(pon t.pon)]
:: =+ sop=+.i.pon
:: ?: ?& =(-.sop -.sot)
:: (lor +<.sop +<.sot)
:: (lor +>.sot +>.sop)
:: ==
:: $(sot sop, pon t.pon)
:: [[%spot sot] ^$(pon t.pon)]
::
++ musk :: nock with block set
=> |%
++ block
:: identity of resource awaited
:: XX parameterize
noun
::
++ result
:: internal interpreter result
::
$@(~ seminoun)
::
++ seminoun
:: partial noun; blocked subtrees are ~
::
{mask/stencil data/noun}
::
++ stencil
:: noun knowledge map
::
$% :: no; noun has partial block substructure
::
{$| left/stencil rite/stencil}
:: yes; noun is either fully complete, or fully blocked
::
{$& blocks/(set block)}
==
::
++ output
:: nil; interpreter stopped
::
%- unit
:: yes, complete noun; no, list of blocks
::
(each noun (list block))
--
|%
++ abet
:: simplify raw result
::
|= $: :: noy: raw result
::
noy/result
==
^- output
:: propagate stop
::
?~ noy ~
:- ~
:: merge all blocking sets
::
=/ blocks (squash mask.noy)
?: =(~ blocks)
:: no blocks, data is complete
::
&+data.noy
:: reduce block set to block list
::
|+~(tap in blocks)
::
++ apex
:: execute nock on partial subject
::
|= $: :: bus: subject, a partial noun
:: fol: formula, a complete noun
::
bus/seminoun
fol/noun
==
^- output
:: simplify result
::
%- abet
:: interpreter loop
::
|- ^- result
?@ fol
:: bad formula, stop
::
~
?: ?=(^ -.fol)
:: hed: interpret head
::
=+ hed=$(fol -.fol)
:: propagate stop
::
?~ hed ~
:: tal: interpret tail
::
=+ tal=$(fol +.fol)
:: propagate stop
::
?~ tal ~
:: combine
::
(combine hed tal)
?+ fol
:: bad formula; stop
::
~
:: 0; fragment
::
{$0 b/@}
:: if bad axis, stop
::
?: =(0 b.fol) ~
:: reduce to fragment
::
(fragment b.fol bus)
::
:: 1; constant
::
{$1 b/*}
:: constant is complete
::
[&+~ b.fol]
::
:: 2; recursion
::
{$2 b/* c/*}
:: require complete formula
::
%+ require
:: compute formula with current subject
::
$(fol c.fol)
|= :: ryf: next formula
::
ryf/noun
:: lub: next subject
::
=+ lub=^$(fol b.fol)
:: propagate stop
::
?~ lub ~
:: recurse
::
^$(fol ryf, bus lub)
::
:: 3; probe
::
{$3 b/*}
%+ require
$(fol b.fol)
|= :: fig: probe input
::
fig/noun
:: yes if cell, no if atom
::
[&+~ .?(fig)]
::
:: 4; increment
::
{$4 b/*}
%+ require
$(fol b.fol)
|= :: fig: increment input
::
fig/noun
:: stop for cells, increment for atoms
::
?^(fig ~ [&+~ +(fig)])
::
:: 5; compare
::
{$5 b/*}
%+ require
$(fol b.fol)
|= :: fig: operator input
::
fig/noun
:: stop for atoms, compare cells
::
?@(fig ~ [&+~ =(-.fig +.fig)])
::
:: 6; if-then-else
::
{$6 b/* c/* d/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b]))
::
:: 7; composition
::
{$7 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [2 b 1 c]))
::
:: 8; declaration
::
{$8 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [7 [[0 1] b] c]))
::
:: 9; invocation
::
{$9 b/* c/*}
:: use standard macro expansion (slow)
::
$(fol =>(fol [7 c 0 b]))
::
:: 10; static hint
::
{$10 @ c/*}
:: ignore hint
::
$(fol c.fol)
::
:: 10; dynamic hint
::
{$10 {b/* c/*} d/*}
:: noy: dynamic hint
::
=+ noy=$(fol c.fol)
:: propagate stop
::
?~ noy ~
:: otherwise, ignore hint
::
$(fol d.fol)
==
::
++ combine
:: combine a pair of seminouns
::
|= $: :: hed: head of pair
:: tal: tail of pair
::
hed/seminoun
tal/seminoun
==
?: &(?=($& -.mask.hed) ?=($& -.mask.tal))
:: yin: merged block set
::
=/ yin (~(uni in blocks.mask.hed) blocks.mask.tal)
:- &+yin
:: don't accumulate stubs
::
?~(yin ~ [data.hed data.tal])
:: partial cell
::
[|+[mask.hed mask.tal] [data.hed data.tal]]
::
++ fragment
:: seek to an axis in a seminoun
::
|= $: :: axe: tree address of subtree
:: bus: partial noun
::
axe/axis
bus/seminoun
==
^- result
:: 1 is the root
::
?: =(1 axe) bus
:: now: 2 or 3, top of axis
:: lat: rest of axis
::
=+ [now=(cap axe) lat=(mas axe)]
?- -.mask.bus
:: subject is fully blocked or complete
::
$& :: if fully blocked, produce self
::
?^ blocks.mask.bus bus
:: descending into atom, stop
::
?@ data.bus ~
:: descend into complete cell
::
$(axe lat, bus [&+~ ?:(=(2 now) -.data.bus +.data.bus)])
:: subject is partly blocked
::
$| :: descend into partial cell
::
%= $
axe lat
bus ?: =(2 now)
[left.mask.bus -.data.bus]
[rite.mask.bus +.data.bus]
== ==
:: require complete intermediate step
::
++ require
|= $: noy/result
yen/$-(noun result)
==
^- result
:: propagate stop
::
?~ noy ~
:: if partial block, squash blocks and stop
::
?: ?=($| -.mask.noy) [&+(squash mask.noy) ~]
:: if full block, propagate block
::
?: ?=(^ blocks.mask.noy) [mask.noy ~]
:: otherwise use complete noun
::
(yen data.noy)
::
++ squash
:: convert stencil to block set
::
|= tyn/stencil
^- (set block)
?- -.tyn
$& blocks.tyn
$| (~(uni in $(tyn left.tyn)) $(tyn rite.tyn))
==
--
++ mook
|= ton/tone
^- toon
@ -5652,6 +5943,16 @@
{$1 p/(list)} :: blocks
{$2 p/(list {@ta *})} :: error ~_s
== ::
++ tony :: ++tone done right
$% {$0 p/tine q/*} :: success
{$1 p/(set)} :: blocks
{$2 p/(list {@ta *})} :: error ~_s
== ::
++ tine :: partial noun
$@ $~ :: open
$% {$& p/tine q/tine} :: half-blocked
{$| p/(set)} :: fully blocked
== ::
++ tool $@(term tune) :: type decoration
++ tune :: complex
$: p/(map term (pair what (unit hoon))) :: aliases
@ -7108,6 +7409,7 @@
%rib rib
%vet vet
%fab fab
%blow blow
%burn burn
%busk busk
%buss buss
@ -7148,22 +7450,56 @@
==
=+ sut=`type`%noun
|%
++ blow
|= {gol/type gen/hoon}
^- {type nock}
=+ pro=(mint gol gen)
=+ bus=bran
~| mask.bus
=+ jon=(apex:musk bus q.pro)
?~ jon
~& %constant-stopped
!!
?. ?=($& -.u.jon)
~& %constant-blocked
!!
[p.pro [%1 p.u.jon]]
::
++ burn
=+ gil=*(set type)
|- ^- (unit)
?- sut
{$atom *} q.sut
{$cell *} %+ biff $(sut p.sut)
|=(a/* (biff ^$(sut q.sut) |=(b/* `[a b])))
{$core *} (biff $(sut p.sut) |=(* `[p.s.q.sut +<]))
{$face *} $(sut repo)
{$fork *} ~
{$help *} $(sut repo)
{$hold *} ?: (~(has in gil) sut)
~
$(sut repo, gil (~(put in gil) sut))
$noun ~
$void ~
{$atom *} q.sut
{$cell *} %+ biff $(sut p.sut)
|=(a/* (biff ^$(sut q.sut) |=(b/* `[a b])))
{$core *} (biff $(sut p.sut) |=(* `[p.s.q.sut +<]))
{$face *} $(sut repo)
{$fork *} ~
{$help *} $(sut repo)
{$hold *} ?: (~(has in gil) sut)
~
$(sut repo, gil (~(put in gil) sut))
$noun ~
$void ~
==
++ bran
=+ gil=*(set type)
|- ^- seminoun:musk
?- sut
$noun [&+[~ ~ ~] ~]
$void [&+[~ ~ ~] ~]
{$atom *} ?~(q.sut [&+[~ ~ ~] ~] [&+~ u.q.sut])
{$cell *} (combine:musk $(sut p.sut) $(sut q.sut))
{$core *} %+ combine:musk
$(sut p.sut)
?~ p.s.q.sut [&+[~ ~ ~] ~]
[&+~ p.s.q.sut]
{$face *} $(sut repo)
{$fork *} [&+[~ ~ ~] ~]
{$help *} $(sut repo)
{$hold *} ?: (~(has in gil) sut)
[&+[~ ~ ~] ~]
$(sut repo, gil (~(put in gil) sut))
==
::
++ busk
@ -7907,7 +8243,8 @@
=+ tal=$(gen q.gen, gol %noun)
[(nice (cell p.hed p.tal)) (cons q.hed q.tal)]
::
{$ktcn *} $(fab |, gen p.gen)
{$ktcn *} (blow gol p.gen)
:: {$ktcn *} $(fab |, gen p.gen)
{$brcn *} (grow %gold [%$ 1] p.gen q.gen)
::
{$cnts *} (~(mint et p.gen q.gen) gol)

View File

@ -1,4 +1,3 @@
^%
::
:: dill (4d), terminal handling
::