(.require [library [lux (.except Type #Local) [abstract [equivalence (.only Equivalence)] [monad (.only do)]] [control ["<>" parser]] [data ["[0]" sum] ["[0]" text ["<[1]>" \\parser]] [format ["[0]" xml (.only XML) ["<[1]>" \\parser (.only Parser)]]]]]] ["[0]" / ["[1][0]" stamp (.only Stamp)]]) (type .public Snapshot (Variant {#Local} {#Remote Stamp})) (def any_equivalence (Equivalence Any) (implementation (def (= _ _) true))) (def .public equivalence (Equivalence Snapshot) (all sum.equivalence ..any_equivalence /stamp.equivalence )) (with_template [ ] [(def xml.Tag ["" ])] [ "localCopy"] [ "snapshot"] ) (def local_copy_value "true") (def local_copy_format XML {xml.#Node xml.attributes (list {xml.#Text ..local_copy_value})}) (def local_copy_parser (Parser Any) (<| (.node ..) (.then (.this ..local_copy_value)) .text)) (def .public (format snapshot) (-> Snapshot XML) (<| {xml.#Node .. xml.attributes} (when snapshot {#Local} (list ..local_copy_format) {#Remote stamp} (/stamp.format stamp)))) (def .public parser (Parser Snapshot) (<| (.node ) (<>.or ..local_copy_parser /stamp.parser)))