parameterized-utils-2.1.1: Classes and data structures for working with data-kind indexed types

Copyright(c) Galois Inc 2014
MaintainerJoe Hendrix <jhendrix@galois.com>
Stabilityprovisional
Safe HaskellUnsafe
LanguageHaskell2010

Data.Parameterized.Nonce.Unsafe

Description

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

Documentation

data NonceGenerator s Source #

A simple type that for getting fresh indices in the ST monad. The type parameter s is used for the ST monad parameter.

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.

data Nonce (tp :: k) Source #

An index generated by the counter.

Instances
TestEquality (Nonce :: k -> Type) Source # 
Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

testEquality :: Nonce a -> Nonce b -> Maybe (a :~: b) #

HashableF (Nonce :: k -> Type) Source # 
Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

hashWithSaltF :: Int -> Nonce tp -> Int Source #

hashF :: Nonce tp -> Int Source #

ShowF (Nonce :: k -> Type) Source # 
Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

withShow :: p Nonce -> q tp -> (Show (Nonce tp) -> a) -> a Source #

showF :: Nonce tp -> String Source #

showsPrecF :: Int -> Nonce tp -> String -> String Source #

OrdF (Nonce :: k -> Type) Source # 
Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

compareF :: Nonce x -> Nonce y -> OrderingF x y Source #

leqF :: Nonce x -> Nonce y -> Bool Source #

ltF :: Nonce x -> Nonce y -> Bool Source #

geqF :: Nonce x -> Nonce y -> Bool Source #

gtF :: Nonce x -> Nonce y -> Bool Source #

Eq (Nonce tp) Source # 
Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

(==) :: Nonce tp -> Nonce tp -> Bool #

(/=) :: Nonce tp -> Nonce tp -> Bool #

Ord (Nonce tp) Source # 
Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

compare :: Nonce tp -> Nonce tp -> Ordering #

(<) :: Nonce tp -> Nonce tp -> Bool #

(<=) :: Nonce tp -> Nonce tp -> Bool #

(>) :: Nonce tp -> Nonce tp -> Bool #

(>=) :: Nonce tp -> Nonce tp -> Bool #

max :: Nonce tp -> Nonce tp -> Nonce tp #

min :: Nonce tp -> Nonce tp -> Nonce tp #

Show (Nonce tp) Source # 
Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

showsPrec :: Int -> Nonce tp -> ShowS #

show :: Nonce tp -> String #

showList :: [Nonce tp] -> ShowS #

Hashable (Nonce tp) Source # 
Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

hashWithSalt :: Int -> Nonce tp -> Int #

hash :: Nonce tp -> Int #