git.iko.soy/distributed-process
on master help sign in
Merge pull request #168 from tweag/closure-closure
8ec85d0Tim Watson
src/Control/Distributed/Process/Internal/Closure/BuiltIn.hs+13−5
@@ -52,6 +52,7 @@ import Control.Distributed.Static
52import Control.Distributed.Process.Serializable
52import Control.Distributed.Process.Serializable
53 ( SerializableDict(..)
53 ( SerializableDict(..)
54 , Serializable
54 , Serializable
55+ , TypeableDict(..)
55 )
56 )
56import Control.Distributed.Process.Internal.Types
57import Control.Distributed.Process.Internal.Types
57 ( Process
58 ( Process
@@ -84,7 +85,8 @@ remoteTable =
84 . registerStatic "$sdictUnit" (toDynamic (SerializableDict :: SerializableDict ()))
85 . registerStatic "$sdictUnit" (toDynamic (SerializableDict :: SerializableDict ()))
85 . registerStatic "$sdictProcessId" (toDynamic (SerializableDict :: SerializableDict ProcessId))
86 . registerStatic "$sdictProcessId" (toDynamic (SerializableDict :: SerializableDict ProcessId))
86 . registerStatic "$sdictSendPort_" (toDynamic (sdictSendPort_ :: SerializableDict ANY -> SerializableDict (SendPort ANY)))
87 . registerStatic "$sdictSendPort_" (toDynamic (sdictSendPort_ :: SerializableDict ANY -> SerializableDict (SendPort ANY)))
88+ . registerStatic "$sdictStatic" (toDynamic (sdictStatic_ :: TypeableDict ANY -> SerializableDict (Static ANY)))
87− . registerStatic "$sdictClosure" (toDynamic (SerializableDict :: SerializableDict (Closure ANY)))
89+ . registerStatic "$sdictClosure" (toDynamic (sdictClosure_ :: TypeableDict ANY -> SerializableDict (Closure ANY)))
88 . registerStatic "$returnProcess" (toDynamic (return :: ANY -> Process ANY))
90 . registerStatic "$returnProcess" (toDynamic (return :: ANY -> Process ANY))
89 . registerStatic "$seqProcess" (toDynamic ((>>) :: Process ANY1 -> Process ANY2 -> Process ANY2))
91 . registerStatic "$seqProcess" (toDynamic ((>>) :: Process ANY1 -> Process ANY2 -> Process ANY2))
90 . registerStatic "$bindProcess" (toDynamic ((>>=) :: Process ANY1 -> (ANY1 -> Process ANY2) -> Process ANY2))
92 . registerStatic "$bindProcess" (toDynamic ((>>=) :: Process ANY1 -> (ANY1 -> Process ANY2) -> Process ANY2))
@@ -105,6 +107,12 @@ remoteTable =
105 sdictSendPort_ :: forall a. SerializableDict a -> SerializableDict (SendPort a)
107 sdictSendPort_ :: forall a. SerializableDict a -> SerializableDict (SendPort a)
106 sdictSendPort_ SerializableDict = SerializableDict
108 sdictSendPort_ SerializableDict = SerializableDict
107
109
110+ sdictStatic_ :: forall a. TypeableDict a -> SerializableDict (Static a)
111+ sdictStatic_ TypeableDict = SerializableDict
112+
113+ sdictClosure_ :: forall a. TypeableDict a -> SerializableDict (Closure a)
114+ sdictClosure_ TypeableDict = SerializableDict
115+
108 sendDict :: forall a. SerializableDict a -> ProcessId -> a -> Process ()
116 sendDict :: forall a. SerializableDict a -> ProcessId -> a -> Process ()
109 sendDict SerializableDict = send
117 sendDict SerializableDict = send
110
118
@@ -148,12 +156,12 @@ sdictSendPort :: Typeable a
148sdictSendPort = staticApply (staticLabel "$sdictSendPort_")
156sdictSendPort = staticApply (staticLabel "$sdictSendPort_")
149
157
150-- | Serialization dictionary for 'Static'.
158-- | Serialization dictionary for 'Static'.
151−sdictStatic :: Typeable a => Static (SerializableDict (Static a))
159+sdictStatic :: Typeable a => Static (TypeableDict a) -> Static (SerializableDict (Static a))
152−sdictStatic = staticLabel "$sdictStatic"
160+sdictStatic = staticApply (staticLabel "$sdictStatic")
153
161
154-- | Serialization dictionary for 'Closure'.
162-- | Serialization dictionary for 'Closure'.
155−sdictClosure :: Typeable a => Static (SerializableDict (Closure a))
163+sdictClosure :: Typeable a => Static (TypeableDict a) -> Static (SerializableDict (Closure a))
156−sdictClosure = staticLabel "$sdictClosure"
164+sdictClosure = staticApply (staticLabel "$sdictClosure")
157
165
158--------------------------------------------------------------------------------
166--------------------------------------------------------------------------------
159-- Static values --
167-- Static values --
src/Control/Distributed/Process/Serializable.hs+6
@@ -12,6 +12,7 @@ module Control.Distributed.Process.Serializable
12 , Fingerprint
12 , Fingerprint
13 , showFingerprint
13 , showFingerprint
14 , SerializableDict(SerializableDict)
14 , SerializableDict(SerializableDict)
15+ , TypeableDict(TypeableDict)
15 ) where
16 ) where
16
17
17import Data.Binary (Binary)
18import Data.Binary (Binary)
@@ -41,6 +42,11 @@ data SerializableDict a where
41 SerializableDict :: Serializable a => SerializableDict a
42 SerializableDict :: Serializable a => SerializableDict a
42 deriving (Typeable)
43 deriving (Typeable)
43
44
45+-- | Reification of 'Typeable'.
46+data TypeableDict a where
47+ TypeableDict :: Typeable a => TypeableDict a
48+ deriving (Typeable)
49+
44-- | Objects that can be sent across the network
50-- | Objects that can be sent across the network
45class (Binary a, Typeable a) => Serializable a
51class (Binary a, Typeable a) => Serializable a
46instance (Binary a, Typeable a) => Serializable a
52instance (Binary a, Typeable a) => Serializable a