(.using [library [lux "*" [abstract [monad {"+" do}]] [control ["[0]" try {"+" Try}] [concurrency ["[0]" async {"+" Async}]]] [data ["[0]" text ["%" format {"+" format}]]] [world [program {"+" Program}] ["[0]" file] [net ["[0]" uri {"+" URI}]]]]] ["[0]" // ["/[1]" // "_" ["[1][0]" local] ["[1][0]" metadata]]]) (def: (root program /) (-> (Program Async) Text file.Path) (|> ///local.repository (text.replaced uri.separator /) (format (# program home) /))) (def: (path /) (-> Text (-> URI file.Path)) (text.replaced uri.separator /)) (def: (absolute_path program /) (-> (Program Async) Text (-> URI file.Path)) (|>> ///metadata.local_uri (..path /) (format (..root program /) /))) (implementation: .public (repository program fs) (-> (Program Async) (file.System Async) (//.Repository Async)) (def: description (..root program (# fs separator))) (def: download (|>> (..absolute_path program (# fs separator)) (# fs read))) (def: (upload uri content) (do [! async.monad] [.let [absolute_path (..absolute_path program (# fs separator) uri)] ? (# fs file? absolute_path) _ (is (Async (Try Any)) (if ? (in {try.#Success []}) (case (file.parent fs absolute_path) {.#Some parent} (file.make_directories async.monad fs parent) _ (in {try.#Success []}))))] (# fs write absolute_path content))))