aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2017-07-22 13:59:38 -0400
committerEduardo Julian2017-07-22 13:59:38 -0400
commit337158b78b5f42a6b9fc46ae367d3179a944d8bb (patch)
tree68a683396eb62096ea6118a4032a7992975866c3 /stdlib
parent5824d2c5b09889c3b0314694c4069c234bd992cf (diff)
- Some utility functions.
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)))