(.require [library [lux (.except type) [abstract [monad (.only do)]] [control ["<>" parser (.use "[1]#[0]" functor)] ["[0]" maybe]] [data ["[0]" text] [collection ["[0]" set (.only Set)] ["[0]" dictionary (.only Dictionary)] [list ["[0]" property]]]] [meta ["[0]" code (.only) ["<[1]>" \\parser (.only Parser)]] [compiler [meta [cli [compiler (.only Compiler)]]]]] [world [net (.only URL)]]]] ["[0]" // ["/" profile] ["[1][0]" runtime (.only Runtime)] ["[1][0]" project (.only Project)] ["[1][0]" dependency] ["[1][0]" format] ["[1][0]" repository ["[1]" remote]] ["[1][0]" artifact (.only Artifact) ["[1]/[0]" type]]]) (def (singular input tag parser) (All (_ a) (-> (Dictionary Text Code) Text (Parser a) (Parser a))) (.locally (maybe.list (dictionary.value tag input)) parser)) (def (plural input tag parser) (All (_ a) (-> (Dictionary Text Code) Text (Parser a) (Parser (List a)))) (.locally (maybe.list (dictionary.value tag input)) (.tuple (<>.some parser)))) (def group (Parser //artifact.Group) .text) (def name (Parser //artifact.Name) .text) (def version (Parser //artifact.Version) .text) (def artifact' (Parser //artifact.Artifact) (all <>.and ..group ..name ..version)) (def artifact (Parser //artifact.Artifact) (.tuple ..artifact')) (def url (Parser URL) .text) (def scm (Parser /.SCM) ..url) (def description (Parser Text) .text) (def license (Parser /.License) (do [! <>.monad] [input (at ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any))))] (all <>.and (..singular input "name" ..name) (..singular input "url" ..url) (<>.else {/.#Repo} (..singular input "type" (<>.or (.this (' "repo")) (.this (' "manual")))))))) (def organization (Parser /.Organization) (do [! <>.monad] [input (at ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any))))] (all <>.and (..singular input "name" ..name) (..singular input "url" ..url)))) (def developer (Parser /.Developer) (do [! <>.monad] [input (at ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any))))] (all <>.and (..singular input "name" ..name) (..singular input "url" ..url) (<>.maybe (..singular input "organization" ..organization)) ))) (def contributor (Parser /.Contributor) ..developer) (def info (Parser /.Info) (do [! <>.monad] [input (at ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any))))] (all <>.and (<>.maybe (..singular input "url" ..url)) (<>.maybe (..singular input "scm" ..scm)) (<>.maybe (..singular input "description" ..description)) (<>.else (list) (..plural input "licenses" ..license)) (<>.maybe (..singular input "organization" ..organization)) (<>.else (list) (..plural input "developers" ..developer)) (<>.else (list) (..plural input "contributors" ..contributor)) ))) (def repository (Parser //repository.Address) ..url) (def type (Parser //artifact/type.Type) .text) (def dependency (Parser //dependency.Dependency) (.tuple (all <>.and ..artifact' (<>.else //artifact/type.lux_library ..type) ))) (def compiler (Parser Compiler) (.tuple (all <>.and .global (<>.some .text) ))) (def source (Parser /.Source) .text) (def target (Parser /.Target) .text) (def module_or_program (Parser Symbol) .symbol) (def program (Parser Symbol) .global) (def deploy_repository (Parser [Text //repository.Address]) (<>.and .text ..repository)) (def configuration/1 (Parser [Text Text]) (<>.and .text .text)) (def runtime (Parser Runtime) (let [environment (<>#each (dictionary.of_list text.hash) (<>.some (.tuple (<>.and .text .text))))] (.tuple (all <>.and environment .text (<>.some .text))))) (def profile (Parser /.Profile) (do [! <>.monad] [input (at ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any)))) .let [^parents (is (Parser (List /.Name)) (<>.else (list) (..plural input "parents" .text))) ^identity (is (Parser (Maybe Artifact)) (<>.maybe (..singular input "identity" ..artifact))) ^info (is (Parser (Maybe /.Info)) (<>.maybe (..singular input "info" ..info))) ^repositories (is (Parser (Set //repository.Address)) (|> (..plural input "repositories" ..repository) (at ! each (set.of_list text.hash)) (<>.else (set.empty text.hash)) (at ! each (set.has /.default_repository)))) ^dependencies (is (Parser (Set //dependency.Dependency)) (|> (..plural input "dependencies" ..dependency) (at ! each (set.of_list //dependency.hash)) (<>.else (set.empty //dependency.hash)))) ^lux (|> ..dependency (..singular input //format.lux_compiler_label) (<>.else /.default_lux)) ^compilers (|> ..compiler (..plural input "compilers") (<>.else (list))) ^sources (is (Parser (Set /.Source)) (|> (..plural input "sources" ..source) (at ! each (set.of_list text.hash)) (<>.else (set.of_list text.hash (list /.default_source))))) ^target (is (Parser /.Target) (|> ..target (..singular input "target") (<>.else /.default_target))) ^program (is (Parser (Maybe Symbol)) (<>.maybe (..singular input "program" ..module_or_program))) ^test (is (Parser (Maybe Symbol)) (<>.maybe (..singular input "test" ..program))) ^deploy_repositories (is (Parser (Dictionary Text //repository.Address)) (<| (at ! each (dictionary.of_list text.hash)) (<>.else (list)) (..plural input "deploy_repositories" ..deploy_repository))) ^configuration (is (Parser (property.List Text)) (<| (<>.else (list)) (..plural input "configuration" ..configuration/1))) ^java (|> ..runtime (..singular input "java") (<>.else //runtime.default_java)) ^js (|> ..runtime (..singular input "js") (<>.else //runtime.default_js)) ^python (|> ..runtime (..singular input "python") (<>.else //runtime.default_python)) ^lua (|> ..runtime (..singular input "lua") (<>.else //runtime.default_lua)) ^ruby (|> ..runtime (..singular input "ruby") (<>.else //runtime.default_ruby))]] (all <>.and ^parents ^identity ^info ^repositories ^dependencies ^lux ^compilers ^sources ^target ^program ^test ^deploy_repositories ^configuration ^java ^js ^python ^lua ^ruby ))) (def .public project (Parser Project) (at <>.monad each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text ..profile)))))