Bringing some observable sharing to GHCi

Joachim Breitner mail at joachim-breitner.de
Sun Oct 29 22:10:58 UTC 2017


Hi,



Am Sonntag, den 29.10.2017, 16:40 -0400 schrieb David Feuer:
> 1. To be able to display cyclical data in some sensible way.
> 
> > x = "hi" : x
> > x `seq` ()
> > :print x
> 
> should print some useful representation of x.

the best that I know for this is the hack that calls itself ghc-heap-
view:

~ $ cabal install ghc-heap-view 
~ $ ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Prelude> :script .cabal/share/x86_64-linux-ghc-8.0.2/ghc-heap-view-0.5.10/ghci
Prelude> x = "hi" : x
Prelude> take 2 x
["hi","hi"]
Prelude> :printHeap x
let x1 = _bh (C# 'h' : _bh (C# 'i' : _bh [])) : _bh x1
in x1
Prelude> System.Mem.performGC
Prelude> :printHeap x
let x1 = "hi" : x1
in x1

A graphical front-end is ghc-vis:
http://felsin9.de/nnis/ghc-vis/

But it is mostly a hack and you should not expect a lot of reliability
of it. I’d love to see it supported by GHC proper. Erik de Castro Lopo
tried to merge it into GHC, but it seems to be very hard.

> 2. To be able to force cyclical data without looping.
> 
> > x = "hi" : x
> > :force x
> 

That could be implemented on top of ghc-heap-view.

Greetings,
Joachim

-- 
Joachim Breitner
  mail at joachim-breitner.de
  http://www.joachim-breitner.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20171029/a7d8e53f/attachment-0001.sig>


More information about the ghc-devs mailing list