git.iko.soy/distributed-process
on master help sign in
Merge pull request #189 from tweag/ghc-7.10

Add compatibility with ghc-7.10

commit3606f3d8a7891b4d6e1bdc32837c4844e5cfa3b8 authorAlexander Vershilov <alexander.vershilov@gmail.com> dateTue 2 Jun 2015, 23:54 (11 years ago) parent337db67785543e
6 files changed+71−22
distributed-process.cabal+16−7 src/Control/Distributed/Process/Internal/Closure/TH.hs+16−8 src/Control/Distributed/Process/Internal/Primitives.hs+4 src/Control/Distributed/Process/Internal/Types.hs+27−7 src/Control/Distributed/Process/Management/Internal/Trace/Tracer.hs+4 src/Control/Distributed/Process/Serializable.hs+4
distributed-process.cabal+16−7
@@ -38,6 +38,13 @@ flag prof
3838 description: Compiling with profiling enabled
3939 default: False
4040
41+
42+flag old-locale
43+ description: If false then depend on time >= 1.5.
44+ .
45+ If true then depend on time < 1.5 together with old-locale.
46+ default: False
47+
4148Library
4249 Build-Depends: base >= 4.4 && < 5,
4350 binary >= 0.6.3 && < 0.8,
@@ -45,15 +52,13 @@ Library
4552 network-transport >= 0.4.1.0 && < 0.5,
4653 stm >= 2.4 && < 2.5,
4754 transformers >= 0.2 && < 0.5,
48− mtl >= 2.0 && < 2.3,
55+ mtl >= 2.0 && < 2.4,
4956 data-accessor >= 0.2 && < 0.3,
5057 bytestring >= 0.9 && < 0.11,
51− old-locale >= 1.0 && < 1.1,
52− time >= 1.2 && < 1.5,
5358 random >= 1.0 && < 1.2,
54− ghc-prim >= 0.2 && < 0.4,
59+ ghc-prim >= 0.2 && < 0.5,
5560 distributed-static >= 0.2 && < 0.4,
56− rank1dynamic >= 0.1 && < 0.3,
61+ rank1dynamic >= 0.1 && < 0.4,
5762 syb >= 0.3 && < 0.5
5863 Exposed-modules: Control.Distributed.Process,
5964 Control.Distributed.Process.Closure,
@@ -89,12 +94,16 @@ Library
8994 deepseq == 1.3.0.0
9095 else
9196 Build-Depends: containers >= 0.4 && < 0.6,
92− deepseq >= 1.3.0.1 && < 1.4
97+ deepseq >= 1.3.0.1 && < 1.6
98+ if flag(old-locale)
99+ Build-Depends: time < 1.5, old-locale >= 1.0 && <1.1
100+ else
101+ Build-Depends: time >= 1.5
93102 if flag(th)
94103 if impl(ghc <= 7.4.2)
95104 Build-Depends: template-haskell >= 2.7 && < 2.8
96105 else
97− Build-Depends: template-haskell >= 2.6 && < 2.10
106+ Build-Depends: template-haskell >= 2.6 && < 2.11
98107 Exposed-modules: Control.Distributed.Process.Internal.Closure.TH
99108 CPP-Options: -DTemplateHaskellSupport
100109
src/Control/Distributed/Process/Internal/Closure/TH.hs+16−8
@@ -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]
src/Control/Distributed/Process/Internal/Primitives.hs+4
@@ -124,7 +124,11 @@ import Prelude hiding (catch)
124124import Data.Binary (decode)
125125import Data.Time.Clock (getCurrentTime)
126126import Data.Time.Format (formatTime)
127+#if MIN_VERSION_time(1,5,0)
128+import Data.Time.Format (defaultTimeLocale)
129+#else
127130import System.Locale (defaultTimeLocale)
131+#endif
128132import System.Timeout (timeout)
129133import Control.Monad (when)
130134import Control.Monad.Reader (ask)
src/Control/Distributed/Process/Internal/Types.hs+27−7
@@ -3,6 +3,7 @@
33{-# LANGUAGE GeneralizedNewtypeDeriving #-}
44{-# LANGUAGE GADTs #-}
55{-# LANGUAGE DeriveGeneric #-}
6+{-# LANGUAGE CPP #-}
67
78-- | Types used throughout the Cloud Haskell framework
89--
@@ -137,7 +138,7 @@ import GHC.Generics
137138newtype NodeId = NodeId { nodeAddress :: NT.EndPointAddress }
138139 deriving (Eq, Ord, Typeable, Data, Generic)
139140instance Binary NodeId where
140−instance NFData NodeId
141+instance NFData NodeId where rnf (NodeId a) = rnf a `seq` ()
141142instance Hashable NodeId where
142143instance Show NodeId where
143144 show (NodeId addr) = "nid://" ++ show addr
@@ -162,7 +163,7 @@ data ProcessId = ProcessId
162163 deriving (Eq, Ord, Typeable, Data, Generic)
163164
164165instance Binary ProcessId where
165−instance NFData ProcessId where
166+instance NFData ProcessId where rnf (ProcessId n _) = rnf n `seq` ()
166167instance Hashable ProcessId where
167168
168169instance Show ProcessId where
@@ -177,6 +178,10 @@ data Identifier =
177178 deriving (Eq, Ord, Generic)
178179
179180instance Hashable Identifier where
181+instance NFData Identifier where
182+ rnf (NodeIdentifier n) = rnf n `seq` ()
183+ rnf (ProcessIdentifier n) = rnf n `seq` ()
184+ rnf n@SendPortIdentifier{} = n `seq` ()
180185
181186instance Show Identifier where
182187 show (NodeIdentifier nid) = show nid
@@ -317,6 +322,9 @@ instance Show SendPortId where
317322 show (SendPortId (ProcessId (NodeId addr) (LocalProcessId _ plid)) clid)
318323 = "cid://" ++ show addr ++ ":" ++ show plid ++ ":" ++ show clid
319324
325+instance NFData SendPortId where
326+ rnf (SendPortId p _) = rnf p `seq` ()
327+
320328data TypedChannel = forall a. Serializable a => TypedChannel (Weak (TQueue a))
321329
322330-- | The send send of a typed channel (serializable)
@@ -328,7 +336,7 @@ newtype SendPort a = SendPort {
328336
329337instance (Serializable a) => Binary (SendPort a) where
330338instance (Hashable a) => Hashable (SendPort a) where
331−instance (NFData a) => NFData (SendPort a) where
339+instance (NFData a) => NFData (SendPort a) where rnf (SendPort x) = x `seq` ()
332340
333341-- | The receive end of a typed channel (not serializable)
334342--
@@ -366,6 +374,14 @@ data Message =
366374 }
367375 deriving (Typeable)
368376
377+instance NFData Message where
378+#if MIN_VERSION_bytestring(0,10,0)
379+ rnf (EncodedMessage _ e) = rnf e `seq` ()
380+#else
381+ rnf (EncodedMessage _ e) = BSL.length e `seq` ()
382+#endif
383+ rnf (UnencodedMessage _ a) = a `seq` () -- forced to WHNF only
384+
369385instance Show Message where
370386 show (EncodedMessage fp enc) = show enc ++ " :: " ++ showFingerprint fp []
371387 show (UnencodedMessage _ uenc) = "[unencoded message] :: " ++ (show $ typeOf uenc)
@@ -429,7 +445,10 @@ data MonitorRef = MonitorRef
429445 , monitorRefCounter :: !Int32
430446 }
431447 deriving (Eq, Ord, Show, Typeable, Generic)
432−instance Hashable MonitorRef where
448+instance Hashable MonitorRef
449+
450+instance NFData MonitorRef where
451+ rnf (MonitorRef i _) = rnf i `seq` ()
433452
434453-- | Message sent by process monitors
435454data ProcessMonitorNotification =
@@ -497,6 +516,10 @@ data DiedReason =
497516 | DiedUnknownId
498517 deriving (Show, Eq)
499518
519+instance NFData DiedReason where
520+ rnf (DiedException s) = rnf s `seq` ()
521+ rnf x = x `seq` ()
522+
500523-- | (Asynchronous) reply from unmonitor
501524newtype DidUnmonitor = DidUnmonitor MonitorRef
502525 deriving (Typeable, Binary)
@@ -678,9 +701,6 @@ instance Binary SendPortId where
678701 put cid = put (sendPortProcessId cid) >> put (sendPortLocalId cid)
679702 get = SendPortId <$> get <*> get
680703
681−instance NFData SendPortId where
682− rnf cid = (sendPortProcessId cid) `seq` (sendPortLocalId cid) `seq` ()
683−
684704instance Binary Identifier where
685705 put (ProcessIdentifier pid) = putWord8 0 >> put pid
686706 put (NodeIdentifier nid) = putWord8 1 >> put nid
src/Control/Distributed/Process/Management/Internal/Trace/Tracer.hs+4
@@ -88,7 +88,11 @@ import System.IO
8888 , hPutStrLn
8989 , hSetBuffering
9090 )
91+#if MIN_VERSION_time(1,5,0)
92+import Data.Time.Format (defaultTimeLocale)
93+#else
9194import System.Locale (defaultTimeLocale)
95+#endif
9296import System.Mem.Weak
9397 ( Weak
9498 )
src/Control/Distributed/Process/Serializable.hs+4
@@ -73,7 +73,11 @@ sizeOfFingerprint = sizeOf (undefined :: Fingerprint)
7373
7474-- | The fingerprint of the typeRep of the argument
7575fingerprint :: Typeable a => a -> Fingerprint
76+#if MIN_VERSION_base(4,8,0)
77+fingerprint a = let TypeRep fp _ _ _ = typeOf a in fp
78+#else
7679fingerprint a = let TypeRep fp _ _ = typeOf a in fp
80+#endif
7781
7882-- | Show fingerprint (for debugging purposes)
7983showFingerprint :: Fingerprint -> ShowS