aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/concurrency
diff options
context:
space:
mode:
authorEduardo Julian2018-07-03 19:49:04 -0400
committerEduardo Julian2018-07-03 19:49:04 -0400
commitaac5a7796939cd705d955acb616cbff38474606d (patch)
tree567f60f65afb2a94299336a72ea105f00a16b63d /stdlib/source/lux/concurrency
parentd3f5e1f4baa667bc2eb72edd542cf5d8cd3924ce (diff)
- Re-named "@abstraction" to ":abstraction" and "@representation" to ":representation".
Diffstat (limited to 'stdlib/source/lux/concurrency')
-rw-r--r--stdlib/source/lux/concurrency/actor.lux12
-rw-r--r--stdlib/source/lux/concurrency/frp.lux6
-rw-r--r--stdlib/source/lux/concurrency/promise.lux12
-rw-r--r--stdlib/source/lux/concurrency/semaphore.lux16
-rw-r--r--stdlib/source/lux/concurrency/stm.lux12
5 files changed, 29 insertions, 29 deletions
diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux
index 77543ba78..ad3bccfdc 100644
--- a/stdlib/source/lux/concurrency/actor.lux
+++ b/stdlib/source/lux/concurrency/actor.lux
@@ -49,7 +49,7 @@
## TODO: Delete after new-luxc becomes the new standard compiler.
(def: (actor mailbox obituary)
(All [s] (-> (Atom <Mailbox>) (Promise <Obituary>) (Actor s)))
- (@abstraction {#mailbox mailbox
+ (:abstraction {#mailbox mailbox
#obituary obituary}))
(type: #export (Message s)
@@ -70,7 +70,7 @@
self (actor (atom (promise #.None))
(promise #.None))
process (loop [state init
- |mailbox| (io.run (atom.read (get@ #mailbox (@representation self))))]
+ |mailbox| (io.run (atom.read (get@ #mailbox (:representation self))))]
(do promise.Monad<Promise>
[[head tail] |mailbox|
?state' (handle head state self)]
@@ -79,7 +79,7 @@
(do @
[_ (end error state)]
(exec (io.run (promise.resolve [error state (#.Cons head (obituary tail))]
- (get@ #obituary (@representation self))))
+ (get@ #obituary (:representation self))))
(wrap [])))
(#e.Success state')
@@ -88,7 +88,7 @@
(def: #export (alive? actor)
(All [s] (-> (Actor s) Bool))
- (case (promise.poll (get@ #obituary (@representation actor)))
+ (case (promise.poll (get@ #obituary (:representation actor)))
#.None
true
@@ -101,7 +101,7 @@
(if (alive? actor)
(let [entry [message (promise #.None)]]
(do Monad<IO>
- [|mailbox| (atom.read (get@ #mailbox (@representation actor)))]
+ [|mailbox| (atom.read (get@ #mailbox (:representation actor)))]
(loop [|mailbox| |mailbox|]
(case (promise.poll |mailbox|)
#.None
@@ -109,7 +109,7 @@
[resolved? (promise.resolve entry |mailbox|)]
(if resolved?
(do @
- [_ (atom.write (product.right entry) (get@ #mailbox (@representation actor)))]
+ [_ (atom.write (product.right entry) (get@ #mailbox (:representation actor)))]
(wrap true))
(recur |mailbox|)))
diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux
index 28d7be094..7b4bfbec0 100644
--- a/stdlib/source/lux/concurrency/frp.lux
+++ b/stdlib/source/lux/concurrency/frp.lux
@@ -16,16 +16,16 @@
(def: #export (channel _)
(All [a] (-> Any (Channel a)))
- (@abstraction (atom (list))))
+ (:abstraction (atom (list))))
- (def: #export (listen listener (^@representation channel))
+ (def: #export (listen listener (^:representation channel))
(All [a] (-> (-> a (IO Any)) (Channel a) (IO Any)))
## TODO: Simplify when possible.
(do io.Monad<IO>
[_ (atom.update (|>> (#.Cons listener)) channel)]
(wrap [])))
- (def: #export (publish (^@representation channel) value)
+ (def: #export (publish (^:representation channel) value)
{#.doc "Publish to a channel."}
(All [a] (-> (Channel a) a (IO Any)))
(do io.Monad<IO>
diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux
index 3ccdc22e9..866cdd8da 100644
--- a/stdlib/source/lux/concurrency/promise.lux
+++ b/stdlib/source/lux/concurrency/promise.lux
@@ -19,16 +19,16 @@
(def: #export (promise ?value)
(All [a] (-> (Maybe a) (Promise a)))
- (@abstraction (atom [?value (list)])))
+ (:abstraction (atom [?value (list)])))
- (def: #export (poll (^@representation promise))
+ (def: #export (poll (^:representation promise))
{#.doc "Polls a promise's value."}
(All [a] (-> (Promise a) (Maybe a)))
(|> (atom.read promise)
io.run
product.left))
- (def: #export (resolve value (^@representation promise))
+ (def: #export (resolve value (^:representation promise))
{#.doc "Sets an promise's value if it has not been done yet."}
(All [a] (-> a (Promise a) (IO Bool)))
(do io.Monad<IO>
@@ -46,9 +46,9 @@
[_ (monad.map @ (function (_ f) (f value))
_observers)]
(wrap true))
- (resolve value (@abstraction promise)))))))
+ (resolve value (:abstraction promise)))))))
- (def: #export (await f (^@representation promise))
+ (def: #export (await f (^:representation promise))
(All [a] (-> (-> a (IO Any)) (Promise a) Any))
(let [(^@ old [_value _observers]) (io.run (atom.read promise))]
(case _value
@@ -59,7 +59,7 @@
(let [new [_value (#.Cons f _observers)]]
(if (io.run (atom.compare-and-swap old new promise))
[]
- (await f (@abstraction promise)))))))
+ (await f (:abstraction promise)))))))
)
(def: #export (resolved? promise)
diff --git a/stdlib/source/lux/concurrency/semaphore.lux b/stdlib/source/lux/concurrency/semaphore.lux
index 23303a236..fa312fcc8 100644
--- a/stdlib/source/lux/concurrency/semaphore.lux
+++ b/stdlib/source/lux/concurrency/semaphore.lux
@@ -18,12 +18,12 @@
(def: #export (semaphore init-open-positions)
(-> Nat Semaphore)
- (@abstraction (atom.atom {#open-positions init-open-positions
+ (:abstraction (atom.atom {#open-positions init-open-positions
#waiting-list (list)})))
(def: #export (wait semaphore)
(Ex [k] (-> Semaphore (Promise Any)))
- (let [semaphore (@representation semaphore)]
+ (let [semaphore (:representation semaphore)]
(io.run
(loop [signal (: (Promise Any)
(promise.promise #.None))]
@@ -45,7 +45,7 @@
(def: #export (signal semaphore)
(Ex [k] (-> Semaphore (Promise Any)))
- (let [semaphore (@representation semaphore)]
+ (let [semaphore (:representation semaphore)]
(promise.future
(loop [_ []]
(do io.Monad<IO>
@@ -77,15 +77,15 @@
(def: #export (mutex _)
(-> Any Mutex)
- (@abstraction (semaphore +1)))
+ (:abstraction (semaphore +1)))
(def: (acquire mutex)
(-> Mutex (Promise Any))
- (wait (@representation mutex)))
+ (wait (:representation mutex)))
(def: (release mutex)
(-> Mutex (Promise Any))
- (signal (@representation mutex)))
+ (signal (:representation mutex)))
(def: #export (synchronize mutex procedure)
(All [a] (-> Mutex (IO (Promise a)) (Promise a)))
@@ -109,7 +109,7 @@
(def: #export (barrier limit)
(-> Limit Barrier)
- (@abstraction {#limit limit
+ (:abstraction {#limit limit
#count (atom.atom +0)
#start-turnstile (semaphore +0)
#end-turnstile (semaphore +0)}))
@@ -124,7 +124,7 @@
(:: promise.Monad<Promise> wrap []))))
(do-template [<phase> <update> <goal> <turnstile>]
- [(def: (<phase> (^@representation barrier))
+ [(def: (<phase> (^:representation barrier))
(-> Barrier (Promise Any))
(do promise.Monad<Promise>
[#let [limit (refinement.un-refine (get@ #limit barrier))
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux
index 5c9e2d68c..9fef9f59e 100644
--- a/stdlib/source/lux/concurrency/stm.lux
+++ b/stdlib/source/lux/concurrency/stm.lux
@@ -20,20 +20,20 @@
(def: #export (var value)
{#.doc "Creates a new STM var, with a default value."}
(All [a] (-> a (Var a)))
- (@abstraction (atom.atom [value (list)])))
+ (:abstraction (atom.atom [value (list)])))
(def: read!!
(All [a] (-> (Var a) a))
- (|>> @representation atom.read io.run product.left))
+ (|>> :representation atom.read io.run product.left))
- (def: #export (read! (^@representation var))
+ (def: #export (read! (^:representation var))
{#.doc "Reads var immediately, without going through a transaction."}
(All [a] (-> (Var a) (IO a)))
(|> var
atom.read
(:: io.Functor<IO> map product.left)))
- (def: (write! new-value (^@representation var))
+ (def: (write! new-value (^:representation var))
(All [a] (-> a (Var a) (IO Any)))
(do io.Monad<IO>
[(^@ old [_value _observers]) (atom.read var)
@@ -42,7 +42,7 @@
(do @
[_ (monad.map @ (function (_ f) (f new-value)) _observers)]
(wrap []))
- (write! new-value (@abstraction var)))))
+ (write! new-value (:abstraction var)))))
## TODO: Remove when possible
(def: (helper|follow var)
@@ -53,7 +53,7 @@
(All [a] (-> (Var a) (IO (frp.Channel a))))
(do io.Monad<IO>
[#let [channel (helper|follow target)
- target (@representation target)]
+ target (:representation target)]
_ (atom.update (function (_ [value observers])
[value (#.Cons (frp.publish channel) observers)])
target)]