summaryrefslogtreecommitdiff
path: root/src/Storage/Internal.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-04-05 22:03:43 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-04-05 22:03:43 +0200
commit7a9ef992afa96ed177ae9a4a67d302017ab73852 (patch)
tree4c53058ce2ae8015db653326996bfc17a906e72e /src/Storage/Internal.hs
parenta8893fbcfa06044e7f999916c4dcc6a2dc907f75 (diff)
Fix non-exhaustive pattern match warnings
Diffstat (limited to 'src/Storage/Internal.hs')
-rw-r--r--src/Storage/Internal.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Storage/Internal.hs b/src/Storage/Internal.hs
index 85742a3..402d924 100644
--- a/src/Storage/Internal.hs
+++ b/src/Storage/Internal.hs
@@ -115,8 +115,11 @@ refDigest (Ref _ dgst) = dgst
showRef :: Ref' c -> ByteString
showRef = showRefDigest . refDigest
+showRefDigestParts :: RefDigest -> (ByteString, ByteString)
+showRefDigestParts x = (BC.pack "blake2", showHex x)
+
showRefDigest :: RefDigest -> ByteString
-showRefDigest x = BC.pack "blake2#" `BC.append` showHex x
+showRefDigest = showRefDigestParts >>> \(alg, hex) -> alg <> BC.pack "#" <> hex
readRefDigest :: ByteString -> Maybe RefDigest
readRefDigest x = case BC.split '#' x of
@@ -213,7 +216,7 @@ ioLoadBytesFromStorage st dgst = loadCurrent st >>=
refPath :: FilePath -> RefDigest -> FilePath
refPath spath rdgst = intercalate "/" [spath, "objects", BC.unpack alg, pref, rest]
- where [alg, dgst] = BC.split '#' $ showRefDigest rdgst
+ where (alg, dgst) = showRefDigestParts rdgst
(pref, rest) = splitAt 2 $ BC.unpack dgst