summaryrefslogtreecommitdiff
path: root/src/Erebos/Storage/Internal.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-06-03 22:03:33 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2026-06-04 21:13:42 +0200
commit9fd045d5dd5a2d9b210847451fb6fc0837a00068 (patch)
treedce40a1726a3a2dd26589780553cabde59703b24 /src/Erebos/Storage/Internal.hs
parent2f403246cb0eb4a0c39598f03cb2116ad00fc500 (diff)
Move Ref declaration to Object.Internal moduleHEADmaster
Diffstat (limited to 'src/Erebos/Storage/Internal.hs')
-rw-r--r--src/Erebos/Storage/Internal.hs39
1 files changed, 5 insertions, 34 deletions
diff --git a/src/Erebos/Storage/Internal.hs b/src/Erebos/Storage/Internal.hs
index c7255ef..e6fafe4 100644
--- a/src/Erebos/Storage/Internal.hs
+++ b/src/Erebos/Storage/Internal.hs
@@ -1,13 +1,11 @@
module Erebos.Storage.Internal (
Storage'(..), Storage, PartialStorage,
- Ref'(..), Ref, PartialRef,
RefDigest(..),
WatchID, startWatchID, nextWatchID,
WatchList(..), WatchListItem(..), watchListAdd, watchListDel,
- refStorage,
- refDigest, refDigestFromByteString,
- showRef, showRefDigest, showRefDigestParts,
+ refDigestFromByteString,
+ showRefDigest, showRefDigestParts,
readRefDigest,
hashToRefDigest,
@@ -176,36 +174,9 @@ newtype RefDigest = RefDigest (Digest Blake2b_256)
instance Show RefDigest where
show = BC.unpack . showRefDigest
-data Ref' c = Ref (Storage' c) RefDigest
-
-type Ref = Ref' Complete
-type PartialRef = Ref' Partial
-
-instance Eq (Ref' c) where
- Ref _ d1 == Ref _ d2 = d1 == d2
-
-instance Show (Ref' c) where
- show ref@(Ref st _) = show st ++ ":" ++ BC.unpack (showRef ref)
-
-instance ByteArrayAccess (Ref' c) where
- length (Ref _ dgst) = BA.length dgst
- withByteArray (Ref _ dgst) = BA.withByteArray dgst
-
instance Hashable RefDigest where
hashWithSalt salt ref = salt `xor` unsafePerformIO (BA.withByteArray ref peek)
-instance Hashable (Ref' c) where
- hashWithSalt salt ref = salt `xor` unsafePerformIO (BA.withByteArray ref peek)
-
-refStorage :: Ref' c -> Storage' c
-refStorage (Ref st _) = st
-
-refDigest :: Ref' c -> RefDigest
-refDigest (Ref _ dgst) = dgst
-
-showRef :: Ref' c -> ByteString
-showRef = showRefDigest . refDigest
-
showRefDigestParts :: RefDigest -> (ByteString, ByteString)
showRefDigestParts x = (BC.pack "blake2", showHex x)
@@ -243,18 +214,18 @@ type Partial = Either RefDigest
class (Traversable compl, Monad compl, Typeable compl) => StorageCompleteness compl where
type LoadResult compl a :: Type
returnLoadResult :: compl a -> LoadResult compl a
- ioLoadBytes :: Ref' compl -> IO (compl BL.ByteString)
+ unsafeLoadBytes :: Storage' compl -> RefDigest -> IO (compl BL.ByteString)
instance StorageCompleteness Complete where
type LoadResult Complete a = a
returnLoadResult = runIdentity
- ioLoadBytes ref@(Ref st dgst) = maybe (error $ "Ref not found in complete storage: "++show ref) Identity
+ unsafeLoadBytes st dgst = maybe (error $ "Ref not found in complete storage: "++show dgst) Identity
<$> ioLoadBytesFromStorage st dgst
instance StorageCompleteness Partial where
type LoadResult Partial a = Either RefDigest a
returnLoadResult = id
- ioLoadBytes (Ref st dgst) = maybe (Left dgst) Right <$> ioLoadBytesFromStorage st dgst
+ unsafeLoadBytes st dgst = maybe (Left dgst) Right <$> ioLoadBytesFromStorage st dgst
ioLoadBytesFromStorage :: Storage' c -> RefDigest -> IO (Maybe BL.ByteString)
ioLoadBytesFromStorage Storage {..} dgst =