diff options
Diffstat (limited to 'stdlib/source/program/aedifex')
-rw-r--r-- | stdlib/source/program/aedifex/artifact/snapshot.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/artifact/time/date.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/cli.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/command/clean.lux | 29 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/dependency/status.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/hash.lux | 4 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/profile.lux | 4 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/project.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/repository.lux | 8 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/repository/local.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/repository/remote.lux | 31 |
11 files changed, 48 insertions, 40 deletions
diff --git a/stdlib/source/program/aedifex/artifact/snapshot.lux b/stdlib/source/program/aedifex/artifact/snapshot.lux index 0488d76dd..836365fed 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot.lux @@ -18,7 +18,7 @@ #Local (#Remote Stamp)) -(structure: any_equivalence +(implementation: any_equivalence (Equivalence Any) (def: (= _ _) diff --git a/stdlib/source/program/aedifex/artifact/time/date.lux b/stdlib/source/program/aedifex/artifact/time/date.lux index 989abb5fc..655b8f6c2 100644 --- a/stdlib/source/program/aedifex/artifact/time/date.lux +++ b/stdlib/source/program/aedifex/artifact/time/date.lux @@ -56,7 +56,7 @@ (-> Date date.Date) (|>> :representation)) - (structure: #export equivalence + (implementation: #export equivalence (Equivalence Date) (def: (= reference subject) diff --git a/stdlib/source/program/aedifex/cli.lux b/stdlib/source/program/aedifex/cli.lux index f2f502bac..0c943efc9 100644 --- a/stdlib/source/program/aedifex/cli.lux +++ b/stdlib/source/program/aedifex/cli.lux @@ -18,7 +18,7 @@ #Build #Test) -(structure: any_equivalence +(implementation: any_equivalence (Equivalence Any) (def: (= reference subject) diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux index ecb71b59d..b966fe85e 100644 --- a/stdlib/source/program/aedifex/command/clean.lux +++ b/stdlib/source/program/aedifex/command/clean.lux @@ -4,6 +4,7 @@ ["." monad (#+ do)]] [control ["." try (#+ Try)] + ["." exception] [security ["!" capability]] [concurrency @@ -35,15 +36,23 @@ (def: #export (do! console fs profile) (-> (Console Promise) (file.System Promise) (Command Any)) - (do {! ///action.monad} + (do promise.monad [#let [target (get@ #///.target profile)] root (: (Promise (Try (Directory Promise))) - (!.use (\ fs directory) target)) - _ (loop [root root] - (do ! - [_ (..clean_files! root) - subs (: (Promise (Try (List (Directory Promise)))) - (!.use (\ root directories) [])) - _ (monad.map ! recur subs)] - (!.use (\ root discard) [])))] - (console.write_line (..success target) console))) + (!.use (\ fs directory) target))] + (case root + (#try.Success root) + (do {! ///action.monad} + [_ (loop [root root] + (do ! + [_ (..clean_files! root) + subs (: (Promise (Try (List (Directory Promise)))) + (!.use (\ root directories) [])) + _ (monad.map ! recur subs)] + (!.use (\ root discard) [])))] + (console.write_line (..success target) console)) + + (#try.Failure error) + (if (exception.match? file.cannot_find_directory error) + (console.write_line (..success target) console) + (\ promise.monad wrap (#try.Failure error)))))) diff --git a/stdlib/source/program/aedifex/dependency/status.lux b/stdlib/source/program/aedifex/dependency/status.lux index 82d99e9aa..8c4db9ddd 100644 --- a/stdlib/source/program/aedifex/dependency/status.lux +++ b/stdlib/source/program/aedifex/dependency/status.lux @@ -15,7 +15,7 @@ (Hash MD5))) (#Verified (Hash SHA-1) (Hash MD5))) -(structure: any_equivalence +(implementation: any_equivalence (Equivalence Any) (def: (= _ _) diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index b94e2a0cf..2e0e35db0 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -145,7 +145,7 @@ (exception.throw ..not_a_hash [(..encoding_size size) encoded])))) (template [<codec> <hash> <nat> <constructor>] - [(structure: #export <codec> + [(implementation: #export <codec> (Codec Text (Hash <hash>)) (def: encode (|>> :representation ..encode)) @@ -155,7 +155,7 @@ [md5_codec MD5 ..md5::size ..as_md5] ) - (structure: #export equivalence + (implementation: #export equivalence (All [h] (Equivalence (Hash h))) (def: (= reference subject) diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index 98eb1c43e..eb686cc15 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -31,7 +31,7 @@ #Repo #Manual) -(structure: distribution_equivalence +(implementation: distribution_equivalence (Equivalence Distribution) (def: (= reference subject) @@ -179,7 +179,7 @@ ## #deploy_repositories (dictionary.equivalence text.equivalence))) -(structure: #export monoid +(implementation: #export monoid (Monoid Profile) (def: identity diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux index 5dce87e0a..a35a3651c 100644 --- a/stdlib/source/program/aedifex/project.lux +++ b/stdlib/source/program/aedifex/project.lux @@ -31,7 +31,7 @@ (Equivalence Project) (dictionary.equivalence //.equivalence)) -(structure: #export monoid +(implementation: #export monoid (Monoid Project) (def: identity diff --git a/stdlib/source/program/aedifex/repository.lux b/stdlib/source/program/aedifex/repository.lux index 230888cef..c5f822633 100644 --- a/stdlib/source/program/aedifex/repository.lux +++ b/stdlib/source/program/aedifex/repository.lux @@ -14,7 +14,7 @@ [net [uri (#+ URI)]]]]) -(signature: #export (Repository !) +(interface: #export (Repository !) (: (-> URI (! (Try Binary))) download) (: (-> URI Binary (! (Try Any))) @@ -22,7 +22,7 @@ (def: #export (async repository) (-> (Repository IO) (Repository Promise)) - (structure + (implementation (def: (download uri) (promise.future (\ repository download uri))) @@ -30,7 +30,7 @@ (promise.future (\ repository upload uri content))) )) -(signature: #export (Simulation s) +(interface: #export (Simulation s) (: (-> URI s (Try [s Binary])) on_download) (: (-> URI Binary s (Try s)) @@ -39,7 +39,7 @@ (def: #export (mock simulation init) (All [s] (-> (Simulation s) s (Repository Promise))) (let [state (stm.var init)] - (structure + (implementation (def: (download uri) (stm.commit (do {! stm.monad} diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux index d026559c9..2841bbd32 100644 --- a/stdlib/source/program/aedifex/repository/local.lux +++ b/stdlib/source/program/aedifex/repository/local.lux @@ -48,7 +48,7 @@ (: (Promise (Try (File Promise))) (!.use (\ system file) absolute_path))))) -(structure: #export (repository program system) +(implementation: #export (repository program system) (-> (Program Promise) (file.System Promise) (//.Repository Promise)) (def: (download uri) diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index eb285bb67..dcf1e1d51 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -80,12 +80,12 @@ (format (///artifact.uri version_template artifact) extension)) (def: buffer_size - (n.* 512 1,024)) + (n.* 1,024 1,024)) (def: user_agent (format "LuxAedifex/" (version.format language/lux.version))) -(structure: #export (repository identity address) +(implementation: #export (repository identity address) (All [s] (-> (Maybe Identity) Address (//.Repository IO))) (def: (download uri) @@ -99,21 +99,20 @@ input (|> connection java/net/URLConnection::getInputStream (\ ! map (|>> java/io/BufferedInputStream::new))) - #let [buffer (binary.create ..buffer_size)] - output (loop [output (\ binary.monoid identity)] + #let [buffer (binary.create ..buffer_size)]] + (loop [output (\ binary.monoid identity)] + (do ! + [bytes_read (java/io/BufferedInputStream::read buffer +0 (.int ..buffer_size) input)] + (case bytes_read + -1 (do ! + [_ (java/lang/AutoCloseable::close input)] + (wrap output)) + +0 (recur output) + _ (if (n.= ..buffer_size bytes_read) + (recur (\ binary.monoid compose output buffer)) (do ! - [bytes_read (java/io/BufferedInputStream::read buffer +0 (.int ..buffer_size) input)] - (case bytes_read - -1 (do ! - [_ (java/lang/AutoCloseable::close input)] - (wrap output)) - +0 (recur output) - _ (if (n.= ..buffer_size bytes_read) - (recur (\ binary.monoid compose output buffer)) - (do ! - [chunk (\ io.monad wrap (binary.slice 0 (.nat bytes_read) buffer))] - (recur (\ binary.monoid compose output chunk)))))))] - (wrap output))) + [chunk (\ io.monad wrap (binary.slice 0 (.nat bytes_read) buffer))] + (recur (\ binary.monoid compose output chunk))))))))) (def: (upload uri content) (case identity |