Concurrency in GHCi

Simon Marlow
Fri, 2 Mar 2001 01:52:32 -0800

> The little program below is to test an idea to try to interact
> using Hugs or GHCi with a running program. 
> To use the program:
> 	1. Start the server with "addServer addChan"
> 	2. Write requests to addChan "writeChan addChan (Add 3 4)"
> The program seems to work OK in Hugs, but crashes out with 
> "ghc: no threads to run". 
> Can anybody suggest a way of getting this to run properly with
> GHCi?

I think you wanted "forkIO (addServer addChan)", because addServer
immediately attempts to read from the channel and will block if there's
no data available.

Oh, and you should really say "{-# NOINLINE addChan #-}" to prevent it
being accidentally duplicated.