hexpr- A framework for symbolic, homoiconic languages.

Safe HaskellNone




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.


Generate Symbols

class Gensym s whereSource

Class for types that can provide an infinite supply of distinct values.


genzero :: sSource

The initial symbol generated.

nextsym :: s -> sSource

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.

Symbol Generator Monad Transformer

data SymbolGenT s m a Source

Monad transformer adding the capability of generating fresh symbols.


runSymbolGenT :: (Gensym s, Monad m) => SymbolGenT s m a -> m aSource

Perform a computation involving generating fresh symbols.