Portability | GHC only |
---|---|
Maintainer | Simon Meier <iridcode@gmail.com> |
Safe Haskell | None |
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.
- type Fresh = FreshT Identity
- runFresh :: Fresh a -> FreshState -> (a, FreshState)
- evalFresh :: Fresh a -> FreshState -> a
- execFresh :: Fresh a -> FreshState -> FreshState
- newtype FreshT m a = FreshT {
- unFreshT :: StateT FreshState m a
- freshT :: (FreshState -> m (a, FreshState)) -> FreshT m a
- runFreshT :: FreshT m a -> FreshState -> m (a, FreshState)
- evalFreshT :: Monad m => FreshT m a -> FreshState -> m a
- execFreshT :: Monad m => FreshT m a -> FreshState -> m FreshState
- type FreshState = Map String Integer
- nothingUsed :: FreshState
- freshIdent :: Monad m => String -> FreshT m Integer
- freshIdents :: Monad m => Integer -> FreshT m Integer
- scopeFreshness :: Monad m => FreshT m a -> FreshT m a
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
A computation that can generate fresh variables from name hints.
FreshT | |
|
MonadTrans FreshT | |
MonadBind k v m => MonadBind k v (FreshT m) | |
MonadError e m => MonadError e (FreshT m) | |
MonadReader r m => MonadReader r (FreshT m) | |
MonadState s m => MonadState s (FreshT m) | |
Monad m => Monad (FreshT m) | |
Functor m => Functor (FreshT m) | |
MonadPlus m => MonadPlus (FreshT m) | |
(Monad m, Functor m) => Applicative (FreshT m) | |
(Functor m, MonadPlus m) => Alternative (FreshT m) | |
(Functor m, Monad m) => MonadFresh (FreshT m) |
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.
:: Monad m | |
=> Integer | number of desired identifiers |
-> FreshT m Integer | The first fresh identifier. |
O(n). Get k
fresh identifiers.
scopeFreshness :: Monad m => FreshT m a -> FreshT m aSource
Restrict the scope of the freshness requests.