Safe Haskell | None |
---|

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.

- everythingButStaged :: Stage -> (r -> r -> r) -> r -> GenericQ (r, Bool) -> GenericQ r
- somethingStaged :: Stage -> Maybe u -> GenericQ (Maybe u) -> GenericQ (Maybe u)
- everythingStaged :: Stage -> (r -> r -> r) -> r -> GenericQ r -> GenericQ r
- somewhereMStaged :: MonadPlus m => Stage -> GenericM m -> GenericM m
- somewhereMStagedBu :: MonadPlus m => Stage -> GenericM m -> GenericM m
- everywhereMStaged :: Monad m => Stage -> GenericM m -> GenericM m
- everywhereMStaged' :: Monad m => Stage -> GenericM m -> GenericM m
- everywhereStaged :: Stage -> (forall a. Data a => a -> a) -> forall a. Data a => a -> a
- everywhereStaged' :: Stage -> (forall a. Data a => a -> a) -> forall a. Data a => a -> a
- listifyStaged :: (Data a, Typeable a1) => Stage -> (a1 -> Bool) -> a -> [a1]
- checkItemRenamer :: (Data a, Typeable a) => a -> Bool
- full_tdTUGhc :: (MonadPlus m, Monoid a) => TU a m -> TU a m
- stop_tdTUGhc :: (MonadPlus m, Monoid a) => TU a m -> TU a m
- allTUGhc' :: (MonadPlus m, Monoid a) => TU a m -> TU a m
- once_tdTPGhc :: MonadPlus m => TP m -> TP m
- once_buTPGhc :: MonadPlus m => TP m -> TP m
- oneTPGhc :: MonadPlus m => TP m -> TP m
- allTUGhc :: MonadPlus m => (a -> a -> a) -> a -> TU a m -> TU a m
- checkItemStage' :: forall m. MonadPlus m => Stage -> TU () m
- checkItemRenamer' :: MonadPlus m => TU () m
- zeverywhereStaged :: Typeable a => Stage -> GenericT -> Zipper a -> Zipper a
- zopenStaged :: Typeable a => Stage -> GenericQ Bool -> Zipper a -> [Zipper a]
- zsomewhereStaged :: MonadPlus m => Stage -> GenericM m -> Zipper a -> m (Zipper a)
- transZ :: Stage -> GenericQ Bool -> (Stage -> Zipper a -> Zipper a) -> Zipper a -> Zipper a
- transZM :: Monad m => Stage -> GenericQ Bool -> (Stage -> Zipper a -> m (Zipper a)) -> Zipper a -> m (Zipper a)
- zopenStaged' :: Typeable a => Stage -> GenericQ (Maybe b) -> Zipper a -> [(Zipper a, b)]
- ztransformStagedM :: (Typeable a, Monad m) => Stage -> GenericQ (Maybe (Stage -> Zipper a -> m (Zipper a))) -> Zipper a -> m (Zipper a)
- checkZipperStaged :: Stage -> Zipper a -> Bool
- upUntil :: GenericQ Bool -> Zipper a -> Maybe (Zipper a)
- findAbove :: Data a => (a -> Bool) -> Zipper a -> Maybe a

# SYB versions

somethingStaged :: Stage -> Maybe u -> GenericQ (Maybe u) -> GenericQ (Maybe u)Source

Look up a subterm by means of a maybe-typed filter

everythingStaged :: Stage -> (r -> r -> r) -> r -> GenericQ r -> GenericQ rSource

Staged variation of SYB.everything The stage must be provided to avoid trying to modify elements which may not be present at all stages of AST processing. Note: Top-down order

somewhereMStaged :: MonadPlus m => Stage -> GenericM m -> GenericM mSource

Apply a monadic transformation at least somewhere

somewhereMStagedBu :: MonadPlus m => Stage -> GenericM m -> GenericM mSource

Apply a monadic transformation at least somewhere, in bottom up order

everywhereMStaged :: Monad m => Stage -> GenericM m -> GenericM mSource

Monadic variation on everywhere

everywhereMStaged' :: Monad m => Stage -> GenericM m -> GenericM mSource

Monadic variation on everywhere'

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

Bottom-up transformation

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

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

checkItemRenamer :: (Data a, Typeable a) => a -> BoolSource

# Strafunski StrategyLib versions

full_tdTUGhc :: (MonadPlus m, Monoid a) => TU a m -> TU a mSource

Full type-unifying traversal in top-down order.

stop_tdTUGhc :: (MonadPlus m, Monoid a) => TU a m -> TU a mSource

Top-down type-unifying traversal that is cut of below nodes where the argument strategy succeeds.

once_tdTPGhc :: MonadPlus m => TP m -> TP mSource

Top-down type-preserving traversal that performs its argument strategy at most once.

once_buTPGhc :: MonadPlus m => TP m -> TP mSource

Bottom-up type-preserving traversal that performs its argument strategy at most once.

## Strafunski utility

checkItemStage' :: forall m. MonadPlus m => Stage -> TU () mSource

checkItemRenamer' :: MonadPlus m => TU () mSource

# Scrap Your Zipper versions

zeverywhereStaged :: Typeable a => Stage -> GenericT -> Zipper a -> Zipper aSource

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 aSource

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

checkZipperStaged :: Stage -> Zipper a -> BoolSource