(.module: [library [lux {"-" [Module type]} [abstract [monad {"+" [do]}]] [control ["<>" parser ["<.>" code {"+" [Parser]}]]] [data ["." text] [collection ["." dictionary {"+" [Dictionary]}] ["." set {"+" [Set]}]]] [tool [compiler [meta [archive [descriptor {"+" [Module]}]]]]] [world [net {"+" [URL]}]]]] ["." // "_" ["/" profile] ["#." runtime {"+" [Runtime]}] ["#." project {"+" [Project]}] ["#." dependency] ["#." repository "_" ["#" remote]] ["#." artifact {"+" [Artifact]} ["#/." type]]]) (def: (as_input input) (-> (Maybe Code) (List Code)) (case input (#.Some input) (list input) #.None (list))) (def: (singular input tag parser) (All (_ a) (-> (Dictionary Text Code) Text (Parser a) (Parser a))) (.local (..as_input (dictionary.value tag input)) parser)) (def: (plural input tag parser) (All (_ a) (-> (Dictionary Text Code) Text (Parser a) (Parser (List a)))) (.local (..as_input (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) ($_ <>.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 (\ ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any))))] ($_ <>.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 (\ ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any))))] ($_ <>.and (..singular input "name" ..name) (..singular input "url" ..url)))) (def: developer (Parser /.Developer) (do {! <>.monad} [input (\ ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any))))] ($_ <>.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 (\ ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any))))] ($_ <>.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 ($_ <>.and ..artifact' (<>.else //artifact/type.lux_library ..type) ))) (def: source (Parser /.Source) .text) (def: target (Parser /.Target) .text) (def: module (Parser Module) .text) (def: deploy_repository (Parser (List [Text //repository.Address])) (.tuple (<>.some (<>.and .text ..repository)))) (def: runtime (Parser Runtime) (.tuple (<>.and .text (<>.some .text)))) (def: profile (Parser /.Profile) (do {! <>.monad} [input (\ ! each (dictionary.of_list text.hash) (.tuple (<>.some (<>.and .text .any)))) .let [^parents (: (Parser (List /.Name)) (<>.else (list) (..plural input "parents" .text))) ^identity (: (Parser (Maybe Artifact)) (<>.maybe (..singular input "identity" ..artifact))) ^info (: (Parser (Maybe /.Info)) (<>.maybe (..singular input "info" ..info))) ^repositories (: (Parser (Set //repository.Address)) (|> (..plural input "repositories" ..repository) (\ ! each (set.of_list text.hash)) (<>.else (set.empty text.hash)) (\ ! each (set.has /.default_repository)))) ^dependencies (: (Parser (Set //dependency.Dependency)) (|> (..plural input "dependencies" ..dependency) (\ ! each (set.of_list //dependency.hash)) (<>.else (set.empty //dependency.hash)))) ^compiler (|> ..dependency (..singular input "compiler") (<>.else /.default_compiler)) ^sources (: (Parser (Set /.Source)) (|> (..plural input "sources" ..source) (\ ! each (set.of_list text.hash)) (<>.else (set.of_list text.hash (list /.default_source))))) ^target (: (Parser /.Target) (|> ..target (..singular input "target") (<>.else /.default_target))) ^program (: (Parser (Maybe Module)) (<>.maybe (..singular input "program" ..module))) ^test (: (Parser (Maybe Module)) (<>.maybe (..singular input "test" ..module))) ^deploy_repositories (: (Parser (Dictionary Text //repository.Address)) (<| (\ ! each (dictionary.of_list text.hash)) (<>.else (list)) (..singular input "deploy_repositories" ..deploy_repository))) ^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))]] ($_ <>.and ^parents ^identity ^info ^repositories ^dependencies ^compiler ^sources ^target ^program ^test ^deploy_repositories ^java ^js ^python ^lua ^ruby ))) (def: .public project (Parser Project) (\ <>.monad each (dictionary.of_list text.hash) (.tuple (<>.many (<>.and .text ..profile)))))