@@ -44,13 +44,18 @@ module Control.Distributed.Process.Closure
45 , mkClosure
45 , mkClosure
46 -- * Closure combinators
46 -- * Closure combinators
50import Prelude hiding (lookup)
55import Prelude hiding (lookup)
51import Data.ByteString.Lazy (ByteString)
56import Data.ByteString.Lazy (ByteString)
52import Data.Binary (encode, decode)
57import Data.Binary (encode, decode)
53−import Data.Typeable (typeOf, TypeRep, Typeable)
58+import Data.Typeable (typeOf, Typeable)
54import Control.Applicative ((<$>))
59import Control.Applicative ((<$>))
55import Language.Haskell.TH
60import Language.Haskell.TH
56 ( -- Q monad and operations
61 ( -- Q monad and operations
@@ -119,13 +124,25 @@ liftedBind :: forall a b. (Typeable a, Typeable b)
119 => Closure (Process a -> (a -> Process b) -> Process b)
124 => Closure (Process a -> (a -> Process b) -> Process b)
120liftedBind = Closure (Static "$liftedBind") (encode typ)
125liftedBind = Closure (Static "$liftedBind") (encode typ)
123 typ = typeOf (undefined :: Process a -> (a -> Process b) -> Process b)
127 typ = typeOf (undefined :: Process a -> (a -> Process b) -> Process b)
129+liftedConst :: forall a b. (Typeable a, Typeable b)
130+ => Closure (a -> b -> a)
131+liftedConst = Closure (Static "$liftedConst") (encode typ)
133+ typ = typeOf (undefined :: a -> b -> a)
125bindCP :: (Typeable a, Typeable b)
135bindCP :: (Typeable a, Typeable b)
126 => Closure (Process a) -> Closure (a -> Process b) -> Closure (Process b)
136 => Closure (Process a) -> Closure (a -> Process b) -> Closure (Process b)
127bindCP x f = liftedBind `applyClosure` x `applyClosure` f
137bindCP x f = liftedBind `applyClosure` x `applyClosure` f
139+weakenCP :: (Typeable a, Typeable b)
140+ => Closure (Process b) -> Closure (a -> Process b)
141+weakenCP = applyClosure liftedConst
143+seqCP :: Closure (Process ()) -> Closure (Process ()) -> Closure (Process ())
144+seqCP p q = bindCP p (weakenCP q)
129--------------------------------------------------------------------------------
146--------------------------------------------------------------------------------
130-- Internal (Template Haskell) --
147-- Internal (Template Haskell) --
131--------------------------------------------------------------------------------
148--------------------------------------------------------------------------------