urbit/pkg/arvo/mar/txt.hoon

276 lines
7.7 KiB
Plaintext
Raw Normal View History

2015-04-14 00:29:39 +03:00
::
2016-02-05 06:05:37 +03:00
:::: /hoon/txt/mar
2014-09-12 06:11:03 +04:00
::
2016-02-18 02:00:12 +03:00
/? 310
2016-11-17 04:42:58 +03:00
::
=, clay
=, differ
=, format
2016-12-03 03:56:54 +03:00
=, mimes:html
|_ txt=wain
2019-01-18 08:37:34 +03:00
::
2014-09-12 06:11:03 +04:00
++ grab :: convert from
|%
++ mime |=((pair mite octs) (to-wain q.q))
2015-02-27 09:35:41 +03:00
++ noun wain :: clam from %noun
2014-09-12 06:11:03 +04:00
--
2014-10-27 07:34:40 +03:00
++ grow
2015-02-27 09:35:41 +03:00
=> v=.
|%
2016-12-03 03:56:54 +03:00
++ mime => v [/text/plain (as-octs (of-wain txt))]
++ elem => v ;pre: {(trip (of-wain txt))}
2015-02-27 09:35:41 +03:00
--
++ grad
2014-10-27 07:34:40 +03:00
|%
2015-02-27 09:35:41 +03:00
++ form %txt-diff
++ diff
|= tyt=wain
2015-02-27 09:35:41 +03:00
^- (urge cord)
(lusk txt tyt (loss txt tyt))
2015-04-07 02:20:28 +03:00
::
2015-02-27 09:35:41 +03:00
++ pact
|= dif=(urge cord)
2015-04-14 00:29:39 +03:00
~| [%pacting dif]
2015-02-27 09:35:41 +03:00
^- wain
(lurk txt dif)
2015-04-07 02:20:28 +03:00
::
2015-02-27 09:35:41 +03:00
++ join
|= {ali=(urge cord) bob=(urge cord)}
2015-02-27 09:35:41 +03:00
^- (unit (urge cord))
|^
=. ali (clean ali)
=. bob (clean bob)
|- ^- (unit (urge cord))
?~ ali `bob
?~ bob `ali
?- -.i.ali
2018-03-19 06:54:47 +03:00
%&
2015-02-27 09:35:41 +03:00
?- -.i.bob
2018-03-19 06:54:47 +03:00
%&
2015-02-27 09:35:41 +03:00
?: =(p.i.ali p.i.bob)
%+ bind $(ali t.ali, bob t.bob)
|=(cud=(urge cord) [i.ali cud])
2015-02-27 09:35:41 +03:00
?: (gth p.i.ali p.i.bob)
%+ bind $(p.i.ali (sub p.i.ali p.i.bob), bob t.bob)
|=(cud=(urge cord) [i.bob cud])
2015-02-27 09:35:41 +03:00
%+ bind $(ali t.ali, p.i.bob (sub p.i.bob p.i.ali))
|=(cud=(urge cord) [i.ali cud])
::
2018-03-19 06:54:47 +03:00
%|
2015-02-27 09:35:41 +03:00
?: =(p.i.ali (lent p.i.bob))
%+ bind $(ali t.ali, bob t.bob)
|=(cud=(urge cord) [i.bob cud])
2015-02-27 09:35:41 +03:00
?: (gth p.i.ali (lent p.i.bob))
%+ bind $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob)
|=(cud=(urge cord) [i.bob cud])
2015-02-27 09:35:41 +03:00
~
==
2015-04-14 00:29:39 +03:00
::
2018-03-19 06:54:47 +03:00
%|
2015-02-27 09:35:41 +03:00
?- -.i.bob
%|
?. =(i.ali i.bob)
~
%+ bind $(ali t.ali, bob t.bob)
|=(cud=(urge cord) [i.ali cud])
::
2018-03-19 06:54:47 +03:00
%&
2015-02-27 09:35:41 +03:00
?: =(p.i.bob (lent p.i.ali))
%+ bind $(ali t.ali, bob t.bob)
|=(cud=(urge cord) [i.ali cud])
2015-02-27 09:35:41 +03:00
?: (gth p.i.bob (lent p.i.ali))
%+ bind $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali)))
|=(cud=(urge cord) [i.ali cud])
2015-02-27 09:35:41 +03:00
~
==
==
++ clean :: clean
|= wig=(urge cord)
2015-02-27 09:35:41 +03:00
^- (urge cord)
?~ wig ~
?~ t.wig wig
2018-03-19 06:54:47 +03:00
?: ?=(%& -.i.wig)
?: ?=(%& -.i.t.wig)
2015-02-27 09:35:41 +03:00
$(wig [[%& (add p.i.wig p.i.t.wig)] t.t.wig])
[i.wig $(wig t.wig)]
2018-03-19 06:54:47 +03:00
?: ?=(%| -.i.t.wig)
2015-02-27 09:35:41 +03:00
$(wig [[%| (welp p.i.wig p.i.t.wig) (welp q.i.wig q.i.t.wig)] t.t.wig])
[i.wig $(wig t.wig)]
--
2015-04-04 04:31:57 +03:00
::
++ mash
|= $: {als=ship ald=desk ali=(urge cord)}
{bos=ship bod=desk bob=(urge cord)}
==
2015-04-04 04:31:57 +03:00
^- (urge cord)
2015-04-14 00:29:39 +03:00
|^
=. ali (clean ali)
=. bob (clean bob)
|- ^- (urge cord)
?~ ali bob
?~ bob ali
?- -.i.ali
2018-03-19 06:54:47 +03:00
%&
2015-04-14 00:29:39 +03:00
?- -.i.bob
2018-03-19 06:54:47 +03:00
%&
2015-04-14 00:29:39 +03:00
?: =(p.i.ali p.i.bob)
[i.ali $(ali t.ali, bob t.bob)]
?: (gth p.i.ali p.i.bob)
[i.bob $(p.i.ali (sub p.i.ali p.i.bob), bob t.bob)]
[i.ali $(ali t.ali, p.i.bob (sub p.i.bob p.i.ali))]
::
2018-03-19 06:54:47 +03:00
%|
2015-04-14 00:29:39 +03:00
?: =(p.i.ali (lent p.i.bob))
[i.bob $(ali t.ali, bob t.bob)]
?: (gth p.i.ali (lent p.i.bob))
[i.bob $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob)]
=/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)}
2015-04-14 00:29:39 +03:00
(resolve ali bob)
[fic $(ali ali, bob bob)]
:: ~ :: here, alice is good for a while, but not for the whole
== :: length of bob's changes
::
2018-03-19 06:54:47 +03:00
%|
2015-04-14 00:29:39 +03:00
?- -.i.bob
2018-03-19 06:54:47 +03:00
%|
=/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)}
2015-04-14 00:29:39 +03:00
(resolve ali bob)
[fic $(ali ali, bob bob)]
::
2018-03-19 06:54:47 +03:00
%&
2015-04-14 00:29:39 +03:00
?: =(p.i.bob (lent p.i.ali))
[i.ali $(ali t.ali, bob t.bob)]
?: (gth p.i.bob (lent p.i.ali))
[i.ali $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali)))]
=/ {fic=(unce cord) ali=(urge cord) bob=(urge cord)}
2015-04-14 00:29:39 +03:00
(resolve ali bob)
[fic $(ali ali, bob bob)]
==
==
::
++ annotate :: annotate conflict
|= $: ali=(list @t)
bob=(list @t)
bas=(list @t)
2015-04-14 00:29:39 +03:00
==
2015-12-10 12:17:19 +03:00
^- (list @t)
2015-04-14 00:29:39 +03:00
%- zing
2015-12-10 12:17:19 +03:00
^- (list (list @t))
2015-04-14 00:29:39 +03:00
%- flop
2015-12-10 12:17:19 +03:00
^- (list (list @t))
2015-04-14 00:29:39 +03:00
:- :_ ~
2019-01-18 08:37:34 +03:00
%^ cat 3 '<<<<<<<<<<<<'
2015-04-14 00:29:39 +03:00
%^ cat 3 ' '
%^ cat 3 `@t`(scot %p bos)
2015-04-14 00:29:39 +03:00
%^ cat 3 '/'
2015-07-15 01:32:12 +03:00
bod
2015-04-14 00:29:39 +03:00
:- bob
:- ~['------------']
:- bas
:- ~['++++++++++++']
:- ali
:- :_ ~
2019-01-18 08:37:34 +03:00
%^ cat 3 '>>>>>>>>>>>>'
2015-04-14 00:29:39 +03:00
%^ cat 3 ' '
%^ cat 3 `@t`(scot %p als)
2015-04-14 00:29:39 +03:00
%^ cat 3 '/'
ald
2015-04-14 00:29:39 +03:00
~
::
++ clean :: clean
|= wig=(urge cord)
2015-04-14 00:29:39 +03:00
^- (urge cord)
?~ wig ~
?~ t.wig wig
2018-03-19 06:54:47 +03:00
?: ?=(%& -.i.wig)
?: ?=(%& -.i.t.wig)
2015-04-14 00:29:39 +03:00
$(wig [[%& (add p.i.wig p.i.t.wig)] t.t.wig])
[i.wig $(wig t.wig)]
2018-03-19 06:54:47 +03:00
?: ?=(%| -.i.t.wig)
2015-04-14 00:29:39 +03:00
$(wig [[%| (welp p.i.wig p.i.t.wig) (welp q.i.wig q.i.t.wig)] t.t.wig])
[i.wig $(wig t.wig)]
::
++ resolve
|= {ali=(urge cord) bob=(urge cord)}
^- {fic={%| p=(list cord) q=(list cord)} ali=(urge cord) bob=(urge cord)}
2015-04-14 00:29:39 +03:00
=- [[%| bac (annotate alc boc bac)] ali bob]
|- ^- $: $: bac=(list cord)
alc=(list cord)
boc=(list cord)
2015-04-14 00:29:39 +03:00
==
ali=(urge cord)
bob=(urge cord)
2015-04-14 00:29:39 +03:00
==
?~ ali [[~ ~ ~] ali bob]
?~ bob [[~ ~ ~] ali bob]
?- -.i.ali
2018-03-19 06:54:47 +03:00
%&
2015-04-14 00:29:39 +03:00
?- -.i.bob
2018-03-19 06:54:47 +03:00
%& [[~ ~ ~] ali bob] :: no conflict
%|
2015-04-14 00:29:39 +03:00
=+ lob=(lent p.i.bob)
?: =(lob p.i.ali)
[[p.i.bob p.i.bob q.i.bob] t.ali t.bob]
?: (lth lob p.i.ali)
[[p.i.bob p.i.bob q.i.bob] [[%& (sub p.i.ali lob)] t.ali] t.bob]
=+ wat=(scag (sub lob p.i.ali) p.i.bob)
2015-12-10 07:05:58 +03:00
=+ ^= res
%= $
2019-01-18 08:37:34 +03:00
ali t.ali
2015-12-10 07:05:58 +03:00
bob [[%| (scag (sub lob p.i.ali) p.i.bob) ~] t.bob]
==
2015-04-14 00:29:39 +03:00
:* :* (welp bac.res wat)
(welp alc.res wat)
(welp boc.res q.i.bob)
==
ali.res
bob.res
==
==
::
2018-03-19 06:54:47 +03:00
%|
2015-04-14 00:29:39 +03:00
?- -.i.bob
2018-03-19 06:54:47 +03:00
%&
2015-04-14 00:29:39 +03:00
=+ loa=(lent p.i.ali)
?: =(loa p.i.bob)
[[p.i.ali q.i.ali p.i.ali] t.ali t.bob]
?: (lth loa p.i.bob)
[[p.i.ali q.i.ali p.i.ali] t.ali [[%& (sub p.i.bob loa)] t.bob]]
=+ wat=(slag (sub loa p.i.bob) p.i.ali)
2015-12-10 07:05:58 +03:00
=+ ^= res
%= $
ali [[%| (scag (sub loa p.i.bob) p.i.ali) ~] t.ali]
bob t.bob
==
2015-04-14 00:29:39 +03:00
:* :* (welp bac.res wat)
(welp alc.res q.i.ali)
(welp boc.res wat)
==
ali.res
bob.res
==
::
2018-03-19 06:54:47 +03:00
%|
2015-04-14 00:29:39 +03:00
=+ loa=(lent p.i.ali)
=+ lob=(lent p.i.bob)
?: =(loa lob)
[[p.i.ali q.i.ali q.i.bob] t.ali t.bob]
=+ ^= res
?: (gth loa lob)
$(ali [[%| (scag (sub loa lob) p.i.ali) ~] t.ali], bob t.bob)
~& [%scagging loa=loa pibob=p.i.bob slag=(scag loa p.i.bob)]
$(ali t.ali, bob [[%| (scag (sub lob loa) p.i.bob) ~] t.bob])
:* :* (welp bac.res ?:((gth loa lob) p.i.bob p.i.ali))
(welp alc.res q.i.ali)
(welp boc.res q.i.bob)
==
ali.res
bob.res
==
==
==
--
2014-10-27 07:34:40 +03:00
--
2014-09-12 06:11:03 +04:00
--