(.module: [lux (#- type) [abstract [monad (#+ do)]] [control ["<>" parser ["" code (#+ Parser)]]] [data ["." text]] [world [net (#+ URL)]]] [// ["/" project] ["//." artifact (#+ Artifact)] ["//." dependency]]) (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: license (Parser /.License) (.tuple ($_ <>.and ..name ..url (<>.default #/.Repo (<>.or (.this! (' #repo)) (.this! (' #manual))))))) (def: organization (Parser /.Organization) (<| .form (<>.after (.this! (' #organization))) ($_ <>.and ..name ..url))) (def: developer' (Parser /.Developer) ($_ <>.and ..name ..url (<>.maybe ..organization) )) (def: developer (Parser /.Developer) (<| .form (<>.after (.this! (' #developer))) ..developer')) (def: contributor (Parser /.Contributor) (<| .form (<>.after (.this! (' #contributor))) ..developer')) (def: no-info /.Info {#/.url #.None #/.scm #.None #/.description #.None #/.licenses (list) #/.organization #.None #/.developers (list) #/.contributors (list)}) (def: (singular tag parser) (All [a] (-> Code (Parser a) (Parser a))) (.form (<>.after (.this! tag) parser))) (def: (plural tag parser) (All [a] (-> Code (Parser a) (Parser (List a)))) (.form (<>.after (.this! tag) (<>.some parser)))) (def: info (Parser /.Info) ($_ <>.and (<>.maybe ..url) (<>.maybe ..scm) (<>.maybe .text) (<>.default (list) (..plural (' #licenses) ..license)) (<>.maybe ..organization) (<>.default (list) (..plural (' #developers) ..developer)) (<>.default (list) (..plural (' #contributors) ..contributor)) )) (def: repository (Parser //dependency.Repository) ..url) (def: type (Parser //dependency.Type) .text) (def: dependency (Parser //dependency.Dependency) (.tuple ($_ <>.and ..artifact' (<>.default //dependency.lux-library ..type) ))) (def: source (Parser /.Source) .text) (def: #export project (Parser /.Project) (<| .form (<>.after (.this! (' project:))) (`` ($_ <>.and ..artifact (<| (<>.default ..no-info) (..singular (' #info) ..info)) (<| (<>.default (list)) (..plural (' #repositories)) ..repository) (<| (<>.default (list)) (..plural (' #dependencies)) ..dependency) (<| (<>.default (list "source")) (..plural (' #sources)) ..source) (<| (<>.default "target") (..singular (' #target) .text)) (<>.maybe (..singular (' #program) .text)) (<>.maybe (..singular (' #test) .text)) ))))