@@ -1,5 +1,5 @@
11-- | Template Haskell support
2−{-# LANGUAGE TemplateHaskell #-}
2+{-# LANGUAGE TemplateHaskell, CPP #-}
33module Control.Distributed.Process.Internal.Closure.TH
44 ( -- * User-level API
55 remotable
@@ -29,7 +29,11 @@ import Language.Haskell.TH
2929 , Type(AppT, ForallT, VarT, ArrowT)
3030 , Info(VarI)
3131 , TyVarBndr(PlainTV, KindedTV)
32− , Pred(ClassP)
32+#if ! MIN_VERSION_template_haskell(2,10,0)
33+ , Pred
34+#endif
35+ , varT
36+ , classP
3337 -- Lifted constructors
3438 -- .. Literals
3539 , stringL
@@ -67,6 +71,10 @@ import Control.Distributed.Process.Serializable
6771 )
6872import Control.Distributed.Process.Internal.Closure.BuiltIn (staticDecode)
6973
74+#if MIN_VERSION_template_haskell(2,10,0)
75+type Pred = Type
76+#endif
77+
7078--------------------------------------------------------------------------------
7179-- User-level API --
7280--------------------------------------------------------------------------------
@@ -244,16 +252,16 @@ generateStatic :: Name -> [TyVarBndr] -> Type -> Q [Dec]
244252generateStatic n xs typ = do
245253 staticTyp <- [t| Static |]
246254 sequence
247− [ sigD (staticName n) $
255+ [ sigD (staticName n) $ do
256+ txs <- sequence $ map typeable xs
248257 return (ForallT xs
249− (map typeable xs)
250− (staticTyp `AppT` typ)
251− )
258+ txs
259+ (staticTyp `AppT` typ))
252260 , sfnD (staticName n) [| staticLabel $(showFQN n) |]
253261 ]
254262 where
255− typeable :: TyVarBndr -> Pred
256− typeable tv = ClassP (mkName "Typeable") [VarT (tyVarBndrName tv)]
263+ typeable :: TyVarBndr -> Q Pred
264+ typeable tv = classP (mkName "Typeable") [varT (tyVarBndrName tv)]
257265
258266-- | Generate a serialization dictionary with name 'n' for type 'typ'
259267generateDict :: Name -> Type -> Q [Dec]