aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex
diff options
context:
space:
mode:
authorEduardo Julian2020-12-22 21:42:17 -0400
committerEduardo Julian2020-12-22 21:42:17 -0400
commitcad959345afb8bf0bd1e5eefe6c63f136833b3ce (patch)
tree698a0189c6d30109a5ef27d67ab61e037abb011e /stdlib/source/program/aedifex
parent68b1dd82f23d6648ac3d9075a8f84b0174392945 (diff)
Properly naming unicode Block type.
Diffstat (limited to '')
-rw-r--r--stdlib/source/program/aedifex.lux34
-rw-r--r--stdlib/source/program/aedifex/dependency/status.lux35
2 files changed, 56 insertions, 13 deletions
diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux
index 41d7f9b2f..cfa106407 100644
--- a/stdlib/source/program/aedifex.lux
+++ b/stdlib/source/program/aedifex.lux
@@ -82,18 +82,27 @@
(format (%.text name) " := " (%.text repo)))
(dictionary.entries options))]))
+(def: succeed!
+ (IO Any)
+ (\ program.default exit shell.normal))
+
+(def: (fail! error)
+ (-> Text (IO Any))
+ (exec
+ (log! error)
+ (\ program.default exit shell.error)))
+
(def: (command action)
(All [a] (-> (Promise (Try a)) (IO Any)))
(exec (do promise.monad
- [outcome action
- #let [code (case outcome
- (#try.Failure error)
- (exec (log! error)
- shell.normal)
-
- (#try.Success _)
- shell.error)]]
- (promise.future (\ program.default exit code)))
+ [outcome action]
+ (promise.future
+ (case outcome
+ (#try.Success _)
+ ..succeed!
+
+ (#try.Failure error)
+ (..fail! error))))
(\ io.monad wrap [])))
(program: [{[profile operation] /cli.command}]
@@ -101,7 +110,7 @@
[?console console.default]
(case (try\map console.async ?console)
(#try.Failure error)
- (wrap (log! error))
+ (..fail! error)
(#try.Success console)
(case operation
@@ -114,8 +123,7 @@
[?profile (/input.read io.monad file.default profile)]
(case ?profile
(#try.Failure error)
- (exec (log! error)
- (\ program.default exit shell.error))
+ (..fail! error)
(#try.Success profile)
(let [program (program.async program.default)]
@@ -169,7 +177,7 @@
[?watcher watch.default]
(case ?watcher
(#try.Failure error)
- (wrap (log! error))
+ (..fail! error)
(#try.Success watcher)
(..command
diff --git a/stdlib/source/program/aedifex/dependency/status.lux b/stdlib/source/program/aedifex/dependency/status.lux
new file mode 100644
index 000000000..fa62f643e
--- /dev/null
+++ b/stdlib/source/program/aedifex/dependency/status.lux
@@ -0,0 +1,35 @@
+(.module:
+ [lux #*
+ [abstract
+ [equivalence (#+ Equivalence)]]
+ [data
+ ["." sum]
+ ["." product]]]
+ ["." /// #_
+ ["#." hash (#+ Hash SHA-1 MD5)]])
+
+(type: #export Status
+ #Unverified
+ (#Partial (Either (Hash SHA-1)
+ (Hash MD5)))
+ (#Verified (Hash SHA-1) (Hash MD5)))
+
+(structure: any-equivalence
+ (Equivalence Any)
+
+ (def: (= _ _)
+ true))
+
+(def: #export equivalence
+ (Equivalence Status)
+ ($_ sum.equivalence
+ ..any-equivalence
+ ($_ sum.equivalence
+ ///hash.equivalence
+ ///hash.equivalence
+ )
+ ($_ product.equivalence
+ ///hash.equivalence
+ ///hash.equivalence
+ )
+ ))