From 1b2a8bdce6918c48e332a34615bafbf8d3670d1b Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Mon, 14 Jul 2025 12:19:56 +0200 Subject: [PATCH] use Data.Kind.Type instead of * --- src/Data/CryptoID/Class.hs | 10 +++++----- src/Data/CryptoID/Class/ImplicitNamespace.hs | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Data/CryptoID/Class.hs b/src/Data/CryptoID/Class.hs index 37fcb71..06f9d92 100644 --- a/src/Data/CryptoID/Class.hs +++ b/src/Data/CryptoID/Class.hs @@ -11,6 +11,8 @@ module Data.CryptoID.Class import Data.CryptoID (CryptoID) +import Data.Kind + import GHC.TypeLits (Symbol) import Control.Monad.Catch (MonadThrow) @@ -18,18 +20,16 @@ import Control.Monad.Catch (MonadThrow) -- | Class of monads granting reader access to a key and allowing for failure during cryptographic operations -- -- This formulation is weaker than @MonadReader key@ (from mtl) in that it does not require @local@. -class MonadThrow m => MonadCrypto (m :: * -> *) where - type MonadCryptoKey m :: * +class MonadThrow m => MonadCrypto (m :: Type -> Type) where + type MonadCryptoKey m :: Type cryptoIDKey :: (MonadCryptoKey m -> m a) -> m a -- | Multiparameter typeclass of @(namespace, ciphertext, plaintext, monad)@ tuples which allow for cryptographic operations on 'CryptoID's with appropriate @namespace@, @plaintext@, and @ciphertext@, utilising the state of @monad@ -- -- Instances of this typeclass are usually universally quantified over (at least) @namespace@, and @m@ -class MonadCrypto m => HasCryptoID (namespace :: Symbol) (ciphertext :: *) (plaintext :: *) (m :: * -> *) where +class MonadCrypto m => HasCryptoID (namespace :: Symbol) (ciphertext :: Type) (plaintext :: Type) (m :: Type -> Type) where encrypt :: plaintext -> m (CryptoID namespace ciphertext) -- ^ Encrypt a @plaintext@ in a fashion dependent on the @namespace@ and desired @ciphertext@-type retrieving the key from and throwing errors into @m@ decrypt :: CryptoID namespace ciphertext -> m plaintext -- ^ Encrypt a @ciphertext@ in a fashion dependent on the @namespace@ and desired @plaintext@-type retrieving the key from and throwing errors into @m@ - - diff --git a/src/Data/CryptoID/Class/ImplicitNamespace.hs b/src/Data/CryptoID/Class/ImplicitNamespace.hs index 0a9df5c..13eda0e 100644 --- a/src/Data/CryptoID/Class/ImplicitNamespace.hs +++ b/src/Data/CryptoID/Class/ImplicitNamespace.hs @@ -17,11 +17,13 @@ module Data.CryptoID.Class.ImplicitNamespace import qualified Data.CryptoID.Class as E import qualified Data.CryptoID as E +import Data.Kind + import GHC.TypeLits (Symbol) -- | Type family of @namespace@s associated to certain @plaintext@-types (parameterized over @ciphertext@ for completeness) -type family CryptoIDNamespace (ciphertext :: *) (plaintext :: *) :: Symbol +type family CryptoIDNamespace (ciphertext :: Type) (plaintext :: Type) :: Symbol -- | 'E.HasCryptoID' reformulated to utilize 'CryptoIDNamespace' type HasCryptoID ciphertext plaintext = E.HasCryptoID (CryptoIDNamespace ciphertext plaintext) ciphertext plaintext