The ghc-heap-view package

[Tags:bsd3, library, test]

This library provides functions to introspect the Haskell heap, for example to investigate sharing and lazy evaluation. As this is tied to the internals of the compiler,it only works with specific versions. Currently, GHC 7.4 through 7.10 should be supported.

It has been inspired by (and taken code from) the vacuum package and the GHCi debugger, but also allows to investiage thunks and other closures.

This package also provides a new GHCi-command, :printHeap, which allows you to inspect the current heap representation of a value, including sharing and cyclic references. To enable the command, you need to load the included ghci script or add it to ~/.ghci, as explained by cabal install. Once it is set up, you can do this:

> let value = "A Value"
> let x = (value, if head value == 'A' then value else "", cycle [True, False])
> :printHeap x
let x1 = _bco
    x21 = []
in (x1,_bco,_bco)
> length (take 100 (show x)) `seq` return () -- evaluate everything
> :printHeap x
let x1 = "A Value"
    x16 = True : False : x16
in (x1,x1,x16)

You can change the maximum recursion depth using :setPrintHeapDepth:

> :setPrintHeapDepth 3
> :printHeap x
let x1 = C# 'A' : ... : ...
in (x1,x1,True : ... : ...)

If the view is impaired by blackholes (written _bh), running System.Mem.performGC usually helps.

The work on this package has been supported by the Deutsche Telekom Stiftung (


Versions 0.1, 0.2, 0.3,,,,,,,, 0.5,, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.6, 0.5.7
Dependencies base (>=4.5 && <4.10), binary, bytestring (>=0.10), containers, ghc, template-haskell, transformers [details]
License BSD3
Copyright 2012-2014 Joachim Breitner
Author Joachim Breitner, Dennis Felsing
Maintainer Joachim Breitner <>
Stability Unknown
Category Debug, GHC
Bug tracker
Source repository head: git clone git://
Uploaded Wed Jun 8 09:32:26 UTC 2016 by JoachimBreitner
Distributions LTSHaskell:0.5.7, NixOS:0.5.7, Stackage:0.5.7, Tumbleweed:0.5.7
Downloads 4371 total (61 in the last 30 days)
0 []
Status Docs available [build log]
Last success reported on 2016-06-08 [all 1 reports]




prim-supports-anyThe used GHC supports Any as an argument to foreign prim functions (GHC ticket #5931)DisabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees