@@ -44,13 +44,18 @@ module Control.Distributed.Process.Closure
4444 remotable
4545 , mkClosure
4646 -- * Closure combinators
47+ , applyClosure
48+ , liftedBind
49+ , liftedConst
4750 , bindCP
51+ , weakenCP
52+ , seqCP
4853 ) where
4954
5055import Prelude hiding (lookup)
5156import Data.ByteString.Lazy (ByteString)
5257import Data.Binary (encode, decode)
53−import Data.Typeable (typeOf, TypeRep, Typeable)
58+import Data.Typeable (typeOf, Typeable)
5459import Control.Applicative ((<$>))
5560import Language.Haskell.TH
5661 ( -- Q monad and operations
@@ -119,13 +124,25 @@ liftedBind :: forall a b. (Typeable a, Typeable b)
119124 => Closure (Process a -> (a -> Process b) -> Process b)
120125liftedBind = Closure (Static "$liftedBind") (encode typ)
121126 where
122− typ :: TypeRep
123127 typ = typeOf (undefined :: Process a -> (a -> Process b) -> Process b)
124128
129+liftedConst :: forall a b. (Typeable a, Typeable b)
130+ => Closure (a -> b -> a)
131+liftedConst = Closure (Static "$liftedConst") (encode typ)
132+ where
133+ typ = typeOf (undefined :: a -> b -> a)
134+
125135bindCP :: (Typeable a, Typeable b)
126136 => Closure (Process a) -> Closure (a -> Process b) -> Closure (Process b)
127137bindCP x f = liftedBind `applyClosure` x `applyClosure` f
128138
139+weakenCP :: (Typeable a, Typeable b)
140+ => Closure (Process b) -> Closure (a -> Process b)
141+weakenCP = applyClosure liftedConst
142+
143+seqCP :: Closure (Process ()) -> Closure (Process ()) -> Closure (Process ())
144+seqCP p q = bindCP p (weakenCP q)
145+
129146--------------------------------------------------------------------------------
130147-- Internal (Template Haskell) --
131148--------------------------------------------------------------------------------