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

Copyright | (c) Galois Inc 2014-2019
Maintainer | Eddy Westbrook <westbrook@galois.com>
Safe Haskell | None
Language | Haskell2010

Data.Parameterized.Nonce.Transformers

Description

This module provides a typeclass and monad transformers for generating nonces.

Synopsis

- class Monad m => MonadNonce (m :: Type -> Type) where
  - type NonceSet (m :: Type -> Type)
  - freshNonceM :: forall k (tp :: k). m (Nonce (NonceSet m) tp)
- newtype NonceT s (m :: Type -> Type) a = NonceT {
  - runNonceT :: ReaderT (NonceGenerator m s) m a
  }
- type NonceST t s = NonceT s (ST t)
- type NonceIO s = NonceT s IO
- getNonceSTGen :: NonceST t s (NonceGenerator (ST t) s)
- runNonceST :: (forall t s. NonceST t s a) -> a
- runNonceIO :: (forall s. NonceIO s a) -> IO a
- module Data.Parameterized.Nonce

# Documentation

class Monad m => MonadNonce (m :: Type -> Type) where Source #

A `MonadNonce` is a monad that can generate fresh `Nonce`s in a given set (where we view the phantom type parameter of `Nonce` as a designator of the set that the `Nonce` came from).

Associated Types

type NonceSet (m :: Type -> Type) Source #

Methods

freshNonceM :: forall k (tp :: k). m (Nonce (NonceSet m) tp) Source #

#### Instances

Instances details

Monad m => MonadNonce (NonceT s m) Source # |

Instance details

Defined in Data.Parameterized.Nonce.Transformers

Associated Types

type NonceSet (NonceT s m) |
Instance details Defined in Data.Parameterized.Nonce.Transformers type NonceSet (NonceT s m) = s

Methods

freshNonceM :: forall k (tp :: k). NonceT s m (Nonce (NonceSet (NonceT s m)) tp) Source #

MonadNonce m => MonadNonce (StateT s m) Source # |

Instance details

Defined in Data.Parameterized.Nonce.Transformers

Associated Types

type NonceSet (StateT s m) |
Instance details Defined in Data.Parameterized.Nonce.Transformers type NonceSet (StateT s m) = NonceSet m

Methods

freshNonceM :: forall k (tp :: k). StateT s m (Nonce (NonceSet (StateT s m)) tp) Source #

newtype NonceT s (m :: Type -> Type) a Source #

This transformer adds a nonce generator to a given monad.

Constructors

NonceT |

Fields

- runNonceT :: ReaderT (NonceGenerator m s) m a

#### Instances

Instances details

MonadTrans (NonceT s) Source # |
Instance details Defined in Data.Parameterized.Nonce.Transformers Methods lift :: Monad m => m a -> NonceT s m a Source #
Applicative m => Applicative (NonceT s m) Source # |
Instance details Defined in Data.Parameterized.Nonce.Transformers Methods pure :: a -> NonceT s m a Source # (<*>) :: NonceT s m (a -> b) -> NonceT s m a -> NonceT s m b Source # liftA2 :: (a -> b -> c) -> NonceT s m a -> NonceT s m b -> NonceT s m c Source # (*>) :: NonceT s m a -> NonceT s m b -> NonceT s m b Source # (<*) :: NonceT s m a -> NonceT s m b -> NonceT s m a Source #
Functor m => Functor (NonceT s m) Source # |
Instance details Defined in Data.Parameterized.Nonce.Transformers Methods fmap :: (a -> b) -> NonceT s m a -> NonceT s m b Source # (<$) :: a -> NonceT s m b -> NonceT s m a Source #
Monad m => Monad (NonceT s m) Source # |
Instance details Defined in Data.Parameterized.Nonce.Transformers Methods (>>=) :: NonceT s m a -> (a -> NonceT s m b) -> NonceT s m b Source # (>>) :: NonceT s m a -> NonceT s m b -> NonceT s m b Source # return :: a -> NonceT s m a Source #
Monad m => MonadNonce (NonceT s m) Source # |

Instance details

Defined in Data.Parameterized.Nonce.Transformers

Associated Types

type NonceSet (NonceT s m) |
Instance details Defined in Data.Parameterized.Nonce.Transformers type NonceSet (NonceT s m) = s

Methods

freshNonceM :: forall k (tp :: k). NonceT s m (Nonce (NonceSet (NonceT s m)) tp) Source #

type NonceSet (NonceT s m) Source # |
Instance details Defined in Data.Parameterized.Nonce.Transformers type NonceSet (NonceT s m) = s

type NonceST t s = NonceT s (ST t) Source #

Helper type to build a `MonadNonce` from the `ST` monad.

type NonceIO s = NonceT s IO Source #

Helper type to build a `MonadNonce` from the `IO` monad.

getNonceSTGen :: NonceST t s (NonceGenerator (ST t) s) Source #

Return the actual `NonceGenerator` used in an `ST` computation.

runNonceST :: (forall t s. NonceST t s a) -> a Source #

Run a `NonceST` computation with a fresh `NonceGenerator`.

runNonceIO :: (forall s. NonceIO s a) -> IO a Source #

Run a `NonceIO` computation with a fresh `NonceGenerator` inside `IO`.

module Data.Parameterized.Nonce