ghc-7.0.1: The GHC API

CoreMonad

Contents

Synopsis

Configuration of the core-to-core passes

data SimplifierMode

Constructors

SimplGently 

Fields

sm_rules :: Bool
 
sm_inline :: Bool
 
SimplPhase 

Fields

sm_num :: Int
 
sm_names :: [String]
 

data FloatOutSwitches

Constructors

FloatOutSwitches 

Fields

floatOutLambdas :: Bool

True = float lambdas to top level

floatOutConstants :: Bool

True = float constants to top level, even if they do not escape a lambda

floatOutPartialApplications :: Bool

True = float out partial applications based on arity information.

getCoreToDo :: DynFlags -> [CoreToDo]

Switches that specify the minimum amount of floating out gentleFloatOutSwitches :: FloatOutSwitches gentleFloatOutSwitches = FloatOutSwitches False False

Counting

The monad

data CoreM a

The monad used by Core-to-Core passes to access common state, register simplification statistics and so on

Reading from the monad

getOrigNameCache :: CoreM OrigNameCache

The original name cache is the current mapping from Module and OccName to a compiler-wide unique Name

Writing to the monad

Lifting into the monad

liftIO :: MonadIO m => IO a -> m a

liftIOWithCount :: IO (SimplCount, a) -> CoreM a

Lift an IO operation into CoreM while consuming its SimplCount

liftIO1 :: MonadIO m => (a -> IO b) -> a -> m b

Lift an IO operation with 1 argument into another monad

liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c

Lift an IO operation with 2 arguments into another monad

liftIO3 :: MonadIO m => (a -> b -> c -> IO d) -> a -> b -> c -> m d

Lift an IO operation with 3 arguments into another monad

liftIO4 :: MonadIO m => (a -> b -> c -> d -> IO e) -> a -> b -> c -> d -> m e

Lift an IO operation with 4 arguments into another monad

Dealing with annotations

getAnnotations :: Typeable a => ([Word8] -> a) -> ModGuts -> CoreM (UniqFM [a])

Get all annotations of a given type. This happens lazily, that is no deserialization will take place until the [a] is actually demanded and the [a] can also be empty (the UniqFM is not filtered).

This should be done once at the start of a Core-to-Core pass that uses annotations.

See Note [Annotations]

getFirstAnnotations :: Typeable a => ([Word8] -> a) -> ModGuts -> CoreM (UniqFM a)

Get at most one annotation of a given type per Unique.

Debug output

dumpIfSet :: Bool -> CoreToDo -> SDoc -> SDoc -> IO ()

Screen output

putMsg :: SDoc -> CoreM ()

Output a message to the screen

putMsgS :: String -> CoreM ()

Output a String message to the screen

errorMsg :: SDoc -> CoreM ()

Output an error to the screen

errorMsgS :: String -> CoreM ()

Output a string error to the screen

fatalErrorMsg :: SDoc -> CoreM ()

Output a fatal error to the screen. Note this does not by itself cause the compiler to die

fatalErrorMsgS :: String -> CoreM ()

Output a fatal string error to the screen. Note this does not by itself cause the compiler to die

debugTraceMsg :: SDoc -> CoreM ()

Outputs a debugging message at verbosity level of -v or higher

debugTraceMsgS :: String -> CoreM ()

Output a string debugging message at verbosity level of -v or higher

dumpIfSet_dyn :: DynFlag -> String -> SDoc -> CoreM ()

Show some labelled SDoc if a particular flag is set or at a verbosity level of -v -ddump-most or higher

Getting Names

thNameToGhcName :: Name -> CoreM (Maybe Name)

Attempt to convert a Template Haskell name to one that GHC can understand. Original TH names such as those you get when you use the 'foo syntax will be translated to their equivalent GHC name exactly. Qualified or unqualifed TH names will be dynamically bound to names in the module being compiled, if possible. Exact TH names will be bound to the name they represent, exactly.