(.module: [library [lux #* [data ["." text ("#\." equivalence)] [collection ["." dictionary (#+ Dictionary)] ["." list ("#\." functor)] ["." set (#+ Set)]]] [macro ["." code] ["." template]]]] ["." // #_ ["/" profile] ["#." runtime (#+ Runtime)] ["#." project (#+ Project)] ["#." dependency (#+ Dependency)] ["#." artifact (#+ Artifact) ["#/." type]]]) (type: .public (Format a) (-> a Code)) (def: (license [name url type]) (Format /.License) (`' {#name (~ (code.text name)) #url (~ (code.text url)) #type (~ (case type #/.Repo (' #repo) #/.Manual (' #manual)))})) (def: (organization [name url]) (Format /.Organization) (`' {#name (~ (code.text name)) #url (~ (code.text url))})) (def: (developer [name url organization]) (Format /.Developer) (case organization #.None (`' {#name (~ (code.text name)) #url (~ (code.text url))}) (#.Some value) (`' {#name (~ (code.text name)) #url (~ (code.text url)) #organization (~ (..organization value))}))) (def: contributor (Format /.Contributor) ..developer) (type: Aggregate (Dictionary Text Code)) (def: aggregate (Format Aggregate) (|>> dictionary.entries (list\map (function (_ [key value]) [(code.local_tag key) value])) code.record)) (def: empty Aggregate (dictionary.empty text.hash)) (def: (on_maybe field value format aggregate) (All [a] (-> Text (Maybe a) (Format a) Aggregate Aggregate)) (case value #.None aggregate (#.Some value) (dictionary.has field (format value) aggregate))) (def: (on_list field value format aggregate) (All [a] (-> Text (List a) (Format a) Aggregate Aggregate)) (case value #.End aggregate value (dictionary.has field (` [(~+ (list\map format value))]) aggregate))) (def: (on_set field value format aggregate) (All [a] (-> Text (Set a) (Format a) Aggregate Aggregate)) (..on_list field (set.list value) format aggregate)) (def: (on_dictionary field value key_format value_format aggregate) (All [k v] (-> Text (Dictionary k v) (Format k) (Format v) Aggregate Aggregate)) (if (dictionary.empty? value) aggregate (dictionary.has field (|> value dictionary.entries (list\map (function (_ [key value]) [(key_format key) (value_format value)])) code.record) aggregate))) (def: (info value) (Format /.Info) (|> ..empty (..on_maybe "url" (value@ #/.url value) code.text) (..on_maybe "scm" (value@ #/.scm value) code.text) (..on_maybe "description" (value@ #/.description value) code.text) (..on_list "licenses" (value@ #/.licenses value) ..license) (..on_maybe "organization" (value@ #/.organization value) ..organization) (..on_list "developers" (value@ #/.developers value) ..developer) (..on_list "contributors" (value@ #/.contributors value) ..contributor) ..aggregate)) (def: (artifact' [group name version]) (-> Artifact (List Code)) (list (code.text group) (code.text name) (code.text version))) (def: (artifact value) (Format Artifact) (` [(~+ (..artifact' value))])) (def: (dependency [artifact type]) (Format Dependency) (if (text\= //artifact/type.lux_library type) (` [(~+ (..artifact' artifact))]) (` [(~+ (..artifact' artifact)) (~ (code.text type))]))) (def: (runtime [program parameters]) (Format Runtime) (` [(~ (code.text program)) (~+ (list\map code.text parameters))])) (def: .public (profile value) (Format /.Profile) (`` (|> ..empty (..on_list "parents" (value@ #/.parents value) code.text) (..on_maybe "identity" (value@ #/.identity value) ..artifact) (..on_maybe "info" (value@ #/.info value) ..info) (..on_set "repositories" (value@ #/.repositories value) code.text) (..on_set "dependencies" (value@ #/.dependencies value) ..dependency) (dictionary.has "compiler" (..dependency (value@ #/.compiler value))) (..on_set "sources" (value@ #/.sources value) code.text) (dictionary.has "target" (code.text (value@ #/.target value))) (..on_maybe "program" (value@ #/.program value) code.text) (..on_maybe "test" (value@ #/.test value) code.text) (..on_dictionary "deploy_repositories" (value@ #/.deploy_repositories value) code.text code.text) (~~ (template [] [(dictionary.has (template.text []) (..runtime (value@ value)))] [#/.java] [#/.js] [#/.python] [#/.lua] [#/.ruby])) ..aggregate))) (def: .public project (Format Project) (|>> dictionary.entries (list\map (function (_ [key value]) [(code.text key) (..profile value)])) code.record))