-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add compatibility with ghc-7.10 #189
Changes from all commits
3417155
7c233d1
ed800e6
7b2eae3
785543e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE CPP #-} | ||
|
||
-- | Types used throughout the Cloud Haskell framework | ||
-- | ||
|
@@ -137,7 +138,7 @@ import GHC.Generics | |
newtype NodeId = NodeId { nodeAddress :: NT.EndPointAddress } | ||
deriving (Eq, Ord, Typeable, Data, Generic) | ||
instance Binary NodeId where | ||
instance NFData NodeId | ||
instance NFData NodeId where rnf (NodeId a) = rnf a `seq` () | ||
instance Hashable NodeId where | ||
instance Show NodeId where | ||
show (NodeId addr) = "nid://" ++ show addr | ||
|
@@ -162,7 +163,7 @@ data ProcessId = ProcessId | |
deriving (Eq, Ord, Typeable, Data, Generic) | ||
|
||
instance Binary ProcessId where | ||
instance NFData ProcessId where | ||
instance NFData ProcessId where rnf (ProcessId n _) = rnf n `seq` () | ||
instance Hashable ProcessId where | ||
|
||
instance Show ProcessId where | ||
|
@@ -177,6 +178,10 @@ data Identifier = | |
deriving (Eq, Ord, Generic) | ||
|
||
instance Hashable Identifier where | ||
instance NFData Identifier where | ||
rnf (NodeIdentifier n) = rnf n `seq` () | ||
rnf (ProcessIdentifier n) = rnf n `seq` () | ||
rnf n@SendPortIdentifier{} = n `seq` () | ||
|
||
instance Show Identifier where | ||
show (NodeIdentifier nid) = show nid | ||
|
@@ -317,6 +322,9 @@ instance Show SendPortId where | |
show (SendPortId (ProcessId (NodeId addr) (LocalProcessId _ plid)) clid) | ||
= "cid://" ++ show addr ++ ":" ++ show plid ++ ":" ++ show clid | ||
|
||
instance NFData SendPortId where | ||
rnf (SendPortId p _) = rnf p `seq` () | ||
|
||
data TypedChannel = forall a. Serializable a => TypedChannel (Weak (TQueue a)) | ||
|
||
-- | The send send of a typed channel (serializable) | ||
|
@@ -328,7 +336,7 @@ newtype SendPort a = SendPort { | |
|
||
instance (Serializable a) => Binary (SendPort a) where | ||
instance (Hashable a) => Hashable (SendPort a) where | ||
instance (NFData a) => NFData (SendPort a) where | ||
instance (NFData a) => NFData (SendPort a) where rnf (SendPort x) = x `seq` () | ||
|
||
-- | The receive end of a typed channel (not serializable) | ||
-- | ||
|
@@ -366,6 +374,14 @@ data Message = | |
} | ||
deriving (Typeable) | ||
|
||
instance NFData Message where | ||
#if MIN_VERSION_bytestring(0,10,0) | ||
rnf (EncodedMessage _ e) = rnf e `seq` () | ||
#else | ||
rnf (EncodedMessage _ e) = BSL.length e `seq` () | ||
#endif | ||
rnf (UnencodedMessage _ a) = a `seq` () -- forced to WHNF only | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In unencoded message we have existential variable without NFData constraint, so we just can't force it to NF. This semantics was not changed in this pull request. AFAIU the reason for this change is ability to pass messages locally without additional serialization or forcing. |
||
|
||
instance Show Message where | ||
show (EncodedMessage fp enc) = show enc ++ " :: " ++ showFingerprint fp [] | ||
show (UnencodedMessage _ uenc) = "[unencoded message] :: " ++ (show $ typeOf uenc) | ||
|
@@ -429,7 +445,10 @@ data MonitorRef = MonitorRef | |
, monitorRefCounter :: !Int32 | ||
} | ||
deriving (Eq, Ord, Show, Typeable, Generic) | ||
instance Hashable MonitorRef where | ||
instance Hashable MonitorRef | ||
|
||
instance NFData MonitorRef where | ||
rnf (MonitorRef i _) = rnf i `seq` () | ||
|
||
-- | Message sent by process monitors | ||
data ProcessMonitorNotification = | ||
|
@@ -497,6 +516,10 @@ data DiedReason = | |
| DiedUnknownId | ||
deriving (Show, Eq) | ||
|
||
instance NFData DiedReason where | ||
rnf (DiedException s) = rnf s `seq` () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't auto derive? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, autoderiving creates incorrect instances in |
||
rnf x = x `seq` () | ||
|
||
-- | (Asynchronous) reply from unmonitor | ||
newtype DidUnmonitor = DidUnmonitor MonitorRef | ||
deriving (Typeable, Binary) | ||
|
@@ -678,9 +701,6 @@ instance Binary SendPortId where | |
put cid = put (sendPortProcessId cid) >> put (sendPortLocalId cid) | ||
get = SendPortId <$> get <*> get | ||
|
||
instance NFData SendPortId where | ||
rnf cid = (sendPortProcessId cid) `seq` (sendPortLocalId cid) `seq` () | ||
|
||
instance Binary Identifier where | ||
put (ProcessIdentifier pid) = putWord8 0 >> put pid | ||
put (NodeIdentifier nid) = putWord8 1 >> put nid | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should depend on deepseq>=1.4 and drop the
where rnf (NodeId a) = rnf a seq ()
.http://hackage.haskell.org/package/deepseq-1.4.1.1/docs/Control-DeepSeq.html#t:NFData
Unless I'm misunderstanding the point of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2 possibilities, use generic deriving on
>deepseq-1.4
and write instances manually on previous versions, or write instances manually everywhere. I find latter approach more straightforward as former implies latter under if-condition.