Safe Haskell | None |
---|
Computations involving the generation of fresh symbols.
The notion of what is a symbol is abstracted by the Gensym
class.
Then, we provide the SymbolGen
monad and SymbolGenT
monad transformer,
in which symbols may be generated.
Symbols are generated deterministically, but also without reference to any other sources of symbols, such as the programmer's algorithms, user input or other SymbolGen monads. Therefore, make sure the symbols you generate are trivially distinct from all other sources of symbols.
- class Gensym s where
- gensym :: (Gensym s, Monad m) => SymbolGenT s m s
- type SymbolGen s = SymbolGenT s Identity
- runSymbolGen :: Gensym s => SymbolGen s a -> a
- data SymbolGenT s m a
- runSymbolGenT :: (Gensym s, Monad m) => SymbolGenT s m a -> m a
Generate Symbols
Class for types that can provide an infinite supply of distinct values.
The initial symbol generated.
Given the last symbol generated, generate the next. Must be distinct from all other symbols generated.
gensym :: (Gensym s, Monad m) => SymbolGenT s m sSource
Generate a fresh symbol. Of course, this monad does not know
what other sources of symbols there are, so make sure your Gensym
instance generates symbols distinct from all others.
Symbol Generator Monad
type SymbolGen s = SymbolGenT s IdentitySource
Synonym for SymbolGenT over Identity.
runSymbolGen :: Gensym s => SymbolGen s a -> aSource
Synonym for
.
runIdentity
. runSymbolGenT
Symbol Generator Monad Transformer
data SymbolGenT s m a Source
Monad transformer adding the capability of generating fresh symbols.
MonadTrans (SymbolGenT s) | |
Monad m => Monad (SymbolGenT s m) | |
Monad m => Functor (SymbolGenT s m) | |
Monad m => Applicative (SymbolGenT s m) | |
C m => C (SymbolGenT s m) | |
MonadIO m => MonadIO (SymbolGenT s m) |
runSymbolGenT :: (Gensym s, Monad m) => SymbolGenT s m a -> m aSource
Perform a computation involving generating fresh symbols.