on master help sign in
init
commit7b5bbd7b8102f4cacbb443cebf0561c740610ae3 authoriko <mail@iko.soy> dateThu 27 Jul 2023, 14:59 (3 years ago)
14 files changed+932
zod/seax/app/seax.hoon+144 zod/seax/desk.bill+2 zod/seax/lib/dbug.hoon+155 zod/seax/lib/de-html.hoon+101 zod/seax/lib/extract-links.hoon+29 zod/seax/lib/extract-text.hoon+42 zod/seax/lib/words.hoon+18 zod/seax/mar/bill.hoon+34 zod/seax/mar/hoon.hoon+49 zod/seax/mar/kelvin.hoon+28 zod/seax/mar/mime.hoon+32 zod/seax/mar/noun.hoon+22 zod/seax/mar/txt.hoon+275 zod/seax/sys.kelvin+1
zod/seax/app/seax.hoonnew file+144
@@ -0,0 +1,144 @@
1+/+ extract-text, extract-links, words, dbug
2+
3+|%
4+ +$ url @t
5+ +$ word @t
6+ +$ number-of-hits @u
7+ +$ number-of-hits-mop ((mop number-of-hits (set url)) gth)
8+ +$ search-index (map word number-of-hits-mop)
9+ +$ state-0
10+ $:
11+ rwi=search-index
12+ to-crawl=(list [url=url depth=@u])
13+ ==
14+ +$ poke
15+ $%
16+ [%start-crawl url=url]
17+ [%crawl-next ~]
18+ ==
19+ ++ urls-per-hits
20+ ((on number-of-hits (set url)) gth)
21+ ++ normalize-word
22+ |= word=tape
23+ ^- tape
24+ (cass word)
25+ ++ initial-crawl-depth 2
26+ ++ swap
27+ |* [a=* b=*]
28+ [b a]
29+ ++ second
30+ |* [a=* b=*]
31+ b
32+ ++ add-index
33+ |= [index=search-index new-words=(map word number-of-hits) =url]
34+ %- second
35+ ^- [(list ~) search-index]
36+ %^ spin ~(tap by new-words) index
37+ |= [[=word =number-of-hits] index=search-index]
38+ :- ~
39+ ^- search-index
40+ =/ existing-number-of-hits (~(get by index) word)
41+ ?~ existing-number-of-hits
42+ %+ ~(put by index) word
43+ (gas:urls-per-hits *number-of-hits-mop ~[[number-of-hits (silt ~[url])]])
44+ =/ existing-number-of-hits
45+ ^- number-of-hits-mop
46+ +.existing-number-of-hits
47+ =/ urls (get:urls-per-hits existing-number-of-hits number-of-hits)
48+ ?~ urls
49+ %+ ~(put by index) word
50+ (put:urls-per-hits existing-number-of-hits number-of-hits (silt ~[url]))
51+ =/ urls ^- (set ^url) +.urls
52+ %+ ~(put by index) word
53+ %^ put:urls-per-hits existing-number-of-hits
54+ number-of-hits (~(put in urls) url)
55+--
56+
57+=/ state *state-0
58+
59+^- agent:gall
60+%- agent:dbug
61+|_ =bowl:gall
62++* this .
63+++ on-init `..on-init
64+++ on-save !>(state)
65+++ on-load
66+ |= =vase
67+ =/ state !<(state-0 vase)
68+ `this(state state)
69+++ on-poke
70+ |= =cage
71+ ^- (quip card:agent:gall _this)
72+ ?+ -.cage !!
73+ %noun
74+ =/ poke !<(poke +.cage)
75+ ?- -.poke
76+ %start-crawl
77+ =/ url url.poke
78+ =/ req
79+ ^- task:iris
80+ [%request [%'GET' url ~ ~] *outbound-config:iris]
81+ :_ this
82+ ~[[%pass ~[%crawl-page (scot %ud initial-crawl-depth) url] %arvo %i req]]
83+ ::
84+ %crawl-next
85+ ?~ to-crawl.state `this
86+ =/ req
87+ ^- task:iris
88+ [%request [%'GET' url.i.to-crawl.state ~ ~] *outbound-config:iris]
89+ :_ this(to-crawl.state t.to-crawl.state)
90+ ~[[%pass ~[%crawl-page (scot %ud depth.i.to-crawl.state) url.i.to-crawl.state] %arvo %i req]]
91+ ==
92+
93+ ==
94+++ on-watch |=(path !!)
95+++ on-leave |=(path `..on-init)
96+++ on-peek |=(path ~)
97+++ on-agent |=([wire sign:agent:gall] !!)
98+++ on-arvo
99+ |= [=wire =sign-arvo]
100+ ^- (quip card:agent:gall _this)
101+ ?+ wire !!
102+ [%crawl-page @t @t ~]
103+ ~& "crawling {<+>-.wire>}"
104+ ?> ?=([%iris %http-response %finished *] sign-arvo)
105+ =/ url=@t +>-.wire
106+ =/ depth=@u (slav %ud +<.wire)
107+ =/ purl (need (de-purl:html url))
108+ =/ response-body
109+ %- trip q.data:(need full-file:client-response.sign-arvo)
110+ =/ words
111+ ^- (unit (list tape))
112+ %+ bind
113+ (extract-text response-body)
114+ |= text=tape
115+ (turn (words text) normalize-word)
116+ =/ word-index-map
117+ ^- (unit (list (map cord @u)))
118+ %+ bind words
119+ |= words=(list tape)
120+ %+ turn words
121+ |= word=tape
122+ %- malt ~[[(crip word) 1]]
123+ =/ word-index
124+ ^- (map word number-of-hits)
125+ ?~ word-index-map *(map word number-of-hits)
126+ %+ roll `(list (map cord @u))`+.word-index-map
127+ |= [lhs=(map cord @u) rhs=(map cord @u)]
128+ %- %- ~(uno by lhs) rhs
129+ |= [* a=@u b=@u] (add a b)
130+ =/ index (add-index rwi.state word-index url)
131+ =/ links=(list tape) (extract-links p.purl response-body)
132+ =/ next-depth (dec depth)
133+ =/ to-crawl
134+ ?~ next-depth to-crawl.state
135+ %+ weld
136+ to-crawl.state
137+ %+ turn links
138+ |= link=tape [(crip link) next-depth]
139+ :_ this(to-crawl.state to-crawl, rwi.state index)
140+ ~[[%pass / %agent [our.bowl %seax] %poke [%noun !>((poke [%crawl-next ~]))]]]
141+ ==
142+++ on-fail |=([term tang] `..on-init)
143+--
144+
zod/seax/desk.billnew file+2
@@ -0,0 +1,2 @@
1+:~ %seax
2+==
zod/seax/lib/dbug.hoonnew file+155
@@ -0,0 +1,155 @@
1+:: dbug: agent wrapper for generic debugging tools
2+::
3+:: usage: %-(agent:dbug your-agent)
4+::
5+|%
6++$ poke
7+ $% [%bowl ~]
8+ [%state grab=cord]
9+ [%incoming =about]
10+ [%outgoing =about]
11+ ==
12+::
13++$ about
14+ $@ ~
15+ $% [%ship =ship]
16+ [%path =path]
17+ [%wire =wire]
18+ [%term =term]
19+ ==
20+::
21+++ agent
22+ |= =agent:gall
23+ ^- agent:gall
24+ !.
25+ |_ =bowl:gall
26+ +* this .
27+ ag ~(. agent bowl)
28+ ::
29+ ++ on-poke
30+ |= [=mark =vase]
31+ ^- (quip card:agent:gall agent:gall)
32+ ?. ?=(%dbug mark)
33+ =^ cards agent (on-poke:ag mark vase)
34+ [cards this]
35+ =/ dbug
36+ !<(poke vase)
37+ =; =tang
38+ ((%*(. slog pri 1) tang) [~ this])
39+ ?- -.dbug
40+ %bowl [(sell !>(bowl))]~
41+ ::
42+ %state
43+ =? grab.dbug =('' grab.dbug) '-'
44+ =; product=^vase
45+ [(sell product)]~
46+ =/ state=^vase
47+ :: if the underlying app has implemented a /dbug/state scry endpoint,
48+ :: use that vase in place of +on-save's.
49+ ::
50+ =/ result=(each ^vase tang)
51+ (mule |.(q:(need (need (on-peek:ag /x/dbug/state)))))
52+ ?:(?=(%& -.result) p.result on-save:ag)
53+ %+ slap
54+ (slop state !>([bowl=bowl ..zuse]))
55+ (ream grab.dbug)
56+ ::
57+ %incoming
58+ =; =tang
59+ ?^ tang tang
60+ [%leaf "no matching subscriptions"]~
61+ %+ murn
62+ %+ sort ~(tap by sup.bowl)
63+ |= [[* a=[=ship =path]] [* b=[=ship =path]]]
64+ (aor [path ship]:a [path ship]:b)
65+ |= [=duct [=ship =path]]
66+ ^- (unit tank)
67+ =; relevant=?
68+ ?. relevant ~
69+ `>[path=path from=ship duct=duct]<
70+ ?: ?=(~ about.dbug) &
71+ ?- -.about.dbug
72+ %ship =(ship ship.about.dbug)
73+ %path ?=(^ (find path.about.dbug path))
74+ %wire %+ lien duct
75+ |=(=wire ?=(^ (find wire.about.dbug wire)))
76+ %term !!
77+ ==
78+ ::
79+ %outgoing
80+ =; =tang
81+ ?^ tang tang
82+ [%leaf "no matching subscriptions"]~
83+ %+ murn
84+ %+ sort ~(tap by wex.bowl)
85+ |= [[[a=wire *] *] [[b=wire *] *]]
86+ (aor a b)
87+ |= [[=wire =ship =term] [acked=? =path]]
88+ ^- (unit tank)
89+ =; relevant=?
90+ ?. relevant ~
91+ `>[wire=wire agnt=[ship term] path=path ackd=acked]<
92+ ?: ?=(~ about.dbug) &
93+ ?- -.about.dbug
94+ %ship =(ship ship.about.dbug)
95+ %path ?=(^ (find path.about.dbug path))
96+ %wire ?=(^ (find wire.about.dbug wire))
97+ %term =(term term.about.dbug)
98+ ==
99+ ==
100+ ::
101+ ++ on-peek
102+ |= =path
103+ ^- (unit (unit cage))
104+ ?. ?=([@ %dbug *] path)
105+ (on-peek:ag path)
106+ ?+ path [~ ~]
107+ [%u %dbug ~] ``noun+!>(&)
108+ [%x %dbug %state ~] ``noun+!>(on-save:ag)
109+ [%x %dbug %subscriptions ~] ``noun+!>([wex sup]:bowl)
110+ ==
111+ ::
112+ ++ on-init
113+ ^- (quip card:agent:gall agent:gall)
114+ =^ cards agent on-init:ag
115+ [cards this]
116+ ::
117+ ++ on-save on-save:ag
118+ ::
119+ ++ on-load
120+ |= old-state=vase
121+ ^- (quip card:agent:gall agent:gall)
122+ =^ cards agent (on-load:ag old-state)
123+ [cards this]
124+ ::
125+ ++ on-watch
126+ |= =path
127+ ^- (quip card:agent:gall agent:gall)
128+ =^ cards agent (on-watch:ag path)
129+ [cards this]
130+ ::
131+ ++ on-leave
132+ |= =path
133+ ^- (quip card:agent:gall agent:gall)
134+ =^ cards agent (on-leave:ag path)
135+ [cards this]
136+ ::
137+ ++ on-agent
138+ |= [=wire =sign:agent:gall]
139+ ^- (quip card:agent:gall agent:gall)
140+ =^ cards agent (on-agent:ag wire sign)
141+ [cards this]
142+ ::
143+ ++ on-arvo
144+ |= [=wire =sign-arvo]
145+ ^- (quip card:agent:gall agent:gall)
146+ =^ cards agent (on-arvo:ag wire sign-arvo)
147+ [cards this]
148+ ::
149+ ++ on-fail
150+ |= [=term =tang]
151+ ^- (quip card:agent:gall agent:gall)
152+ =^ cards agent (on-fail:ag term tang)
153+ [cards this]
154+ --
155+--
zod/seax/lib/de-html.hoonnew file+101
@@ -0,0 +1,101 @@
1+=< |=(a=cord (rush a (star apex)))
2+|_ ent=_`(map term @t)`[[%apos '\''] ~ ~]
3+:: :: ++apex:de-xml:html
4+++ apex :: top level
5+ =+ spa=;~(pose comt whit)
6+ %+ knee *manx |. ~+
7+ %+ ifix
8+ [;~(plug (punt decl) (star spa)) (star spa)]
9+ ;~ pose
10+ %+ sear |=([a=marx b=marl c=mane] ?.(=(c n.a) ~ (some [a b])))
11+ ;~(plug head many tail)
12+ ;~(plug head many)
13+ empt
14+ ==
15+:: :: ++attr:de-xml:html
16+++ attr :: attributes
17+ %+ knee *mart |. ~+
18+ %- star
19+ ;~ plug
20+ ;~(pfix (plus whit) name)
21+ ;~ pose
22+ %+ ifix
23+ :_ doq
24+ ;~(plug (ifix [. .]:(star whit) tis) doq)
25+ (star ;~(less doq escp))
26+ ::
27+ %+ ifix
28+ :_ soq
29+ ;~(plug (ifix [. .]:(star whit) tis) soq)
30+ (star ;~(less soq escp))
31+ ::
32+ (easy ~)
33+ ==
34+ ==
35+:: :: ++cdat:de-xml:html
36+++ cdat :: CDATA section
37+ %+ cook
38+ |=(a=tape ^-(mars ;/(a)))
39+ %+ ifix
40+ [(jest '<![CDATA[') (jest ']]>')]
41+ %- star
42+ ;~(less (jest ']]>') next)
43+:: :: ++chrd:de-xml:html
44+++ chrd :: character data
45+ %+ cook |=(a=tape ^-(mars ;/(a)))
46+ (plus ;~(pose (just `@`10) escp))
47+:: :: ++comt:de-xml:html
48+++ comt :: comments
49+ =- (ifix [(jest '<!--') (jest '-->')] (star -))
50+ ;~ pose
51+ ;~(less hep prn)
52+ whit
53+ ;~(less (jest '-->') hep)
54+ ==
55+::
56+++ decl :: ++decl:de-xml:html
57+ %+ ifix :: XML declaration
58+ [(jest '<?xml') (jest '?>')]
59+ %- star
60+ ;~(less (jest '?>') prn)
61+:: :: ++escp:de-xml:html
62+++ escp ::
63+ ;~(pose ;~(less gal gar pam prn) enty)
64+:: :: ++enty:de-xml:html
65+++ enty :: entity
66+ %+ ifix pam^mic
67+ ;~ pose
68+ =+ def=^+(ent (my:nl [%gt '>'] [%lt '<'] [%amp '&'] [%quot '"'] ~))
69+ %+ sear ~(get by (~(uni by def) ent))
70+ (cook crip ;~(plug alf (stun 1^31 aln)))
71+ %+ cook |=(a=@c ?:((gth a 0x10.ffff) '�' (tuft a)))
72+ =< ;~(pfix hax ;~(pose - +))
73+ :- (bass 10 (stun 1^8 dit))
74+ (bass 16 ;~(pfix (mask "xX") (stun 1^8 hit)))
75+ ==
76+:: :: ++empt:de-xml:html
77+++ empt :: self-closing tag
78+ %+ ifix [gal (jest '/>')]
79+ ;~(plug ;~(plug name attr) (cold ~ (star whit)))
80+:: :: ++head:de-xml:html
81+++ head :: opening tag
82+ (ifix [gal gar] ;~(plug name attr))
83+:: :: ++many:de-xml:html
84+++ many :: contents
85+ ;~(pfix (star comt) (star ;~(sfix ;~(pose apex chrd cdat) (star comt))))
86+:: :: ++name:de-xml:html
87+++ name :: tag name
88+ =+ ^= chx
89+ %+ cook crip
90+ ;~ plug
91+ ;~(pose cab alf (just ' ') (just '!'))
92+ (star ;~(pose cab dot alp))
93+ ==
94+ ;~(pose ;~(plug ;~(sfix chx col) chx) chx)
95+:: :: ++tail:de-xml:html
96+++ tail :: closing tag
97+ (ifix [(jest '</') gar] name)
98+:: :: ++whit:de-xml:html
99+++ whit :: whitespace
100+ (mask ~[' ' `@`0x9 `@`0xa `@`0xd])
101+--
zod/seax/lib/extract-links.hoonnew file+29
@@ -0,0 +1,29 @@
1+=<
2+|= [root=hart:eyre html=tape]
3+^- (list tape)
4+=/ root-url=tape
5+ %- en-purl:^html
6+ [root *pork:eyre *quay:eyre]
7+=/ links (rust html apex)
8+?~ links ~
9+%+ turn `(list tape)`+.links
10+|= link=tape
11+?~ (de-purl:^html (crip link))
12+ (weld root-url link)
13+link
14+::
15+|%
16+++ apex
17+ ;~ pfix
18+ %- star not-href
19+ %- star ;~(sfix href (star not-href))
20+ ==
21+++ not-href
22+ ;~(less (jest 'href') next)
23+++ href
24+ ;~(pfix (jest 'href=') quote url)
25+++ url
26+ (star ;~(less quote (just '#') next))
27+++ quote
28+ ;~(pose (just '"') (just '\''))
29+--
zod/seax/lib/extract-text.hoonnew file+42
@@ -0,0 +1,42 @@
1+=<
2+|= html=tape
3+^- (unit tape)
4+=/ processed-html
5+ %+ drop-tag "script"
6+ %+ drop-tag "style"
7+ html
8+=/ parse-result
9+ ^- (unit (list tape))
10+ %+ rust processed-html apex
11+=/ fragments (skip ((list tape) +.parse-result) is-all-whitespace)
12+`(zing (join " " fragments))
13+|%
14+++ apex
15+ %- star
16+ ;~(pfix (star tag) not-tag)
17+++ tag
18+ (ifix [gal gar] (plus ;~(less gar next)))
19+++ not-tag
20+ (plus ;~(less gal next))
21+++ is-whitespace
22+ |= text=@t
23+ ^- ?
24+ ?! ?=(~ (rush text ;~(pose ;~(less prn next) gaw)))
25+++ is-all-whitespace
26+ |= =tape
27+ ^- ?
28+ %+ levy tape is-whitespace
29+++ drop-tag
30+ |= [tag=tape html=tape]
31+ ^- tape
32+ =/ start (find "<{tag}" html)
33+ ?~ start html
34+ =/ end-tag "</{tag}>"
35+ =/ end (find end-tag html)
36+ ?~ end html
37+ ?: (lth +.end +.start) html :: Malformed html
38+ =/ removed-one %+ weld
39+ (scag +.start html)
40+ (slag (add +.end (lent end-tag)) html)
41+ $(html removed-one)
42+--
zod/seax/lib/words.hoonnew file+18
@@ -0,0 +1,18 @@
1+=<
2+|= haystack=tape
3+^- (list tape)
4+(scan haystack apex)
5+::
6+|%
7+++ apex
8+ ;~ pfix
9+ (star whit)
10+ %- star
11+ ;~ sfix
12+ (plus ;~(less whit next))
13+ (star whit)
14+ ==
15+ ==
16+++ whit
17+ (mask ~[' ' `@`0x9 `@`0xa `@`0xd])
18+--
zod/seax/mar/bill.hoonnew file+34
@@ -0,0 +1,34 @@
1+|_ bil=(list dude:gall)
2+++ grow
3+ |%
4+ ++ mime `^mime`[/text/x-bill (as-octs:mimes:html hoon)]
5+ ++ noun bil
6+ ++ hoon
7+ ^- @t
8+ |^ (crip (of-wall:format (wrap-lines (spit-duz bil))))
9+ ::
10+ ++ wrap-lines
11+ |= taz=wall
12+ ^- wall
13+ ?~ taz ["~"]~
14+ :- (weld ":~ " i.taz)
15+ %- snoc :_ "=="
16+ (turn t.taz |=(t=tape (weld " " t)))
17+ ::
18+ ++ spit-duz
19+ |= duz=(list dude:gall)
20+ ^- wall
21+ (turn duz |=(=dude:gall ['%' (trip dude)]))
22+ --
23+ ++ txt (to-wain:format hoon)
24+ --
25+++ grab
26+ |%
27+ ++ noun (list dude:gall)
28+ ++ mime
29+ |= [=mite len=@ud tex=@]
30+ ~_ tex
31+ !<((list dude:gall) (slap !>(~) (ream tex)))
32+ --
33+++ grad %noun
34+--
zod/seax/mar/hoon.hoonnew file+49
@@ -0,0 +1,49 @@
1+:::: /hoon/hoon/mar
2+ ::
3+/? 310
4+::
5+=, eyre
6+|_ own=@t
7+::
8+++ grow :: convert to
9+ |%
10+ ++ mime `^mime`[/text/x-hoon (as-octs:mimes:html own)] :: convert to %mime
11+ ++ elem :: convert to %html
12+ ;div:pre(urb_codemirror "", mode "hoon"):"{(trip own)}"
13+ :: =+ gen-id="src-{<`@ui`(mug own)>}"
14+ :: ;div
15+ :: ;textarea(id "{gen-id}"):"{(trip own)}"
16+ :: ;script:"""
17+ :: CodeMirror.fromTextArea(
18+ :: window[{<gen-id>}],
19+ :: \{lineNumbers:true, readOnly:true}
20+ :: )
21+ :: """
22+ :: ==
23+ ++ hymn
24+ :: ;html:(head:title:"Source" "+{elem}")
25+ ;html
26+ ;head
27+ ;title:"Source"
28+ ;script@"//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.js";
29+ ;script@"/lib/syntax/hoon.js";
30+ ;link(rel "stylesheet", href "//cdnjs.cloudflare.com/ajax/libs/".
31+ "codemirror/4.3.0/codemirror.min.css");
32+ ;link/"/lib/syntax/codemirror.css"(rel "stylesheet");
33+ ==
34+ ;body
35+ ;textarea#src:"{(trip own)}"
36+ ;script:'CodeMirror.fromTextArea(src, {lineNumbers:true, readOnly:true})'
37+ ==
38+ ==
39+ ++ txt
40+ (to-wain:format own)
41+ --
42+++ grab
43+ |% :: convert from
44+ ++ mime |=([p=mite q=octs] q.q)
45+ ++ noun @t :: clam from %noun
46+ ++ txt of-wain:format
47+ --
48+++ grad %txt
49+--
zod/seax/mar/kelvin.hoonnew file+28
@@ -0,0 +1,28 @@
1+|_ kal=waft:clay
2+++ grow
3+ |%
4+ ++ mime `^mime`[/text/x-kelvin (as-octs:mimes:html hoon)]
5+ ++ noun kal
6+ ++ hoon
7+ %+ rap 3
8+ %+ turn
9+ %+ sort
10+ ~(tap in (waft-to-wefts:clay kal))
11+ |= [a=weft b=weft]
12+ ?: =(lal.a lal.b)
13+ (gte num.a num.b)
14+ (gte lal.a lal.b)
15+ |= =weft
16+ (rap 3 '[%' (scot %tas lal.weft) ' ' (scot %ud num.weft) ']\0a' ~)
17+ ::
18+ ++ txt (to-wain:format hoon)
19+ --
20+++ grab
21+ |%
22+ ++ noun waft:clay
23+ ++ mime
24+ |= [=mite len=@ud tex=@]
25+ (cord-to-waft:clay tex)
26+ --
27+++ grad %noun
28+--
zod/seax/mar/mime.hoonnew file+32
@@ -0,0 +1,32 @@
1+::
2+:::: /hoon/mime/mar
3+ ::
4+/? 310
5+::
6+|_ own=mime
7+++ grow
8+ ^?
9+ |%
10+ ++ jam `@`q.q.own
11+ --
12+::
13+++ grab :: convert from
14+ ^?
15+ |%
16+ ++ noun mime :: clam from %noun
17+ ++ tape
18+ |=(a=_"" [/application/x-urb-unknown (as-octt:mimes:html a)])
19+ --
20+++ grad
21+ ^?
22+ |%
23+ ++ form %mime
24+ ++ diff |=(mime +<)
25+ ++ pact |=(mime +<)
26+ ++ join |=([mime mime] `(unit mime)`~)
27+ ++ mash
28+ |= [[ship desk mime] [ship desk mime]]
29+ ^- mime
30+ ~|(%mime-mash !!)
31+ --
32+--
zod/seax/mar/noun.hoonnew file+22
@@ -0,0 +1,22 @@
1+::
2+:::: /hoon/noun/mar
3+ ::
4+/? 310
5+!:
6+:::: A minimal noun mark
7+|_ non=*
8+++ grab |%
9+ ++ noun *
10+ --
11+++ grow |%
12+ ++ mime [/application/x-urb-jam (as-octs:mimes:html (jam non))]
13+ --
14+++ grad
15+ |%
16+ ++ form %noun
17+ ++ diff |=(* +<)
18+ ++ pact |=(* +<)
19+ ++ join |=([* *] *(unit *))
20+ ++ mash |=([[ship desk *] [ship desk *]] `*`~|(%noun-mash !!))
21+ --
22+--
zod/seax/mar/txt.hoonnew file+275
@@ -0,0 +1,275 @@
1+::
2+:::: /hoon/txt/mar
3+ ::
4+/? 310
5+::
6+=, clay
7+=, differ
8+=, format
9+=, mimes:html
10+|_ txt=wain
11+::
12+++ grab :: convert from
13+ |%
14+ ++ mime |=((pair mite octs) (to-wain q.q))
15+ ++ noun wain :: clam from %noun
16+ --
17+++ grow
18+ => v=.
19+ |%
20+ ++ mime => v [/text/plain (as-octs (of-wain txt))]
21+ ++ elem => v ;pre: {(trip (of-wain txt))}
22+ --
23+++ grad
24+ |%
25+ ++ form %txt-diff
26+ ++ diff
27+ |= tyt=wain
28+ ^- (urge cord)
29+ (lusk txt tyt (loss txt tyt))
30+ ::
31+ ++ pact
32+ |= dif=(urge cord)
33+ ~| [%pacting dif]
34+ ^- wain
35+ (lurk txt dif)
36+ ::
37+ ++ join
38+ |= [ali=(urge cord) bob=(urge cord)]
39+ ^- (unit (urge cord))
40+ |^
41+ =. ali (clean ali)
42+ =. bob (clean bob)
43+ |- ^- (unit (urge cord))
44+ ?~ ali `bob
45+ ?~ bob `ali
46+ ?- -.i.ali
47+ %&
48+ ?- -.i.bob
49+ %&
50+ ?: =(p.i.ali p.i.bob)
51+ %+ bind $(ali t.ali, bob t.bob)
52+ |=(cud=(urge cord) [i.ali cud])
53+ ?: (gth p.i.ali p.i.bob)
54+ %+ bind $(p.i.ali (sub p.i.ali p.i.bob), bob t.bob)
55+ |=(cud=(urge cord) [i.bob cud])
56+ %+ bind $(ali t.ali, p.i.bob (sub p.i.bob p.i.ali))
57+ |=(cud=(urge cord) [i.ali cud])
58+ ::
59+ %|
60+ ?: =(p.i.ali (lent p.i.bob))
61+ %+ bind $(ali t.ali, bob t.bob)
62+ |=(cud=(urge cord) [i.bob cud])
63+ ?: (gth p.i.ali (lent p.i.bob))
64+ %+ bind $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob)
65+ |=(cud=(urge cord) [i.bob cud])
66+ ~
67+ ==
68+ ::
69+ %|
70+ ?- -.i.bob
71+ %|
72+ ?. =(i.ali i.bob)
73+ ~
74+ %+ bind $(ali t.ali, bob t.bob)
75+ |=(cud=(urge cord) [i.ali cud])
76+ ::
77+ %&
78+ ?: =(p.i.bob (lent p.i.ali))
79+ %+ bind $(ali t.ali, bob t.bob)
80+ |=(cud=(urge cord) [i.ali cud])
81+ ?: (gth p.i.bob (lent p.i.ali))
82+ %+ bind $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali)))
83+ |=(cud=(urge cord) [i.ali cud])
84+ ~
85+ ==
86+ ==
87+ ++ clean :: clean
88+ |= wig=(urge cord)
89+ ^- (urge cord)
90+ ?~ wig ~
91+ ?~ t.wig wig
92+ ?: ?=(%& -.i.wig)
93+ ?: ?=(%& -.i.t.wig)
94+ $(wig [[%& (add p.i.wig p.i.t.wig)] t.t.wig])
95+ [i.wig $(wig t.wig)]
96+ ?: ?=(%| -.i.t.wig)
97+ $(wig [[%| (welp p.i.wig p.i.t.wig) (welp q.i.wig q.i.t.wig)] t.t.wig])
98+ [i.wig $(wig t.wig)]
99+ --
100+ ::
101+ ++ mash
102+ |= $: [als=ship ald=desk ali=(urge cord)]
103+ [bos=ship bod=desk bob=(urge cord)]
104+ ==
105+ ^- (urge cord)
106+ |^
107+ =. ali (clean ali)
108+ =. bob (clean bob)
109+ |- ^- (urge cord)
110+ ?~ ali bob
111+ ?~ bob ali
112+ ?- -.i.ali
113+ %&
114+ ?- -.i.bob
115+ %&
116+ ?: =(p.i.ali p.i.bob)
117+ [i.ali $(ali t.ali, bob t.bob)]
118+ ?: (gth p.i.ali p.i.bob)
119+ [i.bob $(p.i.ali (sub p.i.ali p.i.bob), bob t.bob)]
120+ [i.ali $(ali t.ali, p.i.bob (sub p.i.bob p.i.ali))]
121+ ::
122+ %|
123+ ?: =(p.i.ali (lent p.i.bob))
124+ [i.bob $(ali t.ali, bob t.bob)]
125+ ?: (gth p.i.ali (lent p.i.bob))
126+ [i.bob $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob)]
127+ =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)]
128+ (resolve ali bob)
129+ [fic $(ali ali, bob bob)]
130+ :: ~ :: here, alice is good for a while, but not for the whole
131+ == :: length of bob's changes
132+ ::
133+ %|
134+ ?- -.i.bob
135+ %|
136+ =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)]
137+ (resolve ali bob)
138+ [fic $(ali ali, bob bob)]
139+ ::
140+ %&
141+ ?: =(p.i.bob (lent p.i.ali))
142+ [i.ali $(ali t.ali, bob t.bob)]
143+ ?: (gth p.i.bob (lent p.i.ali))
144+ [i.ali $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali)))]
145+ =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)]
146+ (resolve ali bob)
147+ [fic $(ali ali, bob bob)]
148+ ==
149+ ==
150+ ::
151+ ++ annotate :: annotate conflict
152+ |= $: ali=(list @t)
153+ bob=(list @t)
154+ bas=(list @t)
155+ ==
156+ ^- (list @t)
157+ %- zing
158+ ^- (list (list @t))
159+ %- flop
160+ ^- (list (list @t))
161+ :- :_ ~
162+ %^ cat 3 '<<<<<<<<<<<<'
163+ %^ cat 3 ' '
164+ %^ cat 3 `@t`(scot %p bos)
165+ %^ cat 3 '/'
166+ bod
167+
168+ :- bob
169+ :- ~['------------']
170+ :- bas
171+ :- ~['++++++++++++']
172+ :- ali
173+ :- :_ ~
174+ %^ cat 3 '>>>>>>>>>>>>'
175+ %^ cat 3 ' '
176+ %^ cat 3 `@t`(scot %p als)
177+ %^ cat 3 '/'
178+ ald
179+ ~
180+ ::
181+ ++ clean :: clean
182+ |= wig=(urge cord)
183+ ^- (urge cord)
184+ ?~ wig ~
185+ ?~ t.wig wig
186+ ?: ?=(%& -.i.wig)
187+ ?: ?=(%& -.i.t.wig)
188+ $(wig [[%& (add p.i.wig p.i.t.wig)] t.t.wig])
189+ [i.wig $(wig t.wig)]
190+ ?: ?=(%| -.i.t.wig)
191+ $(wig [[%| (welp p.i.wig p.i.t.wig) (welp q.i.wig q.i.t.wig)] t.t.wig])
192+ [i.wig $(wig t.wig)]
193+ ::
194+ ++ resolve
195+ |= [ali=(urge cord) bob=(urge cord)]
196+ ^- [fic=[%| p=(list cord) q=(list cord)] ali=(urge cord) bob=(urge cord)]
197+ =- [[%| bac (annotate alc boc bac)] ali bob]
198+ |- ^- $: $: bac=(list cord)
199+ alc=(list cord)
200+ boc=(list cord)
201+ ==
202+ ali=(urge cord)
203+ bob=(urge cord)
204+ ==
205+ ?~ ali [[~ ~ ~] ali bob]
206+ ?~ bob [[~ ~ ~] ali bob]
207+ ?- -.i.ali
208+ %&
209+ ?- -.i.bob
210+ %& [[~ ~ ~] ali bob] :: no conflict
211+ %|
212+ =+ lob=(lent p.i.bob)
213+ ?: =(lob p.i.ali)
214+ [[p.i.bob p.i.bob q.i.bob] t.ali t.bob]
215+ ?: (lth lob p.i.ali)
216+ [[p.i.bob p.i.bob q.i.bob] [[%& (sub p.i.ali lob)] t.ali] t.bob]
217+ =+ wat=(scag (sub lob p.i.ali) p.i.bob)
218+ =+ ^= res
219+ %= $
220+ ali t.ali
221+ bob [[%| (scag (sub lob p.i.ali) p.i.bob) ~] t.bob]
222+ ==
223+ :* :* (welp bac.res wat)
224+ (welp alc.res wat)
225+ (welp boc.res q.i.bob)
226+ ==
227+ ali.res
228+ bob.res
229+ ==
230+ ==
231+ ::
232+ %|
233+ ?- -.i.bob
234+ %&
235+ =+ loa=(lent p.i.ali)
236+ ?: =(loa p.i.bob)
237+ [[p.i.ali q.i.ali p.i.ali] t.ali t.bob]
238+ ?: (lth loa p.i.bob)
239+ [[p.i.ali q.i.ali p.i.ali] t.ali [[%& (sub p.i.bob loa)] t.bob]]
240+ =+ wat=(slag (sub loa p.i.bob) p.i.ali)
241+ =+ ^= res
242+ %= $
243+ ali [[%| (scag (sub loa p.i.bob) p.i.ali) ~] t.ali]
244+ bob t.bob
245+ ==
246+ :* :* (welp bac.res wat)
247+ (welp alc.res q.i.ali)
248+ (welp boc.res wat)
249+ ==
250+ ali.res
251+ bob.res
252+ ==
253+ ::
254+ %|
255+ =+ loa=(lent p.i.ali)
256+ =+ lob=(lent p.i.bob)
257+ ?: =(loa lob)
258+ [[p.i.ali q.i.ali q.i.bob] t.ali t.bob]
259+ =+ ^= res
260+ ?: (gth loa lob)
261+ $(ali [[%| (scag (sub loa lob) p.i.ali) ~] t.ali], bob t.bob)
262+ ~& [%scagging loa=loa pibob=p.i.bob slag=(scag loa p.i.bob)]
263+ $(ali t.ali, bob [[%| (scag (sub lob loa) p.i.bob) ~] t.bob])
264+ :* :* (welp bac.res ?:((gth loa lob) p.i.bob p.i.ali))
265+ (welp alc.res q.i.ali)
266+ (welp boc.res q.i.bob)
267+ ==
268+ ali.res
269+ bob.res
270+ ==
271+ ==
272+ ==
273+ --
274+ --
275+--
zod/seax/sys.kelvinnew file+1
@@ -0,0 +1 @@
1+[%zuse 413]