Bringing some observable sharing to GHCi

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Bringing some observable sharing to GHCi

David Feuer
The :sprint, :print, and :force commands in GHCi fall into infinite
loops when confronted by cyclical data. This bit me hard in
https://phabricator.haskell.org/D4085 because that produces cyclical
TypeReps, which is trouble for (e.g.) the test break011 which tries to
:force a SomeException (which wraps an Exception dictionary, which has
a Typeable constraint). I could try coming up with a fix myself, but
I'm rather curious whether some of the work you (or others) have
already done on observing GHC data graphs could be yanked into GHCi
itself for this purpose. We want

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.

2. To be able to force cyclical data without looping.

> x = "hi" : x
> :force x

should print a useful representation of x.
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Bringing some observable sharing to GHCi

Joachim Breitner-2
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
  [hidden email]
  http://www.joachim-breitner.de/

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Bringing some observable sharing to GHCi

Simon Marlow-7
In reply to this post by David Feuer
Not being able to :print an exception would be quite annoying. Do TypeReps need to be cyclic?

Observable sharing can be done with StableName, but that would be a bit pile of hassle in the printer. Maybe exceptions warrant a special case.

Cheers
Simon

On 29 October 2017 at 20:40, David Feuer <[hidden email]> wrote:
The :sprint, :print, and :force commands in GHCi fall into infinite
loops when confronted by cyclical data. This bit me hard in
https://phabricator.haskell.org/D4085 because that produces cyclical
TypeReps, which is trouble for (e.g.) the test break011 which tries to
:force a SomeException (which wraps an Exception dictionary, which has
a Typeable constraint). I could try coming up with a fix myself, but
I'm rather curious whether some of the work you (or others) have
already done on observing GHC data graphs could be yanked into GHCi
itself for this purpose. We want

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.

2. To be able to force cyclical data without looping.

> x = "hi" : x
> :force x

should print a useful representation of x.
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

RE: Bringing some observable sharing to GHCi

GHC - devs mailing list

Do TypeReps need to be cyclic?

 

No – I think David is working on a non-cyclic version

 

Simon

 

From: ghc-devs [mailto:[hidden email]] On Behalf Of Simon Marlow
Sent: 02 November 2017 10:27
To: David Feuer <[hidden email]>
Cc: Joachim Breitner <[hidden email]>; ghc-devs <[hidden email]>
Subject: Re: Bringing some observable sharing to GHCi

 

Not being able to :print an exception would be quite annoying. Do TypeReps need to be cyclic?

 

Observable sharing can be done with StableName, but that would be a bit pile of hassle in the printer. Maybe exceptions warrant a special case.

 

Cheers

Simon

 

On 29 October 2017 at 20:40, David Feuer <[hidden email]> wrote:

The :sprint, :print, and :force commands in GHCi fall into infinite
loops when confronted by cyclical data. This bit me hard in
https://phabricator.haskell.org/D4085 because that produces cyclical
TypeReps, which is trouble for (e.g.) the test break011 which tries to
:force a SomeException (which wraps an Exception dictionary, which has
a Typeable constraint). I could try coming up with a fix myself, but
I'm rather curious whether some of the work you (or others) have
already done on observing GHC data graphs could be yanked into GHCi
itself for this purpose. We want

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.

2. To be able to force cyclical data without looping.

> x = "hi" : x
> :force x

should print a useful representation of x.
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

 


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs