diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/concurrency/stm.lux | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index cc39ae0c3..0fe9ee9df 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -57,7 +57,8 @@ (:! (Var Unit) _var)))) (:: Monad<Maybe> map (function [[_var _original _current]] _current)) - (:! (Maybe ($ +0))))) + (:!!) + )) (def: #export (read var) (All [a] (-> (Var a) (STM a))) @@ -85,13 +86,15 @@ #.Nil (#.Cons [_var _original _current] tx') - (if (is (:! (Var ($ +0)) var) - (:! (Var ($ +0)) _var)) - (#.Cons [(:! (Var ($ +0)) _var) - (:! ($ +0) _original) - (:! ($ +0) value)] + (if (is (:! (Var Unit) var) + (:! (Var Unit) _var)) + (#.Cons {#var (:! (Var Unit) _var) + #original (:! Unit _original) + #current (:! Unit value)} tx') - (#.Cons [_var _original _current] + (#.Cons {#var _var + #original _original + #current _current} (update-tx-value var value tx'))) )) @@ -127,7 +130,8 @@ (def: #export (follow target) {#.doc "Creates a channel that will receive all changes to the value of the given var."} (All [a] (-> (Var a) (IO (frp.Channel a)))) - (let [head (frp.channel ($ +0)) + (let [head (: (frp.Channel ($ +0)) (frp.channel)) + ## head (frp.channel) channel-var (var head) observer (function [label value] (case (io.run (|> channel-var raw-read (frp.write value))) @@ -247,10 +251,10 @@ (:! (frp.Channel [(STM Unit) (P.Promise Unit)])) (P.await (function recur [?inputs] (io (case ?inputs - #.Nil + #.None [] - (#.Cons head tail) + (#.Some [head tail]) (exec (process-commit head) (P.await recur tail))))))) (wrap []))) @@ -264,7 +268,7 @@ For this reason, it's important to note that transactions must be free from side-effects, such as I/O."} (All [a] (-> (STM a) (P.Promise a))) - (let [output (: (P.Promise ($ +0)) (P.promise #.None))] + (let [output (P.promise #.None)] (exec (io.run init-processor!) (io.run (write! [stm-proc output] pending-commits)) output))) |