Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- data ASTMapper m = ASTMapper {
- mapOnExp :: ExpBase Info VName -> m (ExpBase Info VName)
- mapOnName :: VName -> m VName
- mapOnQualName :: QualName VName -> m (QualName VName)
- mapOnStructType :: StructType -> m StructType
- mapOnPatType :: PatType -> m PatType
- mapOnStructRetType :: StructRetType -> m StructRetType
- mapOnPatRetType :: PatRetType -> m PatRetType
- class ASTMappable x where
- identityMapper :: Monad m => ASTMapper m
- bareExp :: ExpBase Info VName -> ExpBase NoInfo VName
Documentation
Express a monad mapping operation on a syntax node. Each element of this structure expresses the operation to be performed on a given child.
ASTMapper | |
|
class ASTMappable x where Source #
The class of things that we can map an ASTMapper
across.
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.