ghc-syb-utils-0.3.0.0: Scrap Your Boilerplate utilities for the GHC API.
Safe HaskellNone
LanguageHaskell2010

GHC.SYB.Utils

Description

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

Documentation

data Stage Source #

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.

Constructors

Parser 
Renamer 
TypeChecker 

Instances

Instances details
Eq Stage Source # 
Instance details

Defined in GHC.SYB.Utils

Methods

(==) :: Stage -> Stage -> Bool

(/=) :: Stage -> Stage -> Bool

Ord Stage Source # 
Instance details

Defined in GHC.SYB.Utils

Methods

compare :: Stage -> Stage -> Ordering

(<) :: Stage -> Stage -> Bool

(<=) :: Stage -> Stage -> Bool

(>) :: Stage -> Stage -> Bool

(>=) :: Stage -> Stage -> Bool

max :: Stage -> Stage -> Stage

min :: Stage -> Stage -> Stage

Show Stage Source # 
Instance details

Defined in GHC.SYB.Utils

Methods

showsPrec :: Int -> Stage -> ShowS

show :: Stage -> String

showList :: [Stage] -> ShowS

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.

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

Monadic variation on everywhere