git.iko.soy/distributed-process
on master help sign in
Use a BS.copy in Binary instance for addresses
0b0ddb8Edsko de Vries
network-transport/src/Network/Transport.hs+8−2
@@ -23,10 +23,12 @@ module Network.Transport ( -- * Types
23 ) where
23 ) where
24
24
25import Data.ByteString (ByteString)
25import Data.ByteString (ByteString)
26+import qualified Data.ByteString as BS (copy)
26import qualified Data.ByteString.Char8 as BSC (unpack)
27import qualified Data.ByteString.Char8 as BSC (unpack)
27import Control.Exception (Exception)
28import Control.Exception (Exception)
29+import Control.Applicative ((<$>))
28import Data.Typeable (Typeable)
30import Data.Typeable (Typeable)
29−import Data.Binary (Binary)
31+import Data.Binary (Binary(get, put))
30
32
31--------------------------------------------------------------------------------
33--------------------------------------------------------------------------------
32-- Main API --
34-- Main API --
@@ -116,7 +118,11 @@ data MulticastGroup = MulticastGroup {
116
118
117-- | EndPointAddress of an endpoint.
119-- | EndPointAddress of an endpoint.
118newtype EndPointAddress = EndPointAddress { endPointAddressToByteString :: ByteString }
120newtype EndPointAddress = EndPointAddress { endPointAddressToByteString :: ByteString }
119− deriving (Eq, Ord, Typeable, Binary)
121+ deriving (Eq, Ord, Typeable)
122+
123+instance Binary EndPointAddress where
124+ put = put . endPointAddressToByteString
125+ get = EndPointAddress . BS.copy <$> get
120
126
121instance Show EndPointAddress where
127instance Show EndPointAddress where
122 show = BSC.unpack . endPointAddressToByteString
128 show = BSC.unpack . endPointAddressToByteString