ghc-8.8.3: The GHC API
Safe HaskellNone
LanguageHaskell2010

RtClosureInspect

Synopsis

Entry points and types

cvObtainTerm Source #

Arguments

:: HscEnv 
-> Int

How many times to recurse for subterms

-> Bool

Force thunks

-> RttiType

Type of the object to reconstruct

-> ForeignHValue

Object to reconstruct

-> IO Term 

Term reconstruction

Given a pointer to a heap object (HValue) and its type, build a Term representation of the object. Subterms (objects in the payload) are also built up to the given max_depth. After max_depth any subterms will appear as Suspensions. Any thunks found while traversing the object will be forced based on force parameter.

Types of terms will be refined based on constructors we find during term reconstruction. See cvReconstructType for an overview of how type reconstruction works.

cvReconstructType Source #

Arguments

:: HscEnv 
-> Int

How many times to recurse for subterms

-> GhciType

Type to refine

-> ForeignHValue

Refine the type using this value

-> IO (Maybe Type) 

Fast, breadth-first Type reconstruction

Given a heap object (HValue) and its (possibly polymorphic) type (usually obtained in GHCi), try to reconstruct a more monomorphic type of the object. This is used for improving type information in debugger. For example, if we have a polymorphic function:

sumNumList :: Num a => [a] -> a sumNumList [] = 0 sumNumList (x : xs) = x + sumList xs

and add a breakpoint to it:

ghci> break sumNumList ghci> sumNumList ([0 .. 9] :: [Int])

ghci shows us more precise types than just as:

Stopped in Main.sumNumList, debugger.hs:3:23-39 _result :: Int = _ x :: Int = 0 xs :: [Int] = _

improveRTTIType :: HscEnv -> RttiType -> RttiType -> Maybe TCvSubst Source #

data Term Source #

Constructors

Term 

Fields

Prim 

Fields

Suspension 

Fields

NewtypeWrap 

Fields

RefWrap 

Fields

Instances

Instances details
Outputable Term # 
Instance details

Defined in RtClosureInspect

Utils

termType :: Term -> RttiType Source #

mapTermType :: (RttiType -> Type) -> Term -> Term Source #

data TermFold a Source #

Constructors

TermFold 

Fields

cPprTerm :: Monad m => CustomTermPrinter m -> Term -> m SDoc Source #

Takes a list of custom printers with a explicit recursion knot and a term, and returns the output of the first successful printer, or the default printer

cPprTermBase :: forall m. Monad m => CustomTermPrinter m Source #