blob: 38001bfe2b5633eee1577495f2958fbecc00994b (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
(.module:
[library
[lux #*
[abstract
[equivalence (#+ Equivalence)]
[monad (#+ do)]]
[control
["." exception (#+ exception:)]
["<>" parser
["<.>" xml (#+ Parser)]
["<.>" text]]]
[data
["." product]
["." text
["%" format]]
[format
["." xml (#+ XML)]]
[collection
["." list ("#\." functor)]]]
[math
[number
["n" nat]]]
["." time (#+ Time)
["." date (#+ Date)]
["." year]
["." month]]]]
["." // #_
["#." time]
["#." snapshot (#+ Snapshot)
["#/." version (#+ Version)]]])
(type: .public Versioning
(Record
{#snapshot Snapshot
#last_updated //time.Time
#versions (List Version)}))
(def: .public init
{#snapshot #//snapshot.Local
#last_updated //time.epoch
#versions (list)})
(def: .public equivalence
(Equivalence Versioning)
($_ product.equivalence
//snapshot.equivalence
//time.equivalence
(list.equivalence //snapshot/version.equivalence)
))
(template [<definition> <tag>]
[(def: <definition> xml.Tag ["" <tag>])]
[<last_updated> "lastUpdated"]
[<snapshot_versions> "snapshotVersions"]
[<versioning> "versioning"]
)
(def: last_updated_format
(-> //time.Time XML)
(|>> //time.format #xml.Text list (#xml.Node ..<last_updated> xml.attributes)))
(def: .public (format (^slots [#snapshot #last_updated #versions]))
(-> Versioning XML)
(<| (#xml.Node ..<versioning> xml.attributes)
(list (//snapshot.format snapshot)
(..last_updated_format last_updated)
(|> versions
(list\each //snapshot/version.format)
(#xml.Node ..<snapshot_versions> xml.attributes)))))
(def: (text tag)
(-> xml.Tag (Parser Text))
(<| (<xml>.node tag)
<xml>.text))
(def: last_updated_parser
(Parser //time.Time)
(<| (<text>.then //time.parser)
(..text ..<last_updated>)))
(def: .public parser
(Parser Versioning)
(<| (<xml>.node ..<versioning>)
($_ <>.and
(<>.else #//snapshot.Local (<xml>.somewhere //snapshot.parser))
(<>.else //time.epoch (<xml>.somewhere ..last_updated_parser))
(<| (<>.else (list))
<xml>.somewhere
(<xml>.node ..<snapshot_versions>)
(<>.some //snapshot/version.parser))
)))
|