... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. ... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. (.require [library [lux (.except) [data ["[0]" text (.use "[1]#[0]" equivalence)] [collection ["[0]" dictionary (.only Dictionary)] ["[0]" list (.use "[1]#[0]" monad)] ["[0]" set (.only Set)]]] [meta ["[0]" code] [macro ["[0]" template]] [compiler [meta [cli [compiler (.only Compiler)]]]]]]] ["[0]" // ["/" profile] ["[1][0]" runtime (.only Runtime)] ["[1][0]" project (.only Project)] ["[1][0]" dependency (.only Dependency)] ["[1][0]" artifact (.only Artifact) ["[1]/[0]" type]]]) (type .public (Format a) (-> a Code)) (def (license [name url type]) (Format /.License) (`' ["name" (, (code.text name)) "url" (, (code.text url)) "type" (, (when 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) (when 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#each (function (_ [key value]) (list (code.text key) value))) list#conjoint code.tuple)) (def empty Aggregate (dictionary.empty text.hash)) (def (on_maybe field value format aggregate) (All (_ a) (-> Text (Maybe a) (Format a) Aggregate Aggregate)) (when 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)) (when value {.#End} aggregate value (dictionary.has field (` [(,* (list#each 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#each (function (_ [key value]) (list (key_format key) (value_format value)))) list#conjoint code.tuple) aggregate))) (def (info value) (Format /.Info) (|> ..empty (..on_maybe "url" (the /.#url value) code.text) (..on_maybe "scm" (the /.#scm value) code.text) (..on_maybe "description" (the /.#description value) code.text) (..on_list "licenses" (the /.#licenses value) ..license) (..on_maybe "organization" (the /.#organization value) ..organization) (..on_list "developers" (the /.#developers value) ..developer) (..on_list "contributors" (the /.#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 [environment program parameters]) (Format Runtime) (` [(,* (list#each (function (_ [var value]) (` [(, (code.text var)) (, (code.text value))])) (dictionary.entries environment))) (, (code.text program)) (,* (list#each code.text parameters))])) (def (compiler [definition parameters]) (Format Compiler) (` [(, (code.symbol definition)) (,* (list#each code.text parameters))])) (def configuration (Format /.Configuration) (|>> (list#each (function (_ [setting value]) (list (code.text setting) (code.text value)))) list#conjoint code.tuple)) (def .public lux_compiler_label "lux") (def .public (profile value) (Format /.Profile) (`` (|> ..empty (..on_list "parents" (the /.#parents value) code.text) (..on_maybe "identity" (the /.#identity value) ..artifact) (..on_maybe "info" (the /.#info value) ..info) (..on_set "repositories" (the /.#repositories value) code.text) (..on_set "dependencies" (the /.#dependencies value) ..dependency) (dictionary.has ..lux_compiler_label (..dependency (the /.#lux value))) (..on_list "compilers" (the /.#compilers value) ..compiler) (..on_set "sources" (the /.#sources value) code.text) (dictionary.has "target" (code.text (the /.#target value))) (..on_maybe "program" (the /.#program value) code.symbol) (..on_maybe "test" (the /.#test value) code.symbol) (..on_dictionary "deploy_repositories" (the /.#deploy_repositories value) code.text code.text) (dictionary.has "configuration" (..configuration (the /.#configuration value))) (,, (with_template [] [(dictionary.has (template.text []) (..runtime (the value)))] [/.#java] [/.#js] [/.#python] [/.#lua] [/.#ruby])) ..aggregate))) (def .public project (Format Project) (|>> dictionary.entries (list#each (function (_ [key value]) (list (code.text key) (..profile value)))) list#conjoint code.tuple))