summaryrefslogtreecommitdiff
path: root/Logs/SingleValue.hs
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 /Logs/SingleValue.hs
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 'Logs/SingleValue.hs')
-rw-r--r--Logs/SingleValue.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/Logs/SingleValue.hs b/Logs/SingleValue.hs
index 03975df92..cbebdc8e5 100644
--- a/Logs/SingleValue.hs
+++ b/Logs/SingleValue.hs
@@ -21,7 +21,7 @@ import Data.Time.Clock.POSIX
import Data.Time
import System.Locale
-class Serializable v where
+class SingleValueSerializable v where
serialize :: v -> String
deserialize :: String -> Maybe v
@@ -32,12 +32,12 @@ data LogEntry v = LogEntry
type Log v = S.Set (LogEntry v)
-showLog :: (Serializable v) => Log v -> String
+showLog :: (SingleValueSerializable v) => Log v -> String
showLog = unlines . map showline . S.toList
where
showline (LogEntry t v) = unwords [show t, serialize v]
-parseLog :: (Ord v, Serializable v) => String -> Log v
+parseLog :: (Ord v, SingleValueSerializable v) => String -> Log v
parseLog = S.fromList . mapMaybe parse . lines
where
parse line = do
@@ -52,13 +52,13 @@ newestValue s
| S.null s = Nothing
| otherwise = Just (value $ S.findMax s)
-readLog :: (Ord v, Serializable v) => FilePath -> Annex (Log v)
+readLog :: (Ord v, SingleValueSerializable v) => FilePath -> Annex (Log v)
readLog = parseLog <$$> Annex.Branch.get
-getLog :: (Ord v, Serializable v) => FilePath -> Annex (Maybe v)
+getLog :: (Ord v, SingleValueSerializable v) => FilePath -> Annex (Maybe v)
getLog = newestValue <$$> readLog
-setLog :: (Serializable v) => FilePath -> v -> Annex ()
+setLog :: (SingleValueSerializable v) => FilePath -> v -> Annex ()
setLog f v = do
now <- liftIO getPOSIXTime
let ent = LogEntry now v