Copyright | (c) Galois Inc 2014 |
---|---|
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Stability | provisional |
Safe Haskell | Unsafe |
Language | Haskell2010 |
Deprecated: Migrate to use Data.Parameterized.Nonce instead, this module will be removed soon.
This module provides a simple generator of new indexes in the ST monad. It is predictable and not intended for cryptographic purposes.
NOTE: the TestEquality
and OrdF
instances for the Nonce
type simply
compare the generated nonce values and then assert to the compiler
(via unsafeCoerce
) that the types ascribed to the nonces are equal
if their values are equal. This is only OK because of the discipline
by which nonces should be used: they should only be generated from
a NonceGenerator
(i.e., should not be built directly), and nonces from
different generators must never be compared! Arranging to compare
Nonces from different origins would allow users to build unsafeCoerce
via the testEquality
function.
This module is deprecated, and should not be used in new code. Clients of this module should migrate to use Data.Parameterized.Nonce.
Synopsis
- data NonceGenerator s
- newNonceGenerator :: ST s (NonceGenerator s)
- freshNonce :: NonceGenerator s -> ST s (Nonce tp)
- atLimit :: NonceGenerator s -> ST s Bool
- data Nonce (tp :: k)
- indexValue :: Nonce tp -> Word64
Documentation
data NonceGenerator s Source #
newNonceGenerator :: ST s (NonceGenerator s) Source #
Create a new counter.
freshNonce :: NonceGenerator s -> ST s (Nonce tp) Source #
Get a fresh index and increment the counter.
atLimit :: NonceGenerator s -> ST s Bool Source #
Return true if counter has reached the limit, and can't be incremented without risk of error.
An index generated by the counter.
Instances
TestEquality (Nonce :: k -> Type) Source # | |
Defined in Data.Parameterized.Nonce.Unsafe | |
HashableF (Nonce :: k -> Type) Source # | |
OrdF (Nonce :: k -> Type) Source # | |
Defined in Data.Parameterized.Nonce.Unsafe compareF :: forall (x :: k0) (y :: k0). Nonce x -> Nonce y -> OrderingF x y Source # leqF :: forall (x :: k0) (y :: k0). Nonce x -> Nonce y -> Bool Source # ltF :: forall (x :: k0) (y :: k0). Nonce x -> Nonce y -> Bool Source # geqF :: forall (x :: k0) (y :: k0). Nonce x -> Nonce y -> Bool Source # gtF :: forall (x :: k0) (y :: k0). Nonce x -> Nonce y -> Bool Source # | |
ShowF (Nonce :: k -> Type) Source # | |
Show (Nonce tp) Source # | |
Eq (Nonce tp) Source # | |
Ord (Nonce tp) Source # | |
Defined in Data.Parameterized.Nonce.Unsafe | |
Hashable (Nonce tp) Source # | |
Defined in Data.Parameterized.Nonce.Unsafe |
indexValue :: Nonce tp -> Word64 Source #