git.iko.soy/distributed-process
on master help sign in
Merge pull request #189 from tweag/ghc-7.10
3606f3dAlexander Vershilov
distributed-process.cabal+16−7
@@ -38,6 +38,13 @@ flag prof
38 description: Compiling with profiling enabled
38 description: Compiling with profiling enabled
39 default: False
39 default: False
40
40
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+
41Library
48Library
42 Build-Depends: base >= 4.4 && < 5,
49 Build-Depends: base >= 4.4 && < 5,
43 binary >= 0.6.3 && < 0.8,
50 binary >= 0.6.3 && < 0.8,
@@ -45,15 +52,13 @@ Library
45 network-transport >= 0.4.1.0 && < 0.5,
52 network-transport >= 0.4.1.0 && < 0.5,
46 stm >= 2.4 && < 2.5,
53 stm >= 2.4 && < 2.5,
47 transformers >= 0.2 && < 0.5,
54 transformers >= 0.2 && < 0.5,
48− mtl >= 2.0 && < 2.3,
55+ mtl >= 2.0 && < 2.4,
49 data-accessor >= 0.2 && < 0.3,
56 data-accessor >= 0.2 && < 0.3,
50 bytestring >= 0.9 && < 0.11,
57 bytestring >= 0.9 && < 0.11,
51− old-locale >= 1.0 && < 1.1,
52− time >= 1.2 && < 1.5,
53 random >= 1.0 && < 1.2,
58 random >= 1.0 && < 1.2,
54− ghc-prim >= 0.2 && < 0.4,
59+ ghc-prim >= 0.2 && < 0.5,
55 distributed-static >= 0.2 && < 0.4,
60 distributed-static >= 0.2 && < 0.4,
56− rank1dynamic >= 0.1 && < 0.3,
61+ rank1dynamic >= 0.1 && < 0.4,
57 syb >= 0.3 && < 0.5
62 syb >= 0.3 && < 0.5
58 Exposed-modules: Control.Distributed.Process,
63 Exposed-modules: Control.Distributed.Process,
59 Control.Distributed.Process.Closure,
64 Control.Distributed.Process.Closure,
@@ -89,12 +94,16 @@ Library
89 deepseq == 1.3.0.0
94 deepseq == 1.3.0.0
90 else
95 else
91 Build-Depends: containers >= 0.4 && < 0.6,
96 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
93 if flag(th)
102 if flag(th)
94 if impl(ghc <= 7.4.2)
103 if impl(ghc <= 7.4.2)
95 Build-Depends: template-haskell >= 2.7 && < 2.8
104 Build-Depends: template-haskell >= 2.7 && < 2.8
96 else
105 else
97− Build-Depends: template-haskell >= 2.6 && < 2.10
106+ Build-Depends: template-haskell >= 2.6 && < 2.11
98 Exposed-modules: Control.Distributed.Process.Internal.Closure.TH
107 Exposed-modules: Control.Distributed.Process.Internal.Closure.TH
99 CPP-Options: -DTemplateHaskellSupport
108 CPP-Options: -DTemplateHaskellSupport
100
109
src/Control/Distributed/Process/Internal/Closure/TH.hs+16−8
@@ -1,5 +1,5 @@
1-- | Template Haskell support
1-- | Template Haskell support
2−{-# LANGUAGE TemplateHaskell #-}
2+{-# LANGUAGE TemplateHaskell, CPP #-}
3module Control.Distributed.Process.Internal.Closure.TH
3module Control.Distributed.Process.Internal.Closure.TH
4 ( -- * User-level API
4 ( -- * User-level API
5 remotable
5 remotable
@@ -29,7 +29,11 @@ import Language.Haskell.TH
29 , Type(AppT, ForallT, VarT, ArrowT)
29 , Type(AppT, ForallT, VarT, ArrowT)
30 , Info(VarI)
30 , Info(VarI)
31 , TyVarBndr(PlainTV, KindedTV)
31 , TyVarBndr(PlainTV, KindedTV)
32− , Pred(ClassP)
32+#if ! MIN_VERSION_template_haskell(2,10,0)
33+ , Pred
34+#endif
35+ , varT
36+ , classP
33 -- Lifted constructors
37 -- Lifted constructors
34 -- .. Literals
38 -- .. Literals
35 , stringL
39 , stringL
@@ -67,6 +71,10 @@ import Control.Distributed.Process.Serializable
67 )
71 )
68import Control.Distributed.Process.Internal.Closure.BuiltIn (staticDecode)
72import Control.Distributed.Process.Internal.Closure.BuiltIn (staticDecode)
69
73
74+#if MIN_VERSION_template_haskell(2,10,0)
75+type Pred = Type
76+#endif
77+
70--------------------------------------------------------------------------------
78--------------------------------------------------------------------------------
71-- User-level API --
79-- User-level API --
72--------------------------------------------------------------------------------
80--------------------------------------------------------------------------------
@@ -244,16 +252,16 @@ generateStatic :: Name -> [TyVarBndr] -> Type -> Q [Dec]
244generateStatic n xs typ = do
252generateStatic n xs typ = do
245 staticTyp <- [t| Static |]
253 staticTyp <- [t| Static |]
246 sequence
254 sequence
247− [ sigD (staticName n) $
255+ [ sigD (staticName n) $ do
256+ txs <- sequence $ map typeable xs
248 return (ForallT xs
257 return (ForallT xs
249− (map typeable xs)
258+ txs
250− (staticTyp `AppT` typ)
259+ (staticTyp `AppT` typ))
251− )
252 , sfnD (staticName n) [| staticLabel $(showFQN n) |]
260 , sfnD (staticName n) [| staticLabel $(showFQN n) |]
253 ]
261 ]
254 where
262 where
255− typeable :: TyVarBndr -> Pred
263+ typeable :: TyVarBndr -> Q Pred
256− typeable tv = ClassP (mkName "Typeable") [VarT (tyVarBndrName tv)]
264+ typeable tv = classP (mkName "Typeable") [varT (tyVarBndrName tv)]
257
265
258-- | Generate a serialization dictionary with name 'n' for type 'typ'
266-- | Generate a serialization dictionary with name 'n' for type 'typ'
259generateDict :: Name -> Type -> Q [Dec]
267generateDict :: Name -> Type -> Q [Dec]
src/Control/Distributed/Process/Internal/Primitives.hs+4
@@ -124,7 +124,11 @@ import Prelude hiding (catch)
124import Data.Binary (decode)
124import Data.Binary (decode)
125import Data.Time.Clock (getCurrentTime)
125import Data.Time.Clock (getCurrentTime)
126import Data.Time.Format (formatTime)
126import Data.Time.Format (formatTime)
127+#if MIN_VERSION_time(1,5,0)
128+import Data.Time.Format (defaultTimeLocale)
129+#else
127import System.Locale (defaultTimeLocale)
130import System.Locale (defaultTimeLocale)
131+#endif
128import System.Timeout (timeout)
132import System.Timeout (timeout)
129import Control.Monad (when)
133import Control.Monad (when)
130import Control.Monad.Reader (ask)
134import Control.Monad.Reader (ask)
src/Control/Distributed/Process/Internal/Types.hs+27−7
@@ -3,6 +3,7 @@
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4{-# LANGUAGE GADTs #-}
4{-# LANGUAGE GADTs #-}
5{-# LANGUAGE DeriveGeneric #-}
5{-# LANGUAGE DeriveGeneric #-}
6+{-# LANGUAGE CPP #-}
6
7
7-- | Types used throughout the Cloud Haskell framework
8-- | Types used throughout the Cloud Haskell framework
8--
9--
@@ -137,7 +138,7 @@ import GHC.Generics
137newtype NodeId = NodeId { nodeAddress :: NT.EndPointAddress }
138newtype NodeId = NodeId { nodeAddress :: NT.EndPointAddress }
138 deriving (Eq, Ord, Typeable, Data, Generic)
139 deriving (Eq, Ord, Typeable, Data, Generic)
139instance Binary NodeId where
140instance Binary NodeId where
140−instance NFData NodeId
141+instance NFData NodeId where rnf (NodeId a) = rnf a `seq` ()
141instance Hashable NodeId where
142instance Hashable NodeId where
142instance Show NodeId where
143instance Show NodeId where
143 show (NodeId addr) = "nid://" ++ show addr
144 show (NodeId addr) = "nid://" ++ show addr
@@ -162,7 +163,7 @@ data ProcessId = ProcessId
162 deriving (Eq, Ord, Typeable, Data, Generic)
163 deriving (Eq, Ord, Typeable, Data, Generic)
163
164
164instance Binary ProcessId where
165instance Binary ProcessId where
165−instance NFData ProcessId where
166+instance NFData ProcessId where rnf (ProcessId n _) = rnf n `seq` ()
166instance Hashable ProcessId where
167instance Hashable ProcessId where
167
168
168instance Show ProcessId where
169instance Show ProcessId where
@@ -177,6 +178,10 @@ data Identifier =
177 deriving (Eq, Ord, Generic)
178 deriving (Eq, Ord, Generic)
178
179
179instance Hashable Identifier where
180instance 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` ()
180
185
181instance Show Identifier where
186instance Show Identifier where
182 show (NodeIdentifier nid) = show nid
187 show (NodeIdentifier nid) = show nid
@@ -317,6 +322,9 @@ instance Show SendPortId where
317 show (SendPortId (ProcessId (NodeId addr) (LocalProcessId _ plid)) clid)
322 show (SendPortId (ProcessId (NodeId addr) (LocalProcessId _ plid)) clid)
318 = "cid://" ++ show addr ++ ":" ++ show plid ++ ":" ++ show clid
323 = "cid://" ++ show addr ++ ":" ++ show plid ++ ":" ++ show clid
319
324
325+instance NFData SendPortId where
326+ rnf (SendPortId p _) = rnf p `seq` ()
327+
320data TypedChannel = forall a. Serializable a => TypedChannel (Weak (TQueue a))
328data TypedChannel = forall a. Serializable a => TypedChannel (Weak (TQueue a))
321
329
322-- | The send send of a typed channel (serializable)
330-- | The send send of a typed channel (serializable)
@@ -328,7 +336,7 @@ newtype SendPort a = SendPort {
328
336
329instance (Serializable a) => Binary (SendPort a) where
337instance (Serializable a) => Binary (SendPort a) where
330instance (Hashable a) => Hashable (SendPort a) where
338instance (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` ()
332
340
333-- | The receive end of a typed channel (not serializable)
341-- | The receive end of a typed channel (not serializable)
334--
342--
@@ -366,6 +374,14 @@ data Message =
366 }
374 }
367 deriving (Typeable)
375 deriving (Typeable)
368
376
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+
369instance Show Message where
385instance Show Message where
370 show (EncodedMessage fp enc) = show enc ++ " :: " ++ showFingerprint fp []
386 show (EncodedMessage fp enc) = show enc ++ " :: " ++ showFingerprint fp []
371 show (UnencodedMessage _ uenc) = "[unencoded message] :: " ++ (show $ typeOf uenc)
387 show (UnencodedMessage _ uenc) = "[unencoded message] :: " ++ (show $ typeOf uenc)
@@ -429,7 +445,10 @@ data MonitorRef = MonitorRef
429 , monitorRefCounter :: !Int32
445 , monitorRefCounter :: !Int32
430 }
446 }
431 deriving (Eq, Ord, Show, Typeable, Generic)
447 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` ()
433
452
434-- | Message sent by process monitors
453-- | Message sent by process monitors
435data ProcessMonitorNotification =
454data ProcessMonitorNotification =
@@ -497,6 +516,10 @@ data DiedReason =
497 | DiedUnknownId
516 | DiedUnknownId
498 deriving (Show, Eq)
517 deriving (Show, Eq)
499
518
519+instance NFData DiedReason where
520+ rnf (DiedException s) = rnf s `seq` ()
521+ rnf x = x `seq` ()
522+
500-- | (Asynchronous) reply from unmonitor
523-- | (Asynchronous) reply from unmonitor
501newtype DidUnmonitor = DidUnmonitor MonitorRef
524newtype DidUnmonitor = DidUnmonitor MonitorRef
502 deriving (Typeable, Binary)
525 deriving (Typeable, Binary)
@@ -678,9 +701,6 @@ instance Binary SendPortId where
678 put cid = put (sendPortProcessId cid) >> put (sendPortLocalId cid)
701 put cid = put (sendPortProcessId cid) >> put (sendPortLocalId cid)
679 get = SendPortId <$> get <*> get
702 get = SendPortId <$> get <*> get
680
703
681−instance NFData SendPortId where
682− rnf cid = (sendPortProcessId cid) `seq` (sendPortLocalId cid) `seq` ()
683−
684instance Binary Identifier where
704instance Binary Identifier where
685 put (ProcessIdentifier pid) = putWord8 0 >> put pid
705 put (ProcessIdentifier pid) = putWord8 0 >> put pid
686 put (NodeIdentifier nid) = putWord8 1 >> put nid
706 put (NodeIdentifier nid) = putWord8 1 >> put nid
src/Control/Distributed/Process/Management/Internal/Trace/Tracer.hs+4
@@ -88,7 +88,11 @@ import System.IO
88 , hPutStrLn
88 , hPutStrLn
89 , hSetBuffering
89 , hSetBuffering
90 )
90 )
91+#if MIN_VERSION_time(1,5,0)
92+import Data.Time.Format (defaultTimeLocale)
93+#else
91import System.Locale (defaultTimeLocale)
94import System.Locale (defaultTimeLocale)
95+#endif
92import System.Mem.Weak
96import System.Mem.Weak
93 ( Weak
97 ( Weak
94 )
98 )
src/Control/Distributed/Process/Serializable.hs+4
@@ -73,7 +73,11 @@ sizeOfFingerprint = sizeOf (undefined :: Fingerprint)
73
73
74-- | The fingerprint of the typeRep of the argument
74-- | The fingerprint of the typeRep of the argument
75fingerprint :: Typeable a => a -> Fingerprint
75fingerprint :: Typeable a => a -> Fingerprint
76+#if MIN_VERSION_base(4,8,0)
77+fingerprint a = let TypeRep fp _ _ _ = typeOf a in fp
78+#else
76fingerprint a = let TypeRep fp _ _ = typeOf a in fp
79fingerprint a = let TypeRep fp _ _ = typeOf a in fp
80+#endif
77
81
78-- | Show fingerprint (for debugging purposes)
82-- | Show fingerprint (for debugging purposes)
79showFingerprint :: Fingerprint -> ShowS
83showFingerprint :: Fingerprint -> ShowS