tamarin-prover-utils-0.4.0.0: Utility library for the tamarin prover.

PortabilityGHC only
MaintainerSimon Meier <iridcode@gmail.com>
Safe HaskellNone

Control.Monad.Trans.PreciseFresh

Contents

Description

A monad transformer for passing a fresh name supply through a computation. The name supply is precise in the sense that every String has its own supply of indices for the next fresh name.

Modeled after the mtl-2.0 library.

Synopsis

The Fresh monad

runFresh :: Fresh a -> FreshState -> (a, FreshState)Source

Run a computation with a fresh name supply.

evalFresh :: Fresh a -> FreshState -> aSource

Evaluate a computation with a fresh name supply.

execFresh :: Fresh a -> FreshState -> FreshStateSource

Execute a computation with a fresh name supply.

The FreshT monad transformer

newtype FreshT m a Source

A computation that can generate fresh variables from name hints.

Constructors

FreshT 

Fields

unFreshT :: StateT FreshState m a
 

Instances

freshT :: (FreshState -> m (a, FreshState)) -> FreshT m aSource

Construct a FreshT action from a FreshState modification.

runFreshT :: FreshT m a -> FreshState -> m (a, FreshState)Source

Run a computation with a fresh name supply.

evalFreshT :: Monad m => FreshT m a -> FreshState -> m aSource

execFreshT :: Monad m => FreshT m a -> FreshState -> m FreshStateSource

Execute a computation with a fresh name supply.

Fresh name generation

type FreshState = Map String IntegerSource

The state of the name supply: the first unused sequence number of every name.

nothingUsed :: FreshStateSource

The empty fresh state.

freshIdent :: Monad m => String -> FreshT m IntegerSource

O(log(n)). Get a fresh identifier for the given name.

freshIdentsSource

Arguments

:: Monad m 
=> Integer

number of desired identifiers

-> FreshT m Integer

The first fresh identifier.

O(n). Get k fresh identifiers.