From cfa0a075b89a0df4618e7009f05c157393cbba72 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 1 Dec 2020 09:27:58 -0400 Subject: Added specialized root/2 and root/3 functions in lux/math. --- stdlib/source/program/aedifex/cache.lux | 6 +- stdlib/source/program/aedifex/command/build.lux | 1 - stdlib/source/program/aedifex/command/test.lux | 1 - stdlib/source/program/aedifex/shell.lux | 108 ------------------------ 4 files changed, 3 insertions(+), 113 deletions(-) delete mode 100644 stdlib/source/program/aedifex/shell.lux (limited to 'stdlib/source/program/aedifex') diff --git a/stdlib/source/program/aedifex/cache.lux b/stdlib/source/program/aedifex/cache.lux index dca14b496..1aee65405 100644 --- a/stdlib/source/program/aedifex/cache.lux +++ b/stdlib/source/program/aedifex/cache.lux @@ -86,11 +86,11 @@ (def: (decode codec data) (All [a] (-> (Codec Text a) Binary (Try a))) - (let [(^open "_@.") try.monad] + (let [(^open "_\.") try.monad] (|> data encoding.from-utf8 - (_@map (:: codec decode)) - _@join))) + (_\map (:: codec decode)) + _\join))) (def: #export (read-one system [artifact type]) (-> (file.System Promise) Dependency (Promise (Try Package))) diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 94d6760b6..30206095e 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -32,7 +32,6 @@ ["#." local] ["#." cache] ["#." repository] - ["#." shell] ["#." runtime] ["#." dependency (#+ Dependency) ["#/." resolution (#+ Resolution)]] diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux index 2996a6741..f4da76ac4 100644 --- a/stdlib/source/program/aedifex/command/test.lux +++ b/stdlib/source/program/aedifex/command/test.lux @@ -21,7 +21,6 @@ ["/#" // #_ ["#." action] ["#." command (#+ Command)] - ["#." shell] ["#." runtime] [dependency [resolution (#+ Resolution)]]]]) diff --git a/stdlib/source/program/aedifex/shell.lux b/stdlib/source/program/aedifex/shell.lux deleted file mode 100644 index e70571667..000000000 --- a/stdlib/source/program/aedifex/shell.lux +++ /dev/null @@ -1,108 +0,0 @@ -(.module: - [lux #* - ["." host (#+ import:)] - [abstract - [monad (#+ do)]] - [control - ["." io (#+ IO)] - ["." try (#+ Try)] - ["." exception (#+ exception:)] - [concurrency - ["." promise]]] - [data - [text - ["%" format (#+ format)]] - [number - ["." int]]] - [world - [file (#+ Path)]]] - ["." // #_ - ["#." action (#+ Action)]]) - -(import: java/lang/String) - -(import: java/io/InputStream) - -(import: java/io/Reader) - -(import: java/io/InputStreamReader - ["#::." - (new [java/io/InputStream])]) - -(import: java/io/BufferedReader - ["#::." - (new [java/io/Reader]) - (readLine [] #io #try java/lang/String)]) - -(import: java/lang/Process - ["#::." - (getInputStream [] java/io/InputStream) - (getErrorStream [] java/io/InputStream) - (waitFor [] #io #try int)]) - -(import: java/io/File - ["#::." - (new [java/lang/String])]) - -(import: java/lang/Runtime - ["#::." - (#static getRuntime [] #io java/lang/Runtime) - (exec [java/lang/String #? [java/lang/String] java/io/File] #io #try java/lang/Process)]) - -(template [] - [(exception: #export ( {working-directory Text} {command Text} {error Text}) - (exception.report - ["Working directory" (%.text working-directory)] - ["Command" (%.text command)] - ["Error" (%.text error)]))] - - [failure-to-execute-command] - [failure-during-command-execution] - ) - -(exception: #export (abnormal-exit {working-directory Text} {command Text} {code Int}) - (exception.report - ["Working Directory" (%.text working-directory)] - ["Command" (%.text command)] - ["Code" (%.int code)])) - -(def: (consume-stream working-directory command stream) - (-> Text Path java/io/InputStream (IO (Try Any))) - (let [reader (|> stream java/io/InputStreamReader::new java/io/BufferedReader::new)] - (loop [_ []] - (do io.monad - [?line (java/io/BufferedReader::readLine reader)] - (case ?line - (#try.Success line) - (exec (log! line) - (recur [])) - - (#try.Failure error) - (wrap (exception.throw ..failure-during-command-execution [working-directory command error]))))))) - -(def: normal-exit - +0) - -(def: #export (execute command working-directory) - (-> Text Path (Action Any)) - (promise.future - (do {! io.monad} - [runtime (java/lang/Runtime::getRuntime) - ?process (java/lang/Runtime::exec command #.None (java/io/File::new working-directory) runtime)] - (case ?process - (#try.Success process) - (do ! - [_ (..consume-stream working-directory command (java/lang/Process::getInputStream process)) - _ (..consume-stream working-directory command (java/lang/Process::getErrorStream process)) - ?exit-code (java/lang/Process::waitFor process)] - (case ?exit-code - (#try.Success exit-code) - (if (int.= ..normal-exit exit-code) - (wrap (#try.Success [])) - (wrap (exception.throw ..abnormal-exit [working-directory command exit-code]))) - - (#try.Failure error) - (wrap (exception.throw ..failure-to-execute-command [working-directory command error])))) - - (#try.Failure error) - (wrap (exception.throw ..failure-to-execute-command [working-directory command error])))))) -- cgit v1.2.3