aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/concurrency/task.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-12-15 12:39:15 -0400
committerEduardo Julian2018-12-15 12:39:15 -0400
commitf6e280bd4ab41d12083c0eef2c823ad3962d6a04 (patch)
tree41173ee305fcf42736ae96cf7e61d6fac11b6175 /stdlib/source/lux/concurrency/task.lux
parent07426c47503a84666a9a7824d76e8d5730492d75 (diff)
Moved the "lux/concurrency" modules under "lux/control".
Diffstat (limited to 'stdlib/source/lux/concurrency/task.lux')
-rw-r--r--stdlib/source/lux/concurrency/task.lux82
1 files changed, 0 insertions, 82 deletions
diff --git a/stdlib/source/lux/concurrency/task.lux b/stdlib/source/lux/concurrency/task.lux
deleted file mode 100644
index c03ab7647..000000000
--- a/stdlib/source/lux/concurrency/task.lux
+++ /dev/null
@@ -1,82 +0,0 @@
-(.module:
- [lux #*
- [control
- [functor (#+ Functor)]
- [apply (#+ Apply)]
- [monad (#+ Monad do)]
- ["ex" exception (#+ Exception)]]
- [data
- ["." error (#+ Error)]]
- ["." macro
- ["s" syntax (#+ syntax: Syntax)]]]
- [//
- ["." promise (#+ Promise)]])
-
-(type: #export (Task a)
- (Promise (Error a)))
-
-(def: #export (fail error)
- (All [a] (-> Text (Task a)))
- (:: promise.Monad<Promise> wrap (#error.Error error)))
-
-(def: #export (throw exception message)
- (All [e a] (-> (Exception e) e (Task a)))
- (:: promise.Monad<Promise> wrap
- (ex.throw exception message)))
-
-(def: #export (return value)
- (All [a] (-> a (Task a)))
- (:: promise.Monad<Promise> wrap (#error.Success value)))
-
-(def: #export (try computation)
- (All [a] (-> (Task a) (Task (Error a))))
- (:: promise.Functor<Promise> map (|>> #error.Success) computation))
-
-(structure: #export _ (Functor Task)
- (def: (map f fa)
- (:: promise.Functor<Promise> map
- (function (_ fa')
- (case fa'
- (#error.Error error)
- (#error.Error error)
-
- (#error.Success a)
- (#error.Success (f a))))
- fa)))
-
-(structure: #export _ (Apply Task)
- (def: functor Functor<Task>)
-
- (def: (apply ff fa)
- (do promise.Monad<Promise>
- [ff' ff
- fa' fa]
- (wrap (do error.Monad<Error>
- [f ff'
- a fa']
- (wrap (f a)))))))
-
-(structure: #export _ (Monad Task)
- (def: functor Functor<Task>)
-
- (def: wrap return)
-
- (def: (join mma)
- (do promise.Monad<Promise>
- [mma' mma]
- (case mma'
- (#error.Error error)
- (wrap (#error.Error error))
-
- (#error.Success ma)
- ma))))
-
-(syntax: #export (task {type s.any})
- {#.doc (doc "Makes an uninitialized Task (in this example, of Any)."
- (task Any))}
- (wrap (list (` (: (..Task (~ type))
- (promise.promise #.None))))))
-
-(def: #export (from-promise promise)
- (All [a] (-> (Promise a) (Task a)))
- (:: promise.Functor<Promise> map (|>> #error.Success) promise))