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 | |
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/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 | ||||
-rw-r--r-- | stdlib/source/program/scriptum.lux | 18 |
12 files changed, 57 insertions, 49 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 diff --git a/stdlib/source/program/scriptum.lux b/stdlib/source/program/scriptum.lux index 2a205287a..a32a14f8f 100644 --- a/stdlib/source/program/scriptum.lux +++ b/stdlib/source/program/scriptum.lux @@ -267,7 +267,7 @@ (type: Organization {#types (List Value) #macros (List [Text Code]) - #structures (List Value) + #implementations (List Value) #values (List Value)}) (def: (lux-module? module-name) @@ -289,8 +289,8 @@ (|>> (#.Cons [name def-annotations]))) organization) - (macro.structure? def-annotations) - (update@ #structures + (macro.implementation? def-annotations) + (update@ #implementations (: (Mutation (List Value)) (|>> (#.Cons [name def-annotations def-type]))) organization) @@ -311,12 +311,12 @@ (-> (List [Text Definition]) Organization) (let [init {#types (list) #macros (list) - #structures (list) + #implementations (list) #values (list)}] (|> (list\fold add-definition init defs) (update@ #types (list.sort name-sort)) (update@ #macros (list.sort name-sort)) - (update@ #structures (list.sort name-sort)) + (update@ #implementations (list.sort name-sort)) (update@ #values (list.sort name-sort))))) (def: (unravel-type-func level type) @@ -359,7 +359,7 @@ _ (format "(" (text.join-with " " (list& _name type-arguments)) ")")) nesting (list.size type-arguments)]] - (wrap (md.code (format (if signature? "(signature: " "(type: ") + (wrap (md.code (format (if signature? "(interface: " "(type: ") (if recursive-type? "#rec " "") usage text.new-line (|> type @@ -440,7 +440,7 @@ (list\fold (function.flip md.then) (md.heading/2 <header>))))] - [document-structure document-structures "Structures"] + [document-implementation document-implementations "Implementations"] [document-value document-values "Values"] ) @@ -454,7 +454,7 @@ (def: (document-module [[module-name module] organization]) (-> [[Text Module] Organization] (Meta [Text (Markdown Block)])) (do macro.monad - [#let [(^slots [#types #macros #structures #values]) organization + [#let [(^slots [#types #macros #implementations #values]) organization annotations (|> module (get@ #.module-annotations) (maybe.default (' {})) @@ -472,7 +472,7 @@ #let [documentation ($_ md.then types-documentation (if (list.empty? macros) empty-block (document-macros module-name macros)) - (if (list.empty? structures) empty-block (document-structures module-name structures)) + (if (list.empty? implementations) empty-block (document-implementations module-name implementations)) (if (list.empty? values) empty-block (document-values module-name values)))]] (wrap [module-name ($_ md.then |