(.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) (all sum.equivalence ..any_equivalence /stamp.equivalence )) (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} (case snapshot {#Local} (list ..local_copy_format) {#Remote stamp} (/stamp.format stamp)))) (def: .public parser (Parser Snapshot) (<| (.node ) (<>.or ..local_copy_parser /stamp.parser)))