HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-heap-9.10.3Haskell2010

GHC.Exts.Heap

With this module, you can investigate the heap representation of Haskell values, i.e. to investigate sharing and lazy evaluation.

  • 16 types
  • 1 class
  • 9 values
  • Packageghc-heap-9.10.3
  • Exports26
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceHeap.hs

Closure types

10 declarations
datadata GenClosure b
#

This is the representation of a Haskell value on the heap. It reflects https://gitlab.haskell.org/ghc/ghc/blob/master/rts/include/rts/storage/Closures.h

The data type is parametrized by b: the type to store references in. Usually this is a Box with the type synonym Closure.

All Heap objects have the same basic layout. A header containing a pointer to the info table and a payload with various fields. The info field below always refers to the info table pointed to by the header. The remaining fields are the payload.

See https://gitlab.haskell.org/ghc/ghc/wikis/commentary/rts/storage/heap-objects for more information.

Constructors

Instances6Functor, Foldable, Traversable, Show, Generic, Rep
datadata ClosureType
#
Instances6Enum, Eq, Ord, Show, Generic, Rep
datadata PrimType
#
Instances5Eq, Ord, Show, Generic, Rep
datadata WhatNext
#
Instances5Eq, Ord, Show, Generic, Rep
datadata WhyBlocked
#
Instances5Eq, Ord, Show, Generic, Rep
datadata TsoFlags
#
Instances5Eq, Ord, Show, Generic, Rep
classclass HasHeapRep (a :: TYPE rep) where
#

Methods

Instances9HasHeapRep, …
valuegetClosureDataFromHeapRepPrim
  1. :: IO (String, String, String)

    A continuation used to decode the constructor description field, in ghc-debug this code can lead to segfaults because dataConNames will dereference a random part of memory.

  2. -> (Ptr a -> IO (Maybe CostCentreStack))

    A continuation which is used to decode a cost centre stack In ghc-debug, this code will need to call back into the debuggee to fetch the representation of the CCS before decoding it. Using peekTopCCS for this argument can lead to segfaults in ghc-debug as the CCS argument will point outside the copied closure.

  3. -> StgInfoTable

    The StgInfoTable of the closure, extracted from the heap representation.

  4. -> ByteArray#

    Heap representation of the closure as returned by unpackClosure#. This includes all of the object including the header, info table pointer, pointer data, and non-pointer data. The ByteArray# may be pinned or unpinned.

  5. -> [b]

    Pointers in the payload of the closure, extracted from the heap representation as returned by `collect_pointers()` in Heap.c. The type b is some representation of a pointer e.g. Any or `Ptr Any`.

  6. -> IO (GenClosure b)

    Heap representation of the closure.

#

Info Table types

7 declarations
datadata StgInfoTable
#

This is a somewhat faithful representation of an info table. See https://gitlab.haskell.org/ghc/ghc/blob/master/rts/include/rts/storage/InfoTables.h for more details on this data structure.

Instances4Eq, Show, Generic, Rep
valueitblSize :: Int
#

Size in bytes of a standard InfoTable

Read an InfoTable from the heap into a haskell type. WARNING: This code assumes it is passed a pointer to a "standard" info table. If tables_next_to_code is enabled, it will look 1 byte before the start for the entry field.

Cost Centre (profiling) types

4 declarations
newtypenewtype StgTSOProfInfo
#

This is a somewhat faithful representation of StgTSOProfInfo. See https://gitlab.haskell.org/ghc/ghc/blob/master/rts/include/rts/storage/TSO.h for more details on this data structure.

Instances5Eq, Ord, Show, Generic, Rep
datadata IndexTable
#

This is a somewhat faithful representation of IndexTable. See https://gitlab.haskell.org/ghc/ghc/blob/master/rts/include/rts/prof/CCS.h for more details on this data structure.

Instances5Eq, Ord, Show, Generic, Rep
datadata CostCentre
#

This is a somewhat faithful representation of CostCentre. See https://gitlab.haskell.org/ghc/ghc/blob/master/rts/include/rts/prof/CCS.h for more details on this data structure.

Instances5Eq, Ord, Show, Generic, Rep
datadata CostCentreStack
#
Instances5Eq, Ord, Show, Generic, Rep

Closure inspection

2 declarations

Boxes

3 declarations
datadata Box
#

An arbitrary Haskell value in a safe Box. The point is that even unevaluated thunks can safely be moved around inside the Box, and when required, e.g. in getBoxedClosureData, the function knows how far it has to evaluate the argument.

Constructors

Instances1Show
  • Show BoxDefined in ghc-heap-9.10.3 · GHC.Exts.Heap.Closures
valueasBox :: a -> Box
#

This takes an arbitrary value and puts it into a box. Note that calls like

asBox (head list)

will put the thunk "head list" into the box, not the element at the head of the list. For that, use careful case expressions:

case list of x:_ -> asBox x
valueareBoxesEqual :: Box -> Box -> IO Bool
#

Boxes can be compared, but this is not pure, as different heap objects can, after garbage collection, become the same object.