git.iko.soy/distributed-process
on master help sign in
Closure version of newChan
commit1b74f5480ae366bd25bdb985241a2dcf61104fbc authorEdsko de Vries <edsko@edsko.net> dateWed 11 Jul 2012, 17:45 (14 years ago) parente2a09fb
2 files changed+16
distributed-process/src/Control/Distributed/Process/Closure.hs+2 distributed-process/src/Control/Distributed/Process/Internal/Closure/CP.hs+14
distributed-process/src/Control/Distributed/Process/Closure.hs+2
@@ -108,6 +108,7 @@ module Control.Distributed.Process.Closure
108108 , cpUnlink
109109 , cpSend
110110 , cpExpect
111+ , cpNewChan
111112 -- * @Closure (Process a)@ as a not-quite-monad
112113 , cpReturn
113114 , cpBind
@@ -154,6 +155,7 @@ import Control.Distributed.Process.Internal.Closure.CP
154155 , cpUnlink
155156 , cpSend
156157 , cpExpect
158+ , cpNewChan
157159 -- @Closure (Process a)@ as a not-quite-monad
158160 , cpReturn
159161 , cpBind
distributed-process/src/Control/Distributed/Process/Internal/Closure/CP.hs+14
@@ -6,6 +6,7 @@ module Control.Distributed.Process.Internal.Closure.CP
66 , cpUnlink
77 , cpSend
88 , cpExpect
9+ , cpNewChan
910 -- * @Closure (Process a)@ as a not-quite-monad
1011 , cpReturn
1112 , cpBind
@@ -32,12 +33,15 @@ import Control.Distributed.Process.Internal.Types
3233 , ProcessId
3334 , LocalNode(remoteTable)
3435 , procMsg
36+ , SendPort
37+ , ReceivePort
3538 )
3639import Control.Distributed.Process.Internal.Primitives
3740 ( link
3841 , unlink
3942 , send
4043 , expect
44+ , newChan
4145 )
4246import Control.Distributed.Process.Internal.Closure.TH (remotable, mkStatic)
4347import Control.Distributed.Process.Internal.MessageT (getLocalNode)
@@ -83,6 +87,9 @@ sendDict SerializableDict = send
8387expectDict :: SerializableDict a -> Process a
8488expectDict SerializableDict = expect
8589
90+newChanDict :: SerializableDict a -> Process (SendPort a, ReceivePort a)
91+newChanDict SerializableDict = newChan
92+
8693---- Serialization dictionaries ------------------------------------------------
8794
8895-- | Specialized serialization dictionary required in 'cpBind'
@@ -141,6 +148,7 @@ remotable [ -- Monadic operations
141148 -- Explicit dictionaries
142149 , 'sendDict
143150 , 'expectDict
151+ , 'newChanDict
144152 -- Serialization dictionaries
145153 , 'sdictBind
146154 -- Specialized processes
@@ -175,6 +183,12 @@ cpSend dict pid = Closure decoder (encode pid)
175183cpExpect :: Typeable a => Static (SerializableDict a) -> Closure (Process a)
176184cpExpect dict = staticClosure ($(mkStatic 'expectDict) `staticApply` dict)
177185
186+-- | Closure version of 'newChan'
187+cpNewChan :: Typeable a
188+ => Static (SerializableDict a)
189+ -> Closure (Process (SendPort a, ReceivePort a))
190+cpNewChan dict = staticClosure ($(mkStatic 'newChanDict) `staticApply` dict)
191+
178192--------------------------------------------------------------------------------
179193-- (Closure . Process) as a not-quite-monad --
180194--------------------------------------------------------------------------------