HaRe-0.8.3.0: the Haskell Refactorer.

Safe HaskellNone
LanguageHaskell98

Language.Haskell.Refact.Utils.GhcUtils

Contents

Description

This module contains routines used to perform generic traversals of the GHC AST, avoiding the traps resulting from certain fields being populated with values defined to trigger an error if ever evaluated.

This is a useful feature for tracking down bugs in GHC, but makes use of the GHC library problematic.

Synopsis

SYB versions

everywhereM' :: Monad m => GenericM m -> GenericM m Source #

Monadic variation on everywhere'

everywhereMStaged' :: Monad m => Stage -> GenericM m -> GenericM m Source #

Monadic variation on everywhere'

everywhereStaged :: Stage -> (forall a. Data a => a -> a) -> forall a. Data a => a -> a Source #

Bottom-up transformation

everywhereStaged' :: Stage -> (forall a. Data a => a -> a) -> forall a. Data a => a -> a Source #

Top-down version of everywhereStaged

listifyStaged :: (Data a, Typeable a1) => Stage -> (a1 -> Bool) -> a -> [a1] Source #

Staged variation of SYB.listify The stage must be provided to avoid trying to modify elements which may not be present at all stages of AST processing.

SYB Utility

Scrap Your Zipper versions

zeverywhereStaged :: Typeable a => Stage -> GenericT -> Zipper a -> Zipper a Source #

Apply a generic transformation everywhere in a bottom-up manner.

zopenStaged :: Typeable a => Stage -> GenericQ Bool -> Zipper a -> [Zipper a] Source #

Open a zipper to the point where the Geneneric query passes. returns the original zipper if the query does not pass (check this)

zsomewhereStaged :: MonadPlus m => Stage -> GenericM m -> Zipper a -> m (Zipper a) Source #

Apply a generic monadic transformation once at the topmost leftmost successful location, avoiding holes in the GHC structures

transZ :: Stage -> GenericQ Bool -> (Stage -> Zipper a -> Zipper a) -> Zipper a -> Zipper a Source #

Transform a zipper opened with a given generic query

transZM :: Monad m => Stage -> GenericQ Bool -> (Stage -> Zipper a -> m (Zipper a)) -> Zipper a -> m (Zipper a) Source #

Monadic transform of a zipper opened with a given generic query

zopenStaged' :: Typeable a => Stage -> GenericQ (Maybe b) -> Zipper a -> [(Zipper a, b)] Source #

Open a zipper to the point where the Generic query passes, returning the zipper and a value from the specific part of the GenericQ that matched. This allows the components of the query to return a specific transformation routine, to apply to the returned zipper

ztransformStagedM :: (Typeable a, Monad m) => Stage -> GenericQ (Maybe (Stage -> Zipper a -> m (Zipper a))) -> Zipper a -> m (Zipper a) Source #

Open a zipper to the point where the Generic query passes, and apply the transformation returned from the specific part of the GenericQ that matched.

SYZ utilities

upUntil :: GenericQ Bool -> Zipper a -> Maybe (Zipper a) Source #

Climb the tree until a predicate holds

findAbove :: Data a => (a -> Bool) -> Zipper a -> Maybe a Source #

Up the zipper until a predicate holds, and then return the zipper hole