[Haskell-cafe] Connecting to a running process (REPL)

Tomasz Zielonka tomasz.zielonka at gmail.com
Tue Dec 6 15:01:45 EST 2005

On Tue, Dec 06, 2005 at 10:35:50AM +0000, Joel Reymont wrote:
> Is there a good standard way of supplying a read-eval prompt in a  
> program?
> I would like to a running process with something ghci-like to be able  
> to inspect the state and possibly modify it. The running process  
> would be heavily multi-threaded.

Some time ago I was thinking about implementing a Haskell telnet
server module, but now I think that this would be a difficult
solution for a simple problem.

You can almost use GHCi for what you want. You could simply run
your program under from within GHCi. Of course you would have to
structure your program in such a way that you could reach the
interesting parts somehow. I think it could look like this:

$ ghci
Prelude> :l Prog
Prog> root <- runProg
Prog> threads <- getClientThreads root

Unfortunately it seems that forkIO'ed threads are freezed when GHCi is
waiting for command-line input. I bet it would be possible to let
the threads work in the background. I think the current behaviour is
caused by using readline, which is a foreign library. Or it is by

Best regards

I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland

More information about the Haskell-Cafe mailing list