Skip to content

Commit a8aaa9b

Browse files
committed
Rename HasDigest to ValidAlgo.
1 parent 715f415 commit a8aaa9b

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

hnix-store-core/src/System/Nix/Hash.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module System.Nix.Hash (
55
HNix.Digest
66

77
, HNix.HashAlgorithm(..)
8-
, HNix.HasDigest(..)
8+
, HNix.ValidAlgo(..)
99
, HNix.NamedAlgo(..)
1010
, HNix.hash
1111
, HNix.hashLazy

hnix-store-core/src/System/Nix/Internal/Hash.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ newtype Digest (a :: HashAlgorithm) =
5656

5757
-- | The primitive interface for incremental hashing for a given
5858
-- 'HashAlgorithm'. Every 'HashAlgorithm' should have an instance.
59-
class HasDigest (a :: HashAlgorithm) where
59+
class ValidAlgo (a :: HashAlgorithm) where
6060
-- | The incremental state for constructing a hash.
6161
type AlgoCtx a :: Type
6262

@@ -88,15 +88,15 @@ instance NamedAlgo 'SHA256 where
8888
-- or
8989
-- > :set -XTypeApplications
9090
-- > let d = hash @SHA256 "Hello, sha-256!"
91-
hash :: forall a.HasDigest a => BS.ByteString -> Digest a
91+
hash :: forall a.ValidAlgo a => BS.ByteString -> Digest a
9292
hash bs =
9393
finalize $ update @a (initialize @a) bs
9494

9595
-- | Hash an entire (lazy) 'BSL.ByteString' as a single call.
9696
--
9797
-- Use is the same as for 'hash'. This runs in constant space, but
9898
-- forces the entire bytestring.
99-
hashLazy :: forall a.HasDigest a => BSL.ByteString -> Digest a
99+
hashLazy :: forall a.ValidAlgo a => BSL.ByteString -> Digest a
100100
hashLazy bsl =
101101
finalize $ foldl' (update @a) (initialize @a) (BSL.toChunks bsl)
102102

@@ -108,27 +108,27 @@ encodeBase32 (Digest bs) = Base32.encode bs
108108
encodeBase16 :: Digest a -> T.Text
109109
encodeBase16 (Digest bs) = T.decodeUtf8 (Base16.encode bs)
110110

111-
instance HasDigest 'MD5 where
111+
instance ValidAlgo 'MD5 where
112112
type AlgoCtx 'MD5 = MD5.Ctx
113113
initialize = MD5.init
114114
update = MD5.update
115115
finalize = Digest . MD5.finalize
116116

117-
instance HasDigest 'SHA1 where
117+
instance ValidAlgo 'SHA1 where
118118
type AlgoCtx 'SHA1 = SHA1.Ctx
119119
initialize = SHA1.init
120120
update = SHA1.update
121121
finalize = Digest . SHA1.finalize
122122

123-
instance HasDigest 'SHA256 where
123+
instance ValidAlgo 'SHA256 where
124124
type AlgoCtx 'SHA256 = SHA256.Ctx
125125
initialize = SHA256.init
126126
update = SHA256.update
127127
finalize = Digest . SHA256.finalize
128128

129-
-- | Reuses the underlying 'HasDigest' instance, but does a
129+
-- | Reuses the underlying 'ValidAlgo' instance, but does a
130130
-- 'truncateDigest' at the end.
131-
instance (HasDigest a, KnownNat n) => HasDigest ('Truncated n a) where
131+
instance (ValidAlgo a, KnownNat n) => ValidAlgo ('Truncated n a) where
132132
type AlgoCtx ('Truncated n a) = AlgoCtx a
133133
initialize = initialize @a
134134
update = update @a

hnix-store-remote/src/System/Nix/Store/Remote.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ addToStoreNar = undefined -- XXX
178178
type PathFilter = Path -> Bool
179179

180180
addToStore
181-
:: forall a. (HasDigest a, NamedAlgo a)
181+
:: forall a. (ValidAlgo a, NamedAlgo a)
182182
=> LBS.ByteString
183183
-> FilePath
184184
-> Bool

0 commit comments

Comments
 (0)