unbound-generics-0.0.2.1: Reimplementation of Unbound using GHC Generics

Copyright(c) 2014, Aleksey Kliger
LicenseBSD3 (See LICENSE)
MaintainerAleksey Kliger
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Unbound.Generics.LocallyNameless.Fresh

Description

Global freshness monad.

Synopsis

Documentation

class Monad m => Fresh m where Source

The Fresh type class governs monads which can generate new globally unique Names based on a given Name.

Methods

fresh :: Name a -> m (Name a) Source

Generate a new globally unique name based on the given one.

Instances

Fresh m => Fresh (MaybeT m) 
Monad m => Fresh (FreshMT m) 
(Error e, Fresh m) => Fresh (ErrorT e m) 
Fresh m => Fresh (ReaderT r m) 
Fresh m => Fresh (StateT s m) 
Fresh m => Fresh (StateT s m) 
(Monoid w, Fresh m) => Fresh (WriterT w m) 
(Monoid w, Fresh m) => Fresh (WriterT w m) 
Fresh m => Fresh (ExceptT e m) 

newtype FreshMT m a Source

The FreshM monad transformer. Keeps track of the lowest index still globally unused, and increments the index every time it is asked for a fresh name.

Constructors

FreshMT 

Fields

unFreshMT :: StateT Integer m a
 

runFreshMT :: Monad m => FreshMT m a -> m a Source

Run a FreshMT computation (with the global index starting at zero).

contFreshMT :: Monad m => FreshMT m a -> Integer -> m a Source

Run a FreshMT computation given a starting index for fresh name generation.

type FreshM = FreshMT Identity Source

A convenient monad which is an instance of Fresh. It keeps track of a global index used for generating fresh names, which is incremented every time fresh is called.

runFreshM :: FreshM a -> a Source

Run a FreshM computation (with the global index starting at zero).

contFreshM :: FreshM a -> Integer -> a Source

Run a FreshM computation given a starting index.