From 065e8a4d8122d4616b570496915d2c0e2c78cd6b Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 11 Aug 2022 04:15:07 -0400 Subject: Re-named the "case" macro to "when". --- stdlib/source/program/aedifex.lux | 20 ++++++++++---------- stdlib/source/program/aedifex/artifact/snapshot.lux | 2 +- .../aedifex/artifact/snapshot/version/value.lux | 2 +- stdlib/source/program/aedifex/command/auto.lux | 2 +- stdlib/source/program/aedifex/command/build.lux | 20 ++++++++++---------- .../program/aedifex/command/deploy/release.lux | 2 +- stdlib/source/program/aedifex/command/install.lux | 2 +- stdlib/source/program/aedifex/command/test.lux | 2 +- .../source/program/aedifex/dependency/deployment.lux | 10 +++++----- .../source/program/aedifex/dependency/resolution.lux | 16 ++++++++-------- stdlib/source/program/aedifex/format.lux | 8 ++++---- stdlib/source/program/aedifex/hash.lux | 6 +++--- stdlib/source/program/aedifex/input.lux | 2 +- stdlib/source/program/aedifex/metadata/artifact.lux | 2 +- stdlib/source/program/aedifex/metadata/snapshot.lux | 4 ++-- stdlib/source/program/aedifex/package.lux | 2 +- stdlib/source/program/aedifex/pom.lux | 4 ++-- stdlib/source/program/aedifex/profile.lux | 2 +- stdlib/source/program/aedifex/project.lux | 4 ++-- stdlib/source/program/aedifex/repository.lux | 4 ++-- stdlib/source/program/aedifex/repository/local.lux | 2 +- stdlib/source/program/aedifex/repository/remote.lux | 6 +++--- stdlib/source/program/compositor.lux | 12 ++++++------ 23 files changed, 68 insertions(+), 68 deletions(-) (limited to 'stdlib/source/program') diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index 6300dc4fc..27127e3da 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -84,7 +84,7 @@ /repository.async) profile) [exit_code output] ((command console environment (file.async file.default) (shell.async shell.default) resolution) profile) - _ (case exit_code + _ (when exit_code shell.normal (in []) @@ -118,7 +118,7 @@ (do async.monad [outcome action] (async.future - (case outcome + (when outcome {try.#Success _} ..succeed! @@ -153,7 +153,7 @@ (do [! io.monad] [console (at ! each (|>> (try.else ..write_only) console.async) console.default)] - (case operation + (when operation {/cli.#Version} (..command (/command/version.do! console (at /.monoid identity))) @@ -161,12 +161,12 @@ _ (do ! [?profile (/input.read io.monad file.default profiles)] - (case ?profile + (when ?profile {try.#Failure error} (..fail! error) {try.#Success profile} - (case operation + (when operation {/cli.#Version} (in []) @@ -184,9 +184,9 @@ {/cli.#Deploy repository identity} (..command - (case (the /.#identity profile) + (when (the /.#identity profile) {.#Some artifact} - (case (dictionary.value repository (the /.#deploy_repositories profile)) + (when (dictionary.value repository (the /.#deploy_repositories profile)) {.#Some remote} (/command/deploy.do! ..environment (shell.async shell.default) @@ -213,7 +213,7 @@ profile)) {/cli.#Compilation compilation} - (case compilation + (when compilation {/cli.#Build} (..command (..with_dependencies ..environment console /command/build.do! profile)) {/cli.#Test} (..command @@ -222,13 +222,13 @@ {/cli.#Auto auto} (do ! [?watcher watch.default] - (case ?watcher + (when ?watcher {try.#Failure error} (..fail! error) {try.#Success watcher} (..command - (case auto + (when auto {/cli.#Build} (..with_dependencies ..environment console (/command/auto.do! /command/auto.delay watcher /command/build.do!) profile) {/cli.#Test} (..with_dependencies ..environment console (/command/auto.do! /command/auto.delay watcher /command/test.do!) profile)))))) )))))) diff --git a/stdlib/source/program/aedifex/artifact/snapshot.lux b/stdlib/source/program/aedifex/artifact/snapshot.lux index 6b6e97124..df36e1d0d 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot.lux @@ -59,7 +59,7 @@ (def .public (format snapshot) (-> Snapshot XML) (<| {xml.#Node .. xml.attributes} - (case snapshot + (when snapshot {#Local} (list ..local_copy_format) diff --git a/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux index 54d190c44..51a571ab8 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux @@ -31,7 +31,7 @@ (def .public (format (open "/[0]")) (%.Format Value) - (case /#snapshot + (when /#snapshot {///.#Local} /#version diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 4e4871f52..a5f02d37f 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -64,7 +64,7 @@ (do ! [_ (..pause delay) events (at watcher poll [])] - (case events + (when events {.#Item _} (do ! [_ ] diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 503fd5f1c..20492bf69 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -100,9 +100,9 @@ (def (lux resolution lux_dependency) (-> Resolution Dependency (Try [Resolution Lux])) (let [[[lux_group lux_name lux_version] lux_type] lux_dependency] - (case (..dependency_finder lux_group lux_name resolution) + (when (..dependency_finder lux_group lux_name resolution) {.#Some dependency} - (case lux_name + (when lux_name (^.with_template [ ] [ {try.#Success [(..remove_dependency dependency resolution) @@ -148,7 +148,7 @@ (def (< left right) (loop (again [left (text.all_split_by ..version_separator left) right (text.all_split_by ..version_separator right)]) - (case [left right] + (when [left right] [{.#Item leftH leftT} {.#Item rightH rightT}] (if (text#= leftH rightH) (again leftT rightT) @@ -175,7 +175,7 @@ identity [(the ///artifact.#group artifact) (the ///artifact.#name artifact)] version (the ///artifact.#version artifact)] - (case (dictionary.value identity uniques) + (when (dictionary.value identity uniques) {.#Some [current_version current_path]} (if (at version_order < version current_version) (dictionary.has identity [version dependency] uniques) @@ -213,7 +213,7 @@ (async.async [])) _ (|> (at process []) (async.upon! (function (again ?line) - (case ?line + (when ?line {try.#Failure error} (if (exception.match? shell.no_more_output error) (write! {try.#Success []}) @@ -222,7 +222,7 @@ {try.#Success line} (async.upon! (function (_ outcome) - (case outcome + (when outcome {try.#Failure error} (write! {try.#Failure error}) @@ -264,7 +264,7 @@ (def .public (with_jvm_class_path host_dependencies runtime) (-> (List Path) ///runtime.Runtime ///runtime.Runtime) - (case host_dependencies + (when host_dependencies {.#End} runtime @@ -279,7 +279,7 @@ (-> (Console Async) (Environment Async) (file.System Async) (Shell Async) Resolution (Command [Exit Lux Path])) (function (_ profile) (let [target (the ///.#target profile)] - (case (the ///.#program profile) + (when (the ///.#program profile) {.#None} (async#in (exception.except ..no_specified_program [])) @@ -292,7 +292,7 @@ [[resolution lux] (async#in (..lux resolution (the ///.#lux profile))) .let [host_dependencies (..host_dependencies fs home resolution) [[command_environment command lux_params] output] - (case lux + (when lux {#JVM dependency} [(|> (the ///.#java profile) (has ///runtime.#parameters (list "program._")) @@ -320,7 +320,7 @@ (..plural "--compiler" (list#each compiler.format (the ///.#compilers profile))) (..plural "--source" (set.list (the ///.#sources profile))) (..singular "--target" cache_directory) - (case program_module + (when program_module "" (..singular "--module" program_definition) _ (list#composite (..singular "--module" program_module) (..singular "--program" program_definition))) diff --git a/stdlib/source/program/aedifex/command/deploy/release.lux b/stdlib/source/program/aedifex/command/deploy/release.lux index d7394d7a3..88303069a 100644 --- a/stdlib/source/program/aedifex/command/deploy/release.lux +++ b/stdlib/source/program/aedifex/command/deploy/release.lux @@ -81,7 +81,7 @@ archive.empty {.#None}) try.trusted - (pipe.case + (pipe.when {.#Left it} it diff --git a/stdlib/source/program/aedifex/command/install.lux b/stdlib/source/program/aedifex/command/install.lux index 67739203a..b28e2b275 100644 --- a/stdlib/source/program/aedifex/command/install.lux +++ b/stdlib/source/program/aedifex/command/install.lux @@ -52,7 +52,7 @@ (def .public (do! console fs local profile) (-> (Console Async) (file.System Async) (Repository Async) (Command Any)) - (case (the /.#identity profile) + (when (the /.#identity profile) {.#Some identity} (do ///action.monad [package (|> profile diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux index 16a2694d4..f22372abf 100644 --- a/stdlib/source/program/aedifex/command/test.lux +++ b/stdlib/source/program/aedifex/command/test.lux @@ -49,7 +49,7 @@ [_ (is (Async (Try Any)) (console.write_line ..start console)) .let [host_dependencies (//build.host_dependencies fs home resolution) - [command_environment test_command test_parameters] (case compiler + [command_environment test_command test_parameters] (when compiler {//build.#JVM dependency} (|> program (///runtime.for (the ///.#java profile)) diff --git a/stdlib/source/program/aedifex/dependency/deployment.lux b/stdlib/source/program/aedifex/dependency/deployment.lux index 40d7e2532..c74eac1ee 100644 --- a/stdlib/source/program/aedifex/dependency/deployment.lux +++ b/stdlib/source/program/aedifex/dependency/deployment.lux @@ -53,12 +53,12 @@ (at repository upload (format artifact extension)))))] (do [! (try.with async.monad)] [_ (at repository upload artifact data)] - (case status + (when status {///dependency/status.#Unverified} (in []) {///dependency/status.#Partial partial} - (case partial + (when partial {.#Left sha-1} (deploy_hash ///hash.sha-1_codec ///artifact/extension.sha-1 sha-1) @@ -75,12 +75,12 @@ (with_expansions [ (format type ///artifact/extension.sha-1) (format type ///artifact/extension.md5)] (list.partial type - (case status + (when status {///dependency/status.#Unverified} (list) {///dependency/status.#Partial partial} - (list (case partial + (list (when partial {.#Left _} {.#Right _} )) @@ -96,7 +96,7 @@ snapshot (|> snapshot (revised [///metadata/snapshot.#versioning ///artifact/versioning.#snapshot] (function (_ snapshot) - (case snapshot + (when snapshot {///artifact/snapshot.#Local} {///artifact/snapshot.#Local} diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index ae075b5b0..81eb16502 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -84,7 +84,7 @@ (Async (Try (Maybe (Hash h)))))) (do async.monad [?actual (at repository download (///repository/remote.uri version_template artifact extension))] - (case ?actual + (when ?actual {try.#Success actual} (in (do [! try.monad] [output (at ! each (|>> ffi.as_string java/lang/String::trim ffi.of_string) @@ -111,7 +111,7 @@ ?md5 (..verified_hash data repository version_template artifact (format extension ///artifact/extension.md5) ///hash.md5 ///hash.md5_codec ..md5_does_not_match)] - (in [data (case [?sha-1 ?md5] + (in [data (when [?sha-1 ?md5] [{.#Some sha-1} {.#Some md5}] {//status.#Verified sha-1 md5} @@ -178,7 +178,7 @@ (def .public (any console repositories dependency) (-> (Console Async) (List (Repository Async)) Dependency (Async (Try Package))) - (case repositories + (when repositories {.#End} (|> dependency (exception.except ..cannot_resolve) @@ -188,7 +188,7 @@ (do [! async.monad] [_ (..announce_fetching console repository (the //.#artifact dependency)) outcome (..one repository dependency)] - (case outcome + (when outcome {try.#Success package} (do ! [_ (..announce_success console repository (the //.#artifact dependency))] @@ -209,13 +209,13 @@ failures (is (List Dependency) (list)) dependencies dependencies resolution resolution]) - (case dependencies + (when dependencies {.#End} (at async.monad in [successes failures resolution]) {.#Item head tail} - (case (the [//.#artifact ///artifact.#version] head) + (when (the [//.#artifact ///artifact.#version] head) ... Skip if there is no version "" (again repositories successes @@ -224,13 +224,13 @@ resolution) _ (do [! async.monad] [?package (is (Async (Try Package)) - (case (dictionary.value head resolution) + (when (dictionary.value head resolution) {.#Some package} (in {try.#Success package}) {.#None} (..any console repositories head)))] - (case ?package + (when ?package {try.#Success package} (do ! [.let [redundant? (is (Predicate Dependency) diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux index 5eb32d757..594b91014 100644 --- a/stdlib/source/program/aedifex/format.lux +++ b/stdlib/source/program/aedifex/format.lux @@ -30,7 +30,7 @@ (Format /.License) (`' [#name (, (code.text name)) #url (, (code.text url)) - #type (, (case type + #type (, (when type {/.#Repo} (' "repo") @@ -44,7 +44,7 @@ (def (developer [name url organization]) (Format /.Developer) - (case organization + (when organization {.#None} (`' [#name (, (code.text name)) #url (, (code.text url))]) @@ -76,7 +76,7 @@ (def (on_maybe field value format aggregate) (All (_ a) (-> Text (Maybe a) (Format a) Aggregate Aggregate)) - (case value + (when value {.#None} aggregate @@ -86,7 +86,7 @@ (def (on_list field value format aggregate) (All (_ a) (-> Text (List a) (Format a) Aggregate Aggregate)) - (case value + (when value {.#End} aggregate diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 4506720a1..eedf5e464 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -60,7 +60,7 @@ (Format Binary) (binary.mix (function (_ byte representation) (let [hex (at n.hex encoded byte) - hex (case (text.size hex) + hex (when (text.size hex) 1 (format "0" hex) _ hex)] (format representation hex))) @@ -128,7 +128,7 @@ chunk 0 output (binary.empty hash_size)]) (let [index (n.* chunk i64.bytes_per_i64)] - (case (text.split_at ..hex_per_chunk input) + (when (text.split_at ..hex_per_chunk input) {.#Some [head tail]} (do try.monad [head (at n.hex decoded head) @@ -136,7 +136,7 @@ (again tail (++ chunk) output)) {.#None} - (case (..hash_size input) + (when (..hash_size input) 0 (constructor output) (^.with_template [ ] [ diff --git a/stdlib/source/program/aedifex/input.lux b/stdlib/source/program/aedifex/input.lux index 509d8e16f..cf65de5b6 100644 --- a/stdlib/source/program/aedifex/input.lux +++ b/stdlib/source/program/aedifex/input.lux @@ -34,7 +34,7 @@ (let [parse (syntax.parse "" syntax.no_aliases (text.size source_code))] - (case (parse [location.dummy 0 source_code]) + (when (parse [location.dummy 0 source_code]) {.#Left [_ error]} {try.#Failure error} diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux index 5df1ae3a7..61fa4f9bb 100644 --- a/stdlib/source/program/aedifex/metadata/artifact.lux +++ b/stdlib/source/program/aedifex/metadata/artifact.lux @@ -179,7 +179,7 @@ (-> (Repository Async) Artifact (Async (Try Metadata))) (do async.monad [project (at repository download (..uri artifact))] - (case project + (when project {try.#Success binary_metadata} (in (|> binary_metadata (pipe.do try.monad diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux index 7b3e4d5d0..63000bac4 100644 --- a/stdlib/source/program/aedifex/metadata/snapshot.lux +++ b/stdlib/source/program/aedifex/metadata/snapshot.lux @@ -98,7 +98,7 @@ (revised ///artifact/versioning.#versions (is (-> (List ///artifact/snapshot/version.Version) (List ///artifact/snapshot/version.Version)) - (|>> (pipe.case + (|>> (pipe.when (list) (list ) @@ -127,7 +127,7 @@ (-> (Repository Async) Artifact (Async (Try Metadata))) (do async.monad [project (at repository download (..uri artifact))] - (case project + (when project {try.#Success project} (in (|> project (pipe.do try.monad diff --git a/stdlib/source/program/aedifex/package.lux b/stdlib/source/program/aedifex/package.lux index cf4aa1e49..70f925d84 100644 --- a/stdlib/source/program/aedifex/package.lux +++ b/stdlib/source/program/aedifex/package.lux @@ -36,7 +36,7 @@ (with_template [ ] [(def .public ( package) (-> Package Bit) - (case (the #origin package) + (when (the #origin package) { _} true diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index c87dcabaf..eed536317 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -65,7 +65,7 @@ (def distribution (-> /.Distribution XML) - (|>> (pipe.case + (|>> (pipe.when {/.#Repo} "repo" {/.#Manual} "manual") (..property "distribution"))) @@ -141,7 +141,7 @@ (def .public (write value) (-> /.Profile (Try XML)) - (case (the /.#identity value) + (when (the /.#identity value) {.#Some identity} {try.#Success {xml.#Node ["" ..project_tag] xml.attributes diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index 627073d79..fa00bc64c 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -52,7 +52,7 @@ (Equivalence Distribution) (implementation (def (= reference subject) - (case [reference subject] + (when [reference subject] (^.with_template [] [[{} {}] true]) diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux index d94a31b48..2f4d853af 100644 --- a/stdlib/source/program/aedifex/project.lux +++ b/stdlib/source/program/aedifex/project.lux @@ -53,9 +53,9 @@ (def (profile' lineage project name) (-> (Set Name) Project Name (Try Profile)) - (case (dictionary.value name project) + (when (dictionary.value name project) {.#Some profile} - (case (list.example (set.member? lineage) + (when (list.example (set.member? lineage) (the //.#parents profile)) {.#Some ouroboros} (exception.except ..circular_dependency [ouroboros name]) diff --git a/stdlib/source/program/aedifex/repository.lux b/stdlib/source/program/aedifex/repository.lux index bd1d23d3e..ea0507bcf 100644 --- a/stdlib/source/program/aedifex/repository.lux +++ b/stdlib/source/program/aedifex/repository.lux @@ -56,7 +56,7 @@ (stm.commit! (do [! stm.monad] [|state| (stm.read state)] - (case (at mock on_download uri |state|) + (when (at mock on_download uri |state|) {try.#Success [|state| output]} (do ! [_ (stm.write |state| state)] @@ -69,7 +69,7 @@ (stm.commit! (do [! stm.monad] [|state| (stm.read state)] - (case (at mock on_upload uri content |state|) + (when (at mock on_upload uri content |state|) {try.#Success |state|} (do ! [_ (stm.write |state| state)] diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux index af9b502aa..dcc604306 100644 --- a/stdlib/source/program/aedifex/repository/local.lux +++ b/stdlib/source/program/aedifex/repository/local.lux @@ -55,7 +55,7 @@ _ (is (Async (Try Any)) (if ? (in {try.#Success []}) - (case (file.parent fs absolute_path) + (when (file.parent fs absolute_path) {.#Some parent} (file.make_directories async.monad fs parent) diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index 10b7f372d..bb89a6235 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -67,7 +67,7 @@ (http.headers ..base_headers) {.#None} http))] - (case status + (when status http/status.ok (at ! each product.right ((the @http.#body message) {.#None})) @@ -80,7 +80,7 @@ (do (try.with io.monad) [[status message] (is (IO (Try (@http.Response IO))) (http.put (format address uri) - (http.headers (case identity + (http.headers (when identity {.#None} ..base_headers @@ -90,7 +90,7 @@ {.#Some content} http)) _ ((the @http.#body message) {.#Some 0})] - (case status + (when status http/status.created (in []) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index 108325fd7..313939963 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -62,7 +62,7 @@ (-> Text (Async (Try a)) (Async a))) (do [! async.monad] [?output action] - (case ?output + (when ?output {try.#Failure error} (let [report (format text.new_line failure_description text.new_line @@ -70,7 +70,7 @@ (do ! [_ (with_expansions [ (in {try.#Success (debug.log! report)})] (for @.js (is (Async (Try Any)) - (case console.default + (when console.default {.#None} @@ -97,9 +97,9 @@ (def (package! fs host_dependencies [packager package] archive context) (-> (file.System Async) (Dictionary file.Path Binary) [Packager file.Path] Archive (Maybe unit.ID) (Async (Try Any))) - (case (packager host_dependencies archive context) + (when (packager host_dependencies archive context) {try.#Success content} - (case content + (when content {.#Left content} (at fs write package content) @@ -121,7 +121,7 @@ (loop (again [pending host_dependencies output (is (Dictionary file.Path Binary) (dictionary.empty text.hash))]) - (case pending + (when pending {.#End} (in output) @@ -152,7 +152,7 @@ (Async Any))) (do [! async.monad] [platform (async.future platform)] - (case service + (when service {cli.#Compilation compilation} (<| (or_crash! "Compilation failed:") ..timed -- cgit v1.2.3