futhark-0.9.1: An optimising compiler for a functional, array-oriented language.

Safe HaskellNone
LanguageHaskell2010

Futhark.MonadFreshNames

Description

This module provides a monadic facility similar (and built on top of) Futhark.FreshNames. The removes the need for a (small) amount of boilerplate, at the cost of using some GHC extensions. The idea is that if your compiler pass runs in a monad that is an instance of MonadFreshNames, you can automatically use the name generation functions exported by this module.

Synopsis

Documentation

class (Applicative m, Monad m) => MonadFreshNames m where Source #

A monad that stores a name source. The following is a good instance for a monad in which the only state is a NameSource vn:

 instance MonadFreshNames vn MyMonad where
   getNameSource = get
   putNameSource = put
Instances
MonadFreshNames PassM Source # 
Instance details

Defined in Futhark.Pass

MonadFreshNames FutharkM Source # 
Instance details

Defined in Futhark.Pipeline

MonadFreshNames TryFusion Source # 
Instance details

Defined in Futhark.Optimise.Fusion.TryFusion

MonadFreshNames InternaliseM Source # 
Instance details

Defined in Futhark.Internalise.Monad

MonadFreshNames m => MonadFreshNames (MaybeT m) Source # 
Instance details

Defined in Futhark.MonadFreshNames

MonadFreshNames (RuleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Rule

MonadFreshNames (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

(MonadFreshNames m, Monoid s) => MonadFreshNames (WriterT s m) Source # 
Instance details

Defined in Futhark.MonadFreshNames

(MonadFreshNames m, Monoid s) => MonadFreshNames (WriterT s m) Source # 
Instance details

Defined in Futhark.MonadFreshNames

(Applicative im, Monad im) => MonadFreshNames (StateT VNameSource im) Source # 
Instance details

Defined in Futhark.MonadFreshNames

(Applicative im, Monad im) => MonadFreshNames (StateT VNameSource im) Source # 
Instance details

Defined in Futhark.MonadFreshNames

MonadFreshNames m => MonadFreshNames (ExceptT e m) Source # 
Instance details

Defined in Futhark.MonadFreshNames

MonadFreshNames m => MonadFreshNames (BinderT lore m) Source # 
Instance details

Defined in Futhark.Binder

MonadFreshNames (ImpM lore op) Source # 
Instance details

Defined in Futhark.CodeGen.ImpGen

MonadFreshNames (CompilerM op s) Source # 
Instance details

Defined in Futhark.CodeGen.Backends.GenericC

MonadFreshNames (CompilerM op s) Source # 
Instance details

Defined in Futhark.CodeGen.Backends.GenericPython

MonadFreshNames (CompilerM op s) Source # 
Instance details

Defined in Futhark.CodeGen.Backends.GenericCSharp

MonadFreshNames m => MonadFreshNames (ReaderT s m) Source # 
Instance details

Defined in Futhark.MonadFreshNames

(Applicative im, Monad im, Monoid w) => MonadFreshNames (RWST r w VNameSource im) Source # 
Instance details

Defined in Futhark.MonadFreshNames

(Applicative im, Monad im, Monoid w) => MonadFreshNames (RWST r w VNameSource im) Source # 
Instance details

Defined in Futhark.MonadFreshNames

modifyNameSource :: MonadFreshNames m => (VNameSource -> (a, VNameSource)) -> m a Source #

Run a computation needing a fresh name source and returning a new one, using getNameSource and putNameSource before and after the computation.

newName :: MonadFreshNames m => VName -> m VName Source #

Produce a fresh name, using the given name as a template.

newNameFromString :: MonadFreshNames m => String -> m VName Source #

As newName, but takes a String for the name template.

newID :: MonadFreshNames m => Name -> m VName Source #

Produce a fresh ID, using the given base name as a template.

newIDFromString :: MonadFreshNames m => String -> m VName Source #

As newID, but takes a String for the name template.

newVName :: MonadFreshNames m => String -> m VName Source #

Produce a fresh VName, using the given base name as a template.

newVName' :: MonadFreshNames m => (String -> String) -> String -> m VName Source #

Produce a fresh VName, using the given name as a template, but possibly appending something more..

newIdent :: MonadFreshNames m => String -> Type -> m Ident Source #

Produce a fresh Ident, using the given name as a template.

newIdent' :: MonadFreshNames m => (String -> String) -> Ident -> m Ident Source #

Produce a fresh Ident, using the given Ident as a template, but possibly modifying the name.

newIdents :: MonadFreshNames m => String -> [Type] -> m [Ident] Source #

Produce several Idents, using the given name as a template, based on a list of types.

newParam :: MonadFreshNames m => String -> attr -> m (Param attr) Source #

Produce a fresh ParamT, using the given name as a template.

newParam' :: MonadFreshNames m => (String -> String) -> Param attr -> m (Param attr) Source #

Produce a fresh ParamT, using the given ParamT as a template, but possibly modifying the name.

data VNameSource Source #

A name source is conceptually an infinite sequence of names with no repeating entries. In practice, when asked for a name, the name source will return the name along with a new name source, which should then be used in place of the original.

The Ord instance is based on how many names have been extracted from the name source.

Instances
Eq VNameSource Source # 
Instance details

Defined in Futhark.FreshNames

Ord VNameSource Source # 
Instance details

Defined in Futhark.FreshNames

Semigroup VNameSource Source # 
Instance details

Defined in Futhark.FreshNames

Monoid VNameSource Source # 
Instance details

Defined in Futhark.FreshNames

Lift VNameSource Source # 
Instance details

Defined in Futhark.FreshNames

Methods

lift :: VNameSource -> Q Exp #

MonadState VNameSource TypeM Source # 
Instance details

Defined in Language.Futhark.TypeChecker.Monad

(Applicative im, Monad im) => MonadFreshNames (StateT VNameSource im) Source # 
Instance details

Defined in Futhark.MonadFreshNames

(Applicative im, Monad im) => MonadFreshNames (StateT VNameSource im) Source # 
Instance details

Defined in Futhark.MonadFreshNames

MonadState (VNameSource, Bool) (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

get :: SimpleM lore (VNameSource, Bool) #

put :: (VNameSource, Bool) -> SimpleM lore () #

state :: ((VNameSource, Bool) -> (a, (VNameSource, Bool))) -> SimpleM lore a #

(Applicative im, Monad im, Monoid w) => MonadFreshNames (RWST r w VNameSource im) Source # 
Instance details

Defined in Futhark.MonadFreshNames

(Applicative im, Monad im, Monoid w) => MonadFreshNames (RWST r w VNameSource im) Source # 
Instance details

Defined in Futhark.MonadFreshNames

blankNameSource :: VNameSource Source #

A blank name source.

newNameSource :: Int -> VNameSource Source #

A new name source that starts counting from the given number.

newVNameFromName :: VNameSource -> Name -> (VName, VNameSource) Source #

Produce a fresh VName, using the given base name as a template.