Permalink
Browse files

Minor tweaks to RPC, but I think it needs to go back inside meta-par-…

…dist
  • Loading branch information...
1 parent 5193332 commit 8fe68c57849da90acd3af3754142fbdf00e138ba @rrnewton rrnewton committed Apr 23, 2012
Showing with 18 additions and 43 deletions.
  1. +5 −2 RPC/RPC.cabal
  2. +12 −39 RPC/RPC/Call.hs
  3. +1 −2 RPC/RPC/Encoding.hs
View
@@ -21,9 +21,12 @@ Cabal-version: >=1.8
Library
Exposed-modules:
RPC.Call
- , RPC.Closure
- , RPC.Encoding
+ , RPC.Closure
, RPC.Reg
+ , RPC.Encoding
+
+ Other-modules:
+
Build-depends: base >= 4 && < 5
, deepseq >= 1.2
View
@@ -28,25 +28,33 @@ import RPC.Reg (putReg,RemoteCallMetaData)
-- * Compile-time metadata
----------------------------------------------
+----------------------------------------------------------------------------------------------------
+-- RRN: For Meta-par, hacking the below versions to include a tuple of
+-- the original and the serialized closure:
+----------------------------------------------------------------------------------------------------
+
-- | A compile-time macro to expand a function name to its corresponding
-- closure name (if such a closure exists), suitable for use with
-- 'spawn', 'callRemote', etc
-- In general, using the syntax @$(mkClosure foo)@ is the same
-- as addressing the closure generator by name, that is,
-- @foo__closure@. In some cases you may need to use
-- 'mkClosureRec' instead.
-{-
mkClosure :: Name -> Q Exp
mkClosure n = do info <- reify n
case info of
- VarI iname _ _ _ ->
+ (VarI iname _ _ _) ->
do let newn = mkName $ show iname ++ "__closure"
+ arg = mkName "x"
newinfo <- reify newn
case newinfo of
- VarI newiname _ _ _ -> varE newiname
+ VarI newiname _ _ _ ->
+ -- Eta expand to apply to both:
+ lamE [return (VarP arg)]
+ (tupE [appE (varE n) (varE arg),
+ appE (varE newiname) (varE arg)])
_ -> error $ "Unexpected type of closure symbol for "++show n
_ -> error $ "No closure corresponding to "++show n
--}
-- | A variant of 'mkClosure' suitable for expanding closures
-- of functions declared in the same module, including that
@@ -57,41 +65,6 @@ mkClosure n = do info <- reify n
-- checks used by mkClosure, and therefore you are responsible
-- for making sure that you use 'remotable' with each function
-- that may be an argument of mkClosureRec
-{-
-mkClosureRec :: Name -> Q Exp
-mkClosureRec name =
- do e <- makeEnv
- inf <- reify name
- case inf of
- VarI aname atype _ _ ->
- case nameModule aname of
- Just a -> case a == loc_module (eLoc e) of
- False -> error "Can't use mkClosureRec across modules: use mkClosure instead"
- True -> do (aat,aae) <- closureInfo e aname atype
- sigE (return aae) (return aat)
- _ -> error "mkClosureRec can't figure out module of symbol"
- _ -> error "mkClosureRec applied to something weird"
--}
-
-----------------------------------------------------------------------------------------------------
--- RRN: Hacking the below versions to include a tuple of the original and the serialized closure.
-----------------------------------------------------------------------------------------------------
-mkClosure :: Name -> Q Exp
-mkClosure n = do info <- reify n
- case info of
- (VarI iname _ _ _) ->
- do let newn = mkName $ show iname ++ "__closure"
- arg = mkName "x"
- newinfo <- reify newn
- case newinfo of
- VarI newiname _ _ _ ->
- -- Eta expand to apply to both:
- lamE [return (VarP arg)]
- (tupE [appE (varE n) (varE arg),
- appE (varE newiname) (varE arg)])
- _ -> error $ "Unexpected type of closure symbol for "++show n
- _ -> error $ "No closure corresponding to "++show n
-
mkClosureRec :: Name -> Q Exp
mkClosureRec name =
do e <- makeEnv
View
@@ -3,8 +3,7 @@
-- | This module provides the 'Serializable' type class and functions
-- to convert to and from 'Payload's. It's implemented in terms of the
--- @cereal@ package's "Data.Serialize". The message sending and
--- receiving functionality in "RPC.Process" depends on this.
+-- @cereal@ package's "Data.Serialize".
module RPC.Encoding (
Serializable,
serialEncode,

0 comments on commit 8fe68c5

Please sign in to comment.