git.iko.soy/distributed-process
on master help sign in
add mkStaticClosure :: Name -> Q Exp
6e6ac63Simon Marlow
distributed-process/src/Control/Distributed/Process/Closure.hs+2
@@ -182,6 +182,7 @@ module Control.Distributed.Process.Closure
182 , remotableDecl
182 , remotableDecl
183 , mkStatic
183 , mkStatic
184 , mkClosure
184 , mkClosure
185+ , mkStaticClosure
185 , functionSDict
186 , functionSDict
186 , functionTDict
187 , functionTDict
187#endif
188#endif
@@ -216,5 +217,6 @@ import Control.Distributed.Process.Internal.Closure.TH
216 , functionSDict
217 , functionSDict
217 , functionTDict
218 , functionTDict
218 , mkClosure
219 , mkClosure
220+ , mkStaticClosure
219 )
221 )
220#endif
222#endif
distributed-process/src/Control/Distributed/Process/Internal/Closure/TH.hs+9
@@ -8,6 +8,7 @@ module Control.Distributed.Process.Internal.Closure.TH
8 , functionSDict
8 , functionSDict
9 , functionTDict
9 , functionTDict
10 , mkClosure
10 , mkClosure
11+ , mkStaticClosure
11 ) where
12 ) where
12
13
13import Prelude hiding (succ, any)
14import Prelude hiding (succ, any)
@@ -58,6 +59,7 @@ import Control.Distributed.Static
58 , staticLabel
59 , staticLabel
59 , closure
60 , closure
60 , staticCompose
61 , staticCompose
62+ , staticClosure
61 )
63 )
62import Control.Distributed.Process.Internal.Types (Process)
64import Control.Distributed.Process.Internal.Types (Process)
63import Control.Distributed.Process.Serializable
65import Control.Distributed.Process.Serializable
@@ -146,6 +148,13 @@ mkClosure n =
146 . encode
148 . encode
147 |]
149 |]
148
150
151+-- | Make a 'Closure' from a static function. This is useful for
152+-- making a closure for a top-level @Process ()@ function, because
153+-- using 'mkClosure' would require adding a dummy @()@ argument.
154+--
155+mkStaticClosure :: Name -> Q Exp
156+mkStaticClosure n = [| staticClosure $( mkStatic n ) |]
157+
149--------------------------------------------------------------------------------
158--------------------------------------------------------------------------------
150-- Internal (Template Haskell) --
159-- Internal (Template Haskell) --
151--------------------------------------------------------------------------------
160--------------------------------------------------------------------------------