aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/repository
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/program/aedifex/repository')
-rw-r--r--stdlib/source/program/aedifex/repository/local.lux40
-rw-r--r--stdlib/source/program/aedifex/repository/remote.lux80
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])))))
+ ))