aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/concurrency/stm.lux
diff options
context:
space:
mode:
authorEduardo Julian2017-12-04 19:46:36 -0400
committerEduardo Julian2017-12-04 19:46:36 -0400
commit077e8286b1168909d702ae0c28a0d2941c956f15 (patch)
tree29b18553df8fac35ecb377813b66b67a8bdebddd /stdlib/source/lux/concurrency/stm.lux
parent0b946aa762f777682c53c6171b4797f8869204bb (diff)
- No longer deleting type-vars in luxc, to better match it with the type-checking in new-luxc.
- Fixed some minor bugs and inconsistencies.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/concurrency/stm.lux26
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)))