(.require [library [lux (.except local #version) [abstract [equivalence (.only Equivalence)] [order (.only Order)] [hash (.only Hash)]] [data ["[0]" product] ["[0]" text (.use "[1]#[0]" order) ["%" \\format (.only Format)]] [collection ["[0]" list (.use "[1]#[0]" monoid)]]] [world ["[0]" file (.only Path)] [net [uri (.only URI) ["[0]" path]]]]]]) (type .public Group Text) (type .public Name Text) (type .public Version Text) (type .public Artifact (Record [#group Group #name Name #version Version])) (def .public hash (Hash Artifact) (all product.hash text.hash text.hash text.hash )) (def .public equivalence (Equivalence Artifact) (of ..hash equivalence)) (def .public order (Order Artifact) (implementation (def equivalence ..equivalence) (def (< reference subject) (<| (or (text#< (the #group reference) (the #group subject))) (and (text#= (the #group reference) (the #group subject))) (or (text#< (the #name reference) (the #name subject))) (and (text#= (the #name reference) (the #name subject))) (text#< (the #version reference) (the #version subject)))))) (with_template [ ] [(def Text )] ["." group_separator] ["-" version_separator] [":" identity_separator] ) (def .public (identity artifact) (-> Artifact Text) (%.format (the #name artifact) ..version_separator (the #version artifact))) (def .public (format value) (Format Artifact) (%.format (the #group value) ..identity_separator (..identity value))) (def .public (directory separator group) (-> Text Group Text) (|> group (text.all_split_by ..group_separator) (text.interposed separator))) (def .public (bundle version artifact) (-> Version Artifact URI) (let [/ path.separator group (..directory / (the #group artifact)) name (the #name artifact)] (%.format group / name / version))) (def .public (uri version artifact) (-> Version Artifact URI) (let [/ path.separator] (%.format (..bundle version artifact) / (..identity artifact)))) (def .public (local artifact) (-> Artifact (List Text)) (list#composite (|> artifact (the #group) (text.all_split_by ..group_separator)) (list (the #name artifact) (the #version artifact))))