diff options
author | Eduardo Julian | 2021-06-30 23:24:55 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-06-30 23:24:55 -0400 |
commit | 744ee69630de59ca3ba660b0aab6361cd17ce1b4 (patch) | |
tree | 329c11b8c3522c319c99ebd4d7c51ee0e7464bae /stdlib/source/program/aedifex/repository | |
parent | 6633cd42f2892ea71530ddeeb93a7e7c0b59faa3 (diff) |
"signature:" -> "interface:" & "structure:" -> "implementation:"
"signature" & "structure" feel like very ML-specific terminology and might not be easy on programmers unfamiliar with it.
Diffstat (limited to '')
-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 |
3 files changed, 20 insertions, 21 deletions
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 |