unbound-generics-0.3.1: Support for programming with names and binders 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.

Minimal complete definition

fresh

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) Source # 

Methods

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

Monad m => Fresh (FreshMT m) Source # 

Methods

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

Fresh m => Fresh (FFM m) Source # 

Methods

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

(Monoid w, Fresh m) => Fresh (WriterT w m) Source # 

Methods

fresh :: Name a -> WriterT w m (Name a) Source #

(Monoid w, Fresh m) => Fresh (WriterT w m) Source # 

Methods

fresh :: Name a -> WriterT w m (Name a) Source #

Fresh m => Fresh (StateT s m) Source # 

Methods

fresh :: Name a -> StateT s m (Name a) Source #

Fresh m => Fresh (StateT s m) Source # 

Methods

fresh :: Name a -> StateT s m (Name a) Source #

(Error e, Fresh m) => Fresh (ErrorT e m) Source # 

Methods

fresh :: Name a -> ErrorT e m (Name a) Source #

Fresh m => Fresh (ExceptT e m) Source # 

Methods

fresh :: Name a -> ExceptT e m (Name a) Source #

Fresh m => Fresh (ReaderT * r m) Source # 

Methods

fresh :: Name a -> ReaderT * r m (Name a) Source #

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

Instances

MonadTrans FreshMT Source # 

Methods

lift :: Monad m => m a -> FreshMT m a #

MonadReader r m => MonadReader r (FreshMT m) Source # 

Methods

ask :: FreshMT m r

local :: (r -> r) -> FreshMT m a -> FreshMT m a

reader :: (r -> a) -> FreshMT m a

MonadError e m => MonadError e (FreshMT m) Source # 

Methods

throwError :: e -> FreshMT m a

catchError :: FreshMT m a -> (e -> FreshMT m a) -> FreshMT m a

MonadState s m => MonadState s (FreshMT m) Source # 

Methods

get :: FreshMT m s

put :: s -> FreshMT m ()

state :: (s -> (a, s)) -> FreshMT m a

MonadWriter w m => MonadWriter w (FreshMT m) Source # 

Methods

writer :: (a, w) -> FreshMT m a

tell :: w -> FreshMT m ()

listen :: FreshMT m a -> FreshMT m (a, w)

pass :: FreshMT m (a, w -> w) -> FreshMT m a

Monad m => Monad (FreshMT m) Source # 

Methods

(>>=) :: FreshMT m a -> (a -> FreshMT m b) -> FreshMT m b #

(>>) :: FreshMT m a -> FreshMT m b -> FreshMT m b #

return :: a -> FreshMT m a #

fail :: String -> FreshMT m a #

Functor m => Functor (FreshMT m) Source # 

Methods

fmap :: (a -> b) -> FreshMT m a -> FreshMT m b #

(<$) :: a -> FreshMT m b -> FreshMT m a #

MonadFix m => MonadFix (FreshMT m) Source # 

Methods

mfix :: (a -> FreshMT m a) -> FreshMT m a #

Monad m => Applicative (FreshMT m) Source # 

Methods

pure :: a -> FreshMT m a #

(<*>) :: FreshMT m (a -> b) -> FreshMT m a -> FreshMT m b #

(*>) :: FreshMT m a -> FreshMT m b -> FreshMT m b #

(<*) :: FreshMT m a -> FreshMT m b -> FreshMT m a #

MonadIO m => MonadIO (FreshMT m) Source # 

Methods

liftIO :: IO a -> FreshMT m a #

MonadPlus m => Alternative (FreshMT m) Source # 

Methods

empty :: FreshMT m a #

(<|>) :: FreshMT m a -> FreshMT m a -> FreshMT m a #

some :: FreshMT m a -> FreshMT m [a] #

many :: FreshMT m a -> FreshMT m [a] #

MonadPlus m => MonadPlus (FreshMT m) Source # 

Methods

mzero :: FreshMT m a #

mplus :: FreshMT m a -> FreshMT m a -> FreshMT m a #

MonadCont m => MonadCont (FreshMT m) Source # 

Methods

callCC :: ((a -> FreshMT m b) -> FreshMT m a) -> FreshMT m a

Monad m => Fresh (FreshMT m) Source # 

Methods

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

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.