@@ -29,7 +29,6 @@ module Control.Distributed.Process.Internal.Closure.CP
29import Data.Binary (encode)
29import Data.Binary (encode)
30import Data.ByteString.Lazy (ByteString)
30import Data.ByteString.Lazy (ByteString)
31import Data.Typeable (Typeable, typeOf, typeRepTyCon, TyCon)
31import Data.Typeable (Typeable, typeOf, typeRepTyCon, TyCon)
32−import Data.Typeable.Internal (TypeRep(..))
33import Control.Applicative ((<$>))
32import Control.Applicative ((<$>))
34import Control.Monad ((>=>))
33import Control.Monad ((>=>))
35import Control.Distributed.Process.Serializable (Serializable)
34import Control.Distributed.Process.Serializable (Serializable)
@@ -77,6 +76,7 @@ import Control.Distributed.Process.Internal.Dynamic
77 , dynTypeRep
76 , dynTypeRep
78 , dynKleisli
77 , dynKleisli
79+import Control.Distributed.Process.Internal.TypeRep (compareTypeRep)
81--------------------------------------------------------------------------------
81--------------------------------------------------------------------------------
82-- Setup: A number of functions that we will pass to 'remotable' --
82-- Setup: A number of functions that we will pass to 'remotable' --
@@ -123,18 +123,12 @@ unClosure (Static label) env = do
123 Nothing -> fail "Derived.unClosure: resolveClosure failed"
123 Nothing -> fail "Derived.unClosure: resolveClosure failed"
124 Just dyn -> return dyn
124 Just dyn -> return dyn
126−-- | Work around a bug in Typeable
127−-- (http://hackage.haskell.org/trac/ghc/ticket/5692)
128−compareWithoutFingerprint :: TypeRep -> TypeRep -> Bool
129−compareWithoutFingerprint (TypeRep _ con ts) (TypeRep _ con' ts')
130− = con == con' && all (uncurry compareWithoutFingerprint) (zip ts ts')
132-- | Remove a 'Dynamic' constructor, provided that the recorded type matches the
126-- | Remove a 'Dynamic' constructor, provided that the recorded type matches the
133-- type of the first static argument (the value of that argument is not used)
127-- type of the first static argument (the value of that argument is not used)
134unDynamic :: Static a -> Process Dynamic -> Process a
128unDynamic :: Static a -> Process Dynamic -> Process a
135unDynamic (Static label) pdyn = do
129unDynamic (Static label) pdyn = do
136 Dynamic typ val <- pdyn
130 Dynamic typ val <- pdyn
137− if compareWithoutFingerprint typ (typeOfStaticLabel label) -- typ == typeOfStaticLabel label
131+ if typ `compareTypeRep` typeOfStaticLabel label
138 then return (unsafeCoerce# val)
132 then return (unsafeCoerce# val)
139 else fail $ "unDynamic: cannot match "
133 else fail $ "unDynamic: cannot match "
140 ++ show typ
134 ++ show typ