summaryrefslogtreecommitdiff
path: root/Remote/External
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-21 16:08:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-21 16:08:59 -0400
commitd5f7fb27aad3e2e9c4bebb9ccd5577af8deb25c7 (patch)
tree838837e3112942fcf0f82cfc7f68e62a6f4e7a6e /Remote/External
parent9a8709f064c7608859b3155a752093b29cd8ab98 (diff)
reorganize numcopies code (no behavior changes)
Move stuff into Logs.NumCopies. Add a NumCopies newtype. Better names for various serialization classes that are specific to one thing or another.
Diffstat (limited to 'Remote/External')
-rw-r--r--Remote/External/Types.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/Remote/External/Types.hs b/Remote/External/Types.hs
index 42c71b760..1e17a2c4c 100644
--- a/Remote/External/Types.hs
+++ b/Remote/External/Types.hs
@@ -229,11 +229,11 @@ type ProtocolVersion = Int
supportedProtocolVersions :: [ProtocolVersion]
supportedProtocolVersions = [1]
-class Serializable a where
+class ExternalSerializable a where
serialize :: a -> String
deserialize :: String -> Maybe a
-instance Serializable Direction where
+instance ExternalSerializable Direction where
serialize Upload = "STORE"
serialize Download = "RETRIEVE"
@@ -241,23 +241,23 @@ instance Serializable Direction where
deserialize "RETRIEVE" = Just Download
deserialize _ = Nothing
-instance Serializable Key where
+instance ExternalSerializable Key where
serialize = key2file
deserialize = file2key
-instance Serializable [Char] where
+instance ExternalSerializable [Char] where
serialize = id
deserialize = Just
-instance Serializable ProtocolVersion where
+instance ExternalSerializable ProtocolVersion where
serialize = show
deserialize = readish
-instance Serializable Cost where
+instance ExternalSerializable Cost where
serialize = show
deserialize = readish
-instance Serializable Availability where
+instance ExternalSerializable Availability where
serialize GloballyAvailable = "GLOBAL"
serialize LocallyAvailable = "LOCAL"
@@ -265,7 +265,7 @@ instance Serializable Availability where
deserialize "LOCAL" = Just LocallyAvailable
deserialize _ = Nothing
-instance Serializable BytesProcessed where
+instance ExternalSerializable BytesProcessed where
serialize (BytesProcessed n) = show n
deserialize = BytesProcessed <$$> readish
@@ -283,15 +283,15 @@ parse0 :: a -> Parser a
parse0 mk "" = Just mk
parse0 _ _ = Nothing
-parse1 :: Serializable p1 => (p1 -> a) -> Parser a
+parse1 :: ExternalSerializable p1 => (p1 -> a) -> Parser a
parse1 mk p1 = mk <$> deserialize p1
-parse2 :: (Serializable p1, Serializable p2) => (p1 -> p2 -> a) -> Parser a
+parse2 :: (ExternalSerializable p1, ExternalSerializable p2) => (p1 -> p2 -> a) -> Parser a
parse2 mk s = mk <$> deserialize p1 <*> deserialize p2
where
(p1, p2) = splitWord s
-parse3 :: (Serializable p1, Serializable p2, Serializable p3) => (p1 -> p2 -> p3 -> a) -> Parser a
+parse3 :: (ExternalSerializable p1, ExternalSerializable p2, ExternalSerializable p3) => (p1 -> p2 -> p3 -> a) -> Parser a
parse3 mk s = mk <$> deserialize p1 <*> deserialize p2 <*> deserialize p3
where
(p1, rest) = splitWord s