| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
Futhark.Builder
Description
This module defines a convenience monad/typeclass for building
 ASTs.  The fundamental building block is BuilderT and its
 execution functions, but it is usually easier to use Builder.
See Futhark.Construct for a high-level description.
Synopsis
- data BuilderT rep m a
- runBuilderT :: MonadFreshNames m => BuilderT rep m a -> Scope rep -> m (a, Stms rep)
- runBuilderT_ :: MonadFreshNames m => BuilderT rep m () -> Scope rep -> m (Stms rep)
- runBuilderT' :: (MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => BuilderT rep m a -> m (a, Stms rep)
- runBuilderT'_ :: (MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => BuilderT rep m a -> m (Stms rep)
- class ASTRep rep => BuilderOps rep where- mkExpDecB :: (MonadBuilder m, Rep m ~ rep) => Pat (LetDec rep) -> Exp rep -> m (ExpDec rep)
- mkBodyB :: (MonadBuilder m, Rep m ~ rep) => Stms rep -> Result -> m (Body rep)
- mkLetNamesB :: (MonadBuilder m, Rep m ~ rep) => [VName] -> Exp rep -> m (Stm rep)
 
- type Builder rep = BuilderT rep (State VNameSource)
- runBuilder :: (MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => Builder rep a -> m (a, Stms rep)
- runBuilder_ :: (MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => Builder rep a -> m (Stms rep)
- runBodyBuilder :: (Buildable rep, MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => Builder rep (Body rep) -> m (Body rep)
- runLambdaBuilder :: (Buildable rep, MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => [LParam rep] -> Builder rep Result -> m (Lambda rep)
- module Futhark.Builder.Class
A concrete MonadBuilder monad.
data BuilderT rep m a Source #
A monad transformer that tracks statements and provides a
 MonadBuilder instance, assuming that the underlying monad provides
 a name source.  In almost all cases, this is what you will use for
 constructing statements (possibly as part of a larger monad stack).
 If you find yourself needing to implement MonadBuilder from
 scratch, then it is likely that you are making a mistake.
Instances
runBuilderT :: MonadFreshNames m => BuilderT rep m a -> Scope rep -> m (a, Stms rep) Source #
Run a binder action given an initial scope, returning a value and
 the statements added (addStm) during the action.
runBuilderT_ :: MonadFreshNames m => BuilderT rep m () -> Scope rep -> m (Stms rep) Source #
Like runBuilderT, but return only the statements.
runBuilderT' :: (MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => BuilderT rep m a -> m (a, Stms rep) Source #
Like runBuilderT, but get the initial scope from the current
 monad.
runBuilderT'_ :: (MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => BuilderT rep m a -> m (Stms rep) Source #
Like runBuilderT_, but get the initial scope from the current
 monad.
class ASTRep rep => BuilderOps rep where Source #
A BuilderT (and by extension, a Builder) is only an instance of
 MonadBuilder for representations that implement this type class,
 which contains methods for constructing statements.
Minimal complete definition
Nothing
Methods
mkExpDecB :: (MonadBuilder m, Rep m ~ rep) => Pat (LetDec rep) -> Exp rep -> m (ExpDec rep) Source #
default mkExpDecB :: (MonadBuilder m, Buildable rep) => Pat (LetDec rep) -> Exp rep -> m (ExpDec rep) Source #
mkBodyB :: (MonadBuilder m, Rep m ~ rep) => Stms rep -> Result -> m (Body rep) Source #
mkLetNamesB :: (MonadBuilder m, Rep m ~ rep) => [VName] -> Exp rep -> m (Stm rep) Source #
default mkLetNamesB :: (MonadBuilder m, Rep m ~ rep, Buildable rep) => [VName] -> Exp rep -> m (Stm rep) Source #
Instances
runBuilder :: (MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => Builder rep a -> m (a, Stms rep) Source #
Run a binder action, returning a value and the statements added
 (addStm) during the action.  Assumes that the current monad
 provides initial scope and name source.
runBuilder_ :: (MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => Builder rep a -> m (Stms rep) Source #
Like runBuilder, but throw away the result and just return the
 added statements.
runBodyBuilder :: (Buildable rep, MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => Builder rep (Body rep) -> m (Body rep) Source #
runLambdaBuilder :: (Buildable rep, MonadFreshNames m, HasScope somerep m, SameScope somerep rep) => [LParam rep] -> Builder rep Result -> m (Lambda rep) Source #
Given lambda parameters, Run a builder action that produces the
 statements and returns the Result of the lambda body.
The MonadBuilder typeclass
module Futhark.Builder.Class