aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/concurrency/task.lux4
-rw-r--r--stdlib/source/lux/data/result.lux11
2 files changed, 14 insertions, 1 deletions
diff --git a/stdlib/source/lux/concurrency/task.lux b/stdlib/source/lux/concurrency/task.lux
index 6f880ef79..9fc35ee5f 100644
--- a/stdlib/source/lux/concurrency/task.lux
+++ b/stdlib/source/lux/concurrency/task.lux
@@ -73,3 +73,7 @@
(task Unit))}
(wrap (list (` (: (;;Task (~ type))
(P;promise' #;None))))))
+
+(def: #export (from-promise promise)
+ (All [a] (-> (P;Promise a) (Task a)))
+ (:: P;Functor<Promise> map (|>. #R;Success) promise))
diff --git a/stdlib/source/lux/data/result.lux b/stdlib/source/lux/data/result.lux
index 77fd144f9..99c52e664 100644
--- a/stdlib/source/lux/data/result.lux
+++ b/stdlib/source/lux/data/result.lux
@@ -1,5 +1,5 @@
(;module:
- lux
+ [lux #- assume]
(lux (control functor
applicative
["M" monad #*])))
@@ -68,3 +68,12 @@
(def: #export (fail message)
(All [a] (-> Text (Result a)))
(#Error message))
+
+(def: #export (assume result)
+ (All [a] (-> (Result a) a))
+ (case result
+ (#Success value)
+ value
+
+ (#Error message)
+ (error! message)))