On Wed, Jul 6, 2011 at 8:09 AM, Simon Marlow
<marlowsd@gmail.com> wrote:
On 06/07/2011 15:42, Jason Dagit wrote:
How can I make sure my library works from GHC (with arbitrary
user threads) and from GHCI?
Right, but usually the way this is implemented is with some cooperation from the main thread. [...] So you can't just do this from a library - the main thread has to be in on the game. I suppose you might wonder whether the GHC RTS could implement runInMainThread by preempting the main thread and running some different code on it. [...]
I think the real issue is that GHC has a different behavior than GHCi, and I think this causes a lot of difficulties for people working on GUI and other FFI integration.
Perhaps it would be possible to reverse the default roles of threads in GHCi: the main thread run user commands, and a second bound thread will process user interrupts and such.