aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/artifact/snapshot.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-01-26 19:11:14 -0400
committerEduardo Julian2021-01-26 19:11:14 -0400
commit43d28326ad59c74439b96343cc8f619ed7d90231 (patch)
tree3f410d48bfca7d8141e2e7fda0f8d978934dd5c2 /stdlib/source/program/aedifex/artifact/snapshot.lux
parentae56acf791c2ed9bd5865f85fffa00b025d310fe (diff)
Made the Python being generated more compatible with both P2.7 and P3.
Diffstat (limited to 'stdlib/source/program/aedifex/artifact/snapshot.lux')
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot.lux72
1 files changed, 72 insertions, 0 deletions
diff --git a/stdlib/source/program/aedifex/artifact/snapshot.lux b/stdlib/source/program/aedifex/artifact/snapshot.lux
new file mode 100644
index 000000000..0488d76dd
--- /dev/null
+++ b/stdlib/source/program/aedifex/artifact/snapshot.lux
@@ -0,0 +1,72 @@
+(.module:
+ [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))
+
+(structure: 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)
+ (do <>.monad
+ [_ (<xml>.node ..<local_copy>)]
+ (<xml>.children (<text>.embed (<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)
+ (do <>.monad
+ [_ (<xml>.node <snapshot>)]
+ (<xml>.children (<>.or ..local_copy_parser
+ /stamp.parser))))