HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-heap-9.10.3Haskell2010

GHC.Exts.Heap.Closures

  • 13 types
  • 4 values
  • Packageghc-heap-9.10.3
  • Exports17
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceClosures.hs

Closures

8 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 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
valueclosureSize :: Box -> Int
#

Get the size of the top-level closure in words. Includes header and payload. Does not follow pointers.

Stack

6 declarations
datadata GenStgStackClosure b
#

A decoded StgStack with StackFrames

Stack related data structures (GenStgStackClosure, GenStackField, GenStackFrame) are defined separately from GenClosure as their related functions are very different. Though, both are closures in the sense of RTS structures, their decoding logic differs: While it's safe to keep a reference to a heap closure, the garbage collector does not update references to stack located closures.

Additionally, stack frames don't appear outside of the stack. Thus, keeping GenStackFrame and GenClosure separated, makes these types more precise (in the sense what values to expect.)

Instances6Functor, Foldable, Traversable, Show, Generic, Rep
datadata GenStackFrame b
#
Instances6Functor, Foldable, Traversable, Show, Generic, Rep
datadata GenStackField b
#

Bitmap-encoded payload on the stack

Constructors

Instances6Functor, Foldable, Traversable, Show, Generic, Rep

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
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.

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