git.iko.soy/distributed-process
on master help sign in
add mkStaticClosure :: Name -> Q Exp
commit6e6ac63cf2cefb9f28eac7281bef758c1c5ad0cc authorSimon Marlow <marlowsd@gmail.com> dateMon 3 Dec 2012, 16:10 (14 years ago) parent5669b49
2 files changed+11
distributed-process/src/Control/Distributed/Process/Closure.hs+2 distributed-process/src/Control/Distributed/Process/Internal/Closure/TH.hs+9
distributed-process/src/Control/Distributed/Process/Closure.hs+2
@@ -182,6 +182,7 @@ module Control.Distributed.Process.Closure
182182 , remotableDecl
183183 , mkStatic
184184 , mkClosure
185+ , mkStaticClosure
185186 , functionSDict
186187 , functionTDict
187188#endif
@@ -216,5 +217,6 @@ import Control.Distributed.Process.Internal.Closure.TH
216217 , functionSDict
217218 , functionTDict
218219 , mkClosure
220+ , mkStaticClosure
219221 )
220222#endif
distributed-process/src/Control/Distributed/Process/Internal/Closure/TH.hs+9
@@ -8,6 +8,7 @@ module Control.Distributed.Process.Internal.Closure.TH
88 , functionSDict
99 , functionTDict
1010 , mkClosure
11+ , mkStaticClosure
1112 ) where
1213
1314import Prelude hiding (succ, any)
@@ -58,6 +59,7 @@ import Control.Distributed.Static
5859 , staticLabel
5960 , closure
6061 , staticCompose
62+ , staticClosure
6163 )
6264import Control.Distributed.Process.Internal.Types (Process)
6365import Control.Distributed.Process.Serializable
@@ -146,6 +148,13 @@ mkClosure n =
146148 . encode
147149 |]
148150
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+
149158--------------------------------------------------------------------------------
150159-- Internal (Template Haskell) --
151160--------------------------------------------------------------------------------