aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/control/concurrency/frp.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/control/concurrency/frp.lux17
1 files changed, 13 insertions, 4 deletions
diff --git a/stdlib/source/lux/control/concurrency/frp.lux b/stdlib/source/lux/control/concurrency/frp.lux
index 50c26e769..fdec66a61 100644
--- a/stdlib/source/lux/control/concurrency/frp.lux
+++ b/stdlib/source/lux/control/concurrency/frp.lux
@@ -110,7 +110,9 @@
_
(wrap #.None)))))
-(def: empty Channel (promise.resolved #.None))
+(def: empty
+ Channel
+ (promise.resolved #.None))
(structure: #export monad
(Monad Channel)
@@ -145,15 +147,22 @@
(wrap (: Any (io.run (:: sink close))))))))
output))))
-(def: #export (listen listener channel)
- (All [a] (-> (-> a (IO Any)) (Channel a) (IO Any)))
+(type: #export (Subscriber a)
+ (-> a (IO (Maybe Any))))
+
+(def: #export (subscribe subscriber channel)
+ (All [a] (-> (Subscriber a) (Channel a) (IO Any)))
(io (exec (: (Promise Any)
(loop [channel channel]
(do promise.monad
[cons channel]
(case cons
(#.Some [head tail])
- (exec (io.run (listener head))
+ (case (io.run (subscriber head))
+ (#.Some _)
+ (recur tail)
+
+ #.None
(recur tail))
#.None