lux/concurrency/stm
Types
STM
A computation which updates a transaction and produces a value.
(type: (STM a)
(-> Tx [Tx a]))
Var
A mutable cell containing a value, and observers that will be alerted of any change to it.
(type: (Var a)
(lux/concurrency/atom;Atom (Var-State a)))
Structs
Applicative<STM>
(lux/control/applicative;Applicative STM)
Functor<STM>
(lux/control/functor;Functor STM)
Monad<STM>
(lux/control/monad;Monad STM)
Values
(commit stm-proc)
Commits a transaction and returns its result (asynchronously).
Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first.
For this reason, it's important to note that transactions must be free from side-effects, such as I/O.
(All [a] (-> (STM a) (lux/concurrency/promise;Promise a)))
(follow label target)
Creates a channel (identified by a label) that will receive all changes to the value of the given var.
(All [a] (-> lux;Text (Var a) (lux/codata/io;IO (lux/concurrency/frp;Chan a))))
(read var)
(All [a] (-> (Var a) (STM a)))
(read! var)
Reads var immediately, without going through a transaction.
(All [a] (-> (Var a) (lux/codata/io;IO a)))
(unfollow label target)
Stop tracking the changes to a Var.
Caveat emptor: It won't close any Chan that used to track the changes.
(All [a] (-> lux;Text (Var a) (lux/codata/io;IO lux;Unit)))
(update f var)
Will update a Var's value, and return a tuple with the old and the new values.
(All [a] (-> (-> a a) (Var a) (STM [a a])))
(update! f var)
Will update a Var's value, and return a tuple with the old and the new values.
(All [a] (-> (-> a a) (Var a) (lux/codata/io;IO [a a])))
(var value)
Creates a new STM var, with a default value.
(All [a] (-> a (Var a)))
(write value var)
(All [a] (-> a (Var a) (STM lux;Unit)))
(write! new-value var)
Writes value to var immediately, without going through a transaction.
(All [a] (-> a (Var a) (lux/codata/io;IO lux;Unit)))