Dennis Felsing | 4 Dec 16:23 2012
Picon

Extending GHCi

Hi!

I'm currently trying to extend ghc-vis[1], a tool to visualize live data
structures in GHCi and GHC compiled programs, similar to GHCi's :print and
vacuum.

I want to show the type of a subexpression visualized in ghc-vis. As types
aren't stored in GHC they have to be reconstructed. For this I need read access
to internal GHC(i) information, like the type of data constructors. Type
reconstruction is already happening inside GHCi's debugger[2].

Another concern is having a feature for binding a subexpression to a GHCi
variable, so that it appears in ":show bindings" and can be used within the
current GHCi session.

To me it seems like neither is currently possible from a program running within
GHCi. Therefore I just started an extensible GHCi, called eGHCi[3]. So far it
should compile on GHC 7.4.2 and 7.6.1, but does nothing else than the regular
GHCi. I took the relevant files to compile my own GHCi binary from the
corresponding GHC versions, just as ghci-haskeline[4] did before.

In order to get type reconstruction and bindings running I'm planning to
provide a function

> runInGhci :: GhciMonad a -> IO a

which enables programs running in eGHCi to run commands inside the GhciMonad.

Another change I'm planning is a function

(Continue reading)

Simon Hengel | 4 Dec 16:56 2012
Picon

Re: Extending GHCi

> Now I'm wondering whether the approaches I have in mind are sensible or if
> anyone can think of a better way to achieve my goals? Is there a way to extend
> GHCi without copying some of its source code? Is there a chance of having these
> features flow back into mainline GHCi once they are properly implemented?

I can't really help here.  But I'm interested in more powerful ways to
extend GHCi, too.  I'm mostly interested in things that will speedup
development (e.g. Hoogle tab-completion, integration of testing tools).

I think once we have a more powerful API to hook things into a running
GHCi, people will create useful things that you wouldn't have imagined
beforehand.

Cheers,
Simon
Ian Lynagh | 6 Dec 19:20 2012

Re: Extending GHCi

On Tue, Dec 04, 2012 at 04:23:02PM +0100, Dennis Felsing wrote:
> 
> Is there a way to extend GHCi without copying some of its source code?

Someone was looking at moving the ghci code into a library, which may
mean you need to copy less code, at least. I'm not sure what the status
of that is, though.

> Is there a chance of having these
> features flow back into mainline GHCi once they are properly implemented?

Sure, providing the complexity is not disproportionately high for the
functionality.

Thanks
Ian

Gmane