blob: 6a5849f439039c6547c28b52ef2b6d6be4043662 (
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
|
(.module:
[library
[lux (#- Name Type)
[abstract
[equivalence (#+ Equivalence)]
[monad (#+ do)]]
[control
["<>" parser
["<.>" xml (#+ Parser)]
["<.>" text]]]
[data
["." sum]
[format
["." xml (#+ XML)]]]]]
["." / #_
["#." stamp (#+ Stamp)]])
(type: #export Snapshot
#Local
(#Remote Stamp))
(implementation: any_equivalence
(Equivalence Any)
(def: (= _ _)
true))
(def: #export 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: #export (format snapshot)
(-> Snapshot XML)
(<| (#xml.Node ..<snapshot> xml.attributes)
(case snapshot
#Local
(list ..local_copy_format)
(#Remote stamp)
(/stamp.format stamp))))
(def: #export parser
(Parser Snapshot)
(<| (<xml>.node <snapshot>)
(<>.or ..local_copy_parser
/stamp.parser)))
|