Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines a convenience typeclass for creating normalised programs.
See Futhark.Construct for a high-level description.
Synopsis
- class (ASTRep rep, FParamInfo rep ~ DeclType, LParamInfo rep ~ Type, RetType rep ~ DeclExtType, BranchType rep ~ ExtType, SetType (LetDec rep)) => Bindable rep where
- mkLet :: Bindable rep => [Ident] -> [Ident] -> Exp rep -> Stm rep
- mkLet' :: Bindable rep => [Ident] -> [Ident] -> StmAux a -> Exp rep -> Stm rep
- class (ASTRep (Rep m), MonadFreshNames m, Applicative m, Monad m, LocalScope (Rep m) m) => MonadBinder m where
- type Rep m :: Type
- mkExpDecM :: Pattern (Rep m) -> Exp (Rep m) -> m (ExpDec (Rep m))
- mkBodyM :: Stms (Rep m) -> Result -> m (Body (Rep m))
- mkLetNamesM :: [VName] -> Exp (Rep m) -> m (Stm (Rep m))
- addStm :: Stm (Rep m) -> m ()
- addStms :: Stms (Rep m) -> m ()
- collectStms :: m a -> m (a, Stms (Rep m))
- certifying :: Certificates -> m a -> m a
- insertStms :: Bindable rep => Stms rep -> Body rep -> Body rep
- insertStm :: Bindable rep => Stm rep -> Body rep -> Body rep
- letBind :: MonadBinder m => Pattern (Rep m) -> Exp (Rep m) -> m ()
- letBindNames :: MonadBinder m => [VName] -> Exp (Rep m) -> m ()
- collectStms_ :: MonadBinder m => m a -> m (Stms (Rep m))
- bodyBind :: MonadBinder m => Body (Rep m) -> m [SubExp]
- attributing :: MonadBinder m => Attrs -> m a -> m a
- auxing :: MonadBinder m => StmAux anyrep -> m a -> m a
- module Futhark.MonadFreshNames
Documentation
class (ASTRep rep, FParamInfo rep ~ DeclType, LParamInfo rep ~ Type, RetType rep ~ DeclExtType, BranchType rep ~ ExtType, SetType (LetDec rep)) => Bindable rep where Source #
The class of representations that can be constructed solely from
an expression, within some monad. Very important: the methods
should not have any significant side effects! They may be called
more often than you think, and the results thrown away. If used
exclusively within a MonadBinder
instance, it is acceptable for
them to create new bindings, however.
mkExpPat :: [Ident] -> [Ident] -> Exp rep -> Pattern rep Source #
mkExpDec :: Pattern rep -> Exp rep -> ExpDec rep Source #
mkBody :: Stms rep -> Result -> Body rep Source #
mkLetNames :: (MonadFreshNames m, HasScope rep m) => [VName] -> Exp rep -> m (Stm rep) Source #
Instances
mkLet :: Bindable rep => [Ident] -> [Ident] -> Exp rep -> Stm rep Source #
Construct a Stm
from identifiers for the context- and value
part of the pattern, as well as the expression.
mkLet' :: Bindable rep => [Ident] -> [Ident] -> StmAux a -> Exp rep -> Stm rep Source #
Like mkLet, but also take attributes and certificates from the
given StmAux
.
class (ASTRep (Rep m), MonadFreshNames m, Applicative m, Monad m, LocalScope (Rep m) m) => MonadBinder m where Source #
A monad that supports the creation of bindings from expressions
and bodies from bindings, with a specific rep. This is the main
typeclass that a monad must implement in order for it to be useful
for generating or modifying Futhark code. Most importantly
maintains a current state of Stms
(as well as a Scope
) that
have been added with addStm
.
Very important: the methods should not have any significant side effects! They may be called more often than you think, and the results thrown away. It is acceptable for them to create new bindings, however.
mkExpDecM :: Pattern (Rep m) -> Exp (Rep m) -> m (ExpDec (Rep m)) Source #
mkBodyM :: Stms (Rep m) -> Result -> m (Body (Rep m)) Source #
mkLetNamesM :: [VName] -> Exp (Rep m) -> m (Stm (Rep m)) Source #
addStm :: Stm (Rep m) -> m () Source #
Add a statement to the Stms
under construction.
addStms :: Stms (Rep m) -> m () Source #
Add multiple statements to the Stms
under construction.
collectStms :: m a -> m (a, Stms (Rep m)) Source #
Obtain the statements constructed during a monadic action, instead of adding them to the state.
certifying :: Certificates -> m a -> m a Source #
Add the provided certificates to any statements added during execution of the action.
Instances
insertStms :: Bindable rep => Stms rep -> Body rep -> Body rep Source #
Add several bindings at the outermost level of a Body
.
insertStm :: Bindable rep => Stm rep -> Body rep -> Body rep Source #
Add a single binding at the outermost level of a Body
.
letBind :: MonadBinder m => Pattern (Rep m) -> Exp (Rep m) -> m () Source #
Add a statement with the given pattern and expression.
letBindNames :: MonadBinder m => [VName] -> Exp (Rep m) -> m () Source #
Add a statement with the given pattern element names and expression.
collectStms_ :: MonadBinder m => m a -> m (Stms (Rep m)) Source #
As collectStms
, but throw away the ordinary result.
bodyBind :: MonadBinder m => Body (Rep m) -> m [SubExp] Source #
Add the statements of the body, then return the body result.
attributing :: MonadBinder m => Attrs -> m a -> m a Source #
Add the given attributes to any statements added by this action.
auxing :: MonadBinder m => StmAux anyrep -> m a -> m a Source #
Add the certificates and attributes to any statements added by this action.
module Futhark.MonadFreshNames