Safe Haskell | None |
---|---|
Language | Haskell2010 |
GHC.Syb.Utils provides common utilities for the Ghc Api, either based on Data/Typeable or for use with Data.Generics over Ghc Api types.
Synopsis
- data Stage
- = Parser
- | Renamer
- | TypeChecker
- everythingStaged :: Stage -> (r -> r -> r) -> r -> GenericQ r -> GenericQ r
- everythingButStaged :: Stage -> (r -> r -> r) -> r -> GenericQ (r, Bool) -> GenericQ r
- somethingStaged :: Stage -> Maybe u -> GenericQ (Maybe u) -> GenericQ (Maybe u)
- somewhereStaged :: MonadPlus m => Stage -> GenericM m -> GenericM m
- everywhereMStaged :: Monad m => Stage -> GenericM m -> GenericM m
Documentation
Ghc Ast types tend to have undefined holes, to be filled by later compiler phases. We tag Asts with their source, so that we can avoid such holes based on who generated the Asts.
everythingStaged :: Stage -> (r -> r -> r) -> r -> GenericQ r -> GenericQ r Source #
Like everything
, but avoid known potholes, based on the Stage
that
generated the Ast.
everythingButStaged :: Stage -> (r -> r -> r) -> r -> GenericQ (r, Bool) -> GenericQ r Source #
A variation of everything
, using a 'GenericQ Bool' to skip
parts of the input Data
.
everythingBut :: GenericQ Bool -> (r -> r -> r) -> r -> GenericQ r -> GenericQ r
everythingBut q k z f x
| q x = z
| otherwise = foldl k (f x) (gmapQ (everythingBut q k z f) x)
somethingStaged :: Stage -> Maybe u -> GenericQ (Maybe u) -> GenericQ (Maybe u) Source #
Look up a subterm by means of a maybe-typed filter.
somewhereStaged :: MonadPlus m => Stage -> GenericM m -> GenericM m Source #
Apply a monadic transformation at least somewhere.
The transformation is tried in a top-down manner and descends down if it fails to apply at the root of the term. If the transformation fails to apply anywhere within the the term, the whole operation fails.