Skip to content

Commit 08eaf1c

Browse files
committed
Core: Internal.Hash: qualify GHC.TypeList as Kind
A preparation for further work.
1 parent 0eb0e02 commit 08eaf1c

File tree

1 file changed

+6
-5
lines changed
  • hnix-store-core/src/System/Nix/Internal

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ import Data.Text (Text)
3131
import qualified Data.Text as T
3232
import qualified Data.Text.Encoding as T
3333
import Data.Word (Word8)
34-
import GHC.TypeLits (Nat, KnownNat, natVal)
34+
import qualified GHC.TypeLits as Kind
35+
(Nat, KnownNat, natVal)
3536
import Data.Coerce (coerce)
3637

3738
-- | Constructors to indicate the base encodings
@@ -49,7 +50,7 @@ data HashAlgorithm
4950
| SHA1
5051
| SHA256
5152
| SHA512
52-
| Truncated Nat HashAlgorithm
53+
| Truncated Kind.Nat HashAlgorithm
5354
-- ^ The hash algorithm obtained by truncating the result of the
5455
-- input 'HashAlgorithm' to the given number of bytes. See
5556
-- 'truncateDigest' for a description of the truncation algorithm.
@@ -202,7 +203,7 @@ instance ValidAlgo 'SHA512 where
202203

203204
-- | Reuses the underlying 'ValidAlgo' instance, but does a
204205
-- 'truncateDigest' at the end.
205-
instance (ValidAlgo a, KnownNat n) => ValidAlgo ('Truncated n a) where
206+
instance (ValidAlgo a, Kind.KnownNat n) => ValidAlgo ('Truncated n a) where
206207
type AlgoCtx ('Truncated n a) = AlgoCtx a
207208
initialize = initialize @a
208209
update = update @a
@@ -216,11 +217,11 @@ instance (ValidAlgo a, KnownNat n) => ValidAlgo ('Truncated n a) where
216217
-- (leftover part), right-pads the leftovers with 0 to the truncation
217218
-- length, and combines the two strings bytewise with 'xor'.
218219
truncateDigest
219-
:: forall n a.(KnownNat n) => Digest a -> Digest ('Truncated n a)
220+
:: forall n a.(Kind.KnownNat n) => Digest a -> Digest ('Truncated n a)
220221
truncateDigest (Digest c) =
221222
Digest $ BS.pack $ fmap truncOutputByte [0.. n-1]
222223
where
223-
n = fromIntegral $ natVal (Proxy @n)
224+
n = fromIntegral $ Kind.natVal (Proxy @n)
224225

225226
truncOutputByte :: Int -> Word8
226227
truncOutputByte i = foldl' (aux i) 0 [0 .. BS.length c - 1]

0 commit comments

Comments
 (0)