diff options
author | Eduardo Julian | 2022-06-12 13:33:48 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-06-12 13:33:48 -0400 |
commit | 8c3a1afab9efeb86e2f53d743551fc689fbad257 (patch) | |
tree | 396b2fd29bac407544d2136a0d9e6e3b8b2c30af /stdlib/source/program/aedifex/repository | |
parent | 9c21fd1f33eb52fb971d493ad21a67036d68b841 (diff) |
De-sigil-ification: suffix : [Part 4]
Diffstat (limited to 'stdlib/source/program/aedifex/repository')
-rw-r--r-- | stdlib/source/program/aedifex/repository/local.lux | 40 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/repository/remote.lux | 80 |
2 files changed, 60 insertions, 60 deletions
diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux index 6f031ccfd..6e9db2755 100644 --- a/stdlib/source/program/aedifex/repository/local.lux +++ b/stdlib/source/program/aedifex/repository/local.lux @@ -38,27 +38,27 @@ (..path /) (format (..root program fs) /)))) -(implementation: .public (repository program fs) +(def: .public (repository program fs) (-> (Program Async) (file.System Async) (//.Repository Async)) + (implementation + (def: description + (..root program fs)) - (def: description - (..root program fs)) + (def: download + (|>> (..absolute_path program fs) + (at fs read))) - (def: download - (|>> (..absolute_path program fs) - (at fs read))) + (def: (upload uri content) + (do [! async.monad] + [.let [absolute_path (..absolute_path program fs uri)] + ? (at 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) - (def: (upload uri content) - (do [! async.monad] - [.let [absolute_path (..absolute_path program fs uri)] - ? (at 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 []}))))] - (at fs write absolute_path content)))) + _ + (in {try.#Success []}))))] + (at fs write absolute_path content))))) diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index 29bcbad84..b5fbc6b13 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -54,45 +54,45 @@ (List [Text Text]) (list ["User-Agent" ..user_agent])) -(implementation: .public (repository http identity address) +(def: .public (repository http identity address) (All (_ s) (-> (http.Client IO) (Maybe Identity) Address (//.Repository IO))) + (implementation + (def: description + address) + (def: (download uri) + (do [! (try.with io.monad)] + [[status message] (is (IO (Try (@http.Response IO))) + (http.get (format address uri) + (http.headers ..base_headers) + {.#None} + http))] + (case status + (pattern (static http/status.ok)) + (at ! each product.right ((the @http.#body message) {.#None})) + + _ + (do ! + [_ ((the @http.#body message) {.#Some 0})] + (at io.monad in (exception.except ..download_failure [(format address uri) status])))))) - (def: description - address) - (def: (download uri) - (do [! (try.with io.monad)] - [[status message] (is (IO (Try (@http.Response IO))) - (http.get (format address uri) - (http.headers ..base_headers) - {.#None} - http))] - (case status - (pattern (static http/status.ok)) - (at ! each product.right ((the @http.#body message) {.#None})) - - _ - (do ! - [_ ((the @http.#body message) {.#Some 0})] - (at io.monad in (exception.except ..download_failure [(format address uri) status])))))) - - (def: (upload uri content) - (do (try.with io.monad) - [[status message] (is (IO (Try (@http.Response IO))) - (http.put (format address uri) - (http.headers (case identity - {.#None} - ..base_headers - - {.#Some [user password]} - (partial_list ["Authorization" (//identity.basic_auth user password)] - ..base_headers))) - {.#Some content} - http)) - _ ((the @http.#body message) {.#Some 0})] - (case status - (pattern (static http/status.created)) - (in []) - - _ - (at io.monad in (exception.except ..upload_failure [(format address uri) status]))))) - ) + (def: (upload uri content) + (do (try.with io.monad) + [[status message] (is (IO (Try (@http.Response IO))) + (http.put (format address uri) + (http.headers (case identity + {.#None} + ..base_headers + + {.#Some [user password]} + (partial_list ["Authorization" (//identity.basic_auth user password)] + ..base_headers))) + {.#Some content} + http)) + _ ((the @http.#body message) {.#Some 0})] + (case status + (pattern (static http/status.created)) + (in []) + + _ + (at io.monad in (exception.except ..upload_failure [(format address uri) status]))))) + )) |