futhark-0.15.5: An optimising compiler for a functional, array-oriented language.
Safe HaskellNone
LanguageHaskell2010

Language.Futhark.Traversals

Description

Functions for generic traversals across Futhark syntax trees. The motivation for this module came from dissatisfaction with rewriting the same trivial tree recursions for every module. A possible alternative would be to use normal "Scrap your boilerplate"-techniques, but these are rejected for two reasons:

  • They are too slow.
  • More importantly, they do not tell you whether you have missed some cases.

Instead, this module defines various traversals of the Futhark syntax tree. The implementation is rather tedious, but the interface is easy to use.

A traversal of the Futhark syntax tree is expressed as a record of functions expressing the operations to be performed on the various types of nodes.

Synopsis

Documentation

data ASTMapper m Source #

Express a monad mapping operation on a syntax node. Each element of this structure expresses the operation to be performed on a given child.

class ASTMappable x where Source #

Methods

astMap :: Monad m => ASTMapper m -> x -> m x Source #

Map a monadic action across the immediate children of an object. Importantly, the astMap action is not invoked for the object itself, and the mapping does not descend recursively into subexpressions. The mapping is done left-to-right.

Instances

Instances details
ASTMappable StructType Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable PatternType Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable Aliasing Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> Aliasing -> m Aliasing Source #

ASTMappable Alias Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> Alias -> m Alias Source #

ASTMappable a => ASTMappable [a] Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> [a] -> m [a] Source #

ASTMappable a => ASTMappable (NonEmpty a) Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> NonEmpty a -> m (NonEmpty a) Source #

ASTMappable (TypeParamBase VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (TypeArgExp VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (TypeExp VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> TypeExp VName -> m (TypeExp VName) Source #

ASTMappable (DimExp VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> DimExp VName -> m (DimExp VName) Source #

ASTMappable (DimDecl VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> DimDecl VName -> m (DimDecl VName) Source #

ASTMappable a => ASTMappable (Info a) Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> Info a -> m (Info a) Source #

(ASTMappable a, ASTMappable b) => ASTMappable (a, b) Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> (a, b) -> m (a, b) Source #

ASTMappable (PatternBase Info VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (LoopFormBase Info VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (CaseBase Info VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (FieldBase Info VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (ExpBase Info VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (DimIndexBase Info VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (IdentBase Info VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

ASTMappable (TypeDeclBase Info VName) Source # 
Instance details

Defined in Language.Futhark.Traversals

(ASTMappable a, ASTMappable b, ASTMappable c) => ASTMappable (a, b, c) Source # 
Instance details

Defined in Language.Futhark.Traversals

Methods

astMap :: Monad m => ASTMapper m -> (a, b, c) -> m (a, b, c) Source #

identityMapper :: Monad m => ASTMapper m Source #

An ASTMapper that just leaves its input unchanged.

bareExp :: ExpBase Info VName -> ExpBase NoInfo VName Source #

Remove all annotations from an expression, but retain the name/scope information.