summaryrefslogtreecommitdiff
path: root/Logs/Chunk/Pure.hs
blob: 09e871c3858f6d5d5bf5b8c637ac8eeb4cd54d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{- Chunk logs, pure operations.
 -
 - Copyright 2014 Joey Hess <joey@kitenet.net>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

module Logs.Chunk.Pure where

import Common.Annex
import Logs.MapLog
import Data.Int

type ChunkSize = Int64

type ChunkCount = Integer

type ChunkLog = MapLog (UUID, ChunkSize) ChunkCount

parseLog :: String -> ChunkLog
parseLog = parseMapLog fieldparser valueparser
  where
	fieldparser s =
		let (u,sz) = separate (== ':') s
		in (,) <$> pure (toUUID u) <*> readish sz
	valueparser = readish

showLog :: ChunkLog -> String
showLog = showMapLog fieldshower valueshower
  where
	fieldshower (u, sz) = fromUUID u ++ ':' : show sz
	valueshower = show