blob: 8f06a38173edf66d8e4fa4a072cf70ae5e8aff29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
(.using
[library
[lux {"-" Type}
[abstract
[equivalence {"+" Equivalence}]
[monad {"+" do}]]
[control
["<>" parser
["<[0]>" xml {"+" Parser}]
["<[0]>" text]]]
[data
["[0]" sum]
[format
["[0]" xml {"+" XML}]]]]]
["[0]" / "_"
["[1][0]" stamp {"+" Stamp}]])
(type: .public Snapshot
(Variant
{#Local}
{#Remote Stamp}))
(implementation: any_equivalence
(Equivalence Any)
(def: (= _ _)
true))
(def: .public equivalence
(Equivalence Snapshot)
($_ sum.equivalence
..any_equivalence
/stamp.equivalence
))
(template [<definition> <tag>]
[(def: <definition> xml.Tag ["" <tag>])]
[<local_copy> "localCopy"]
[<snapshot> "snapshot"]
)
(def: local_copy_value
"true")
(def: local_copy_format
XML
{xml.#Node <local_copy>
xml.attributes
(list {xml.#Text ..local_copy_value})})
(def: local_copy_parser
(Parser Any)
(<| (<xml>.node ..<local_copy>)
(<text>.then (<text>.this ..local_copy_value))
<xml>.text))
(def: .public (format snapshot)
(-> Snapshot XML)
(<| {xml.#Node ..<snapshot> xml.attributes}
(case snapshot
{#Local}
(list ..local_copy_format)
{#Remote stamp}
(/stamp.format stamp))))
(def: .public parser
(Parser Snapshot)
(<| (<xml>.node <snapshot>)
(<>.or ..local_copy_parser
/stamp.parser)))
|