[Haskell-cafe] How to ensure code executes in the context of aspecific OS thread?

Donn Cave donn at avvanta.com
Wed Jul 6 18:25:46 CEST 2011


Quoth Jason Dagit <dagitj at gmail.com>,
...
> Yes.  From my perspective (that of a library writer) that's what makes
> this tricky in GHCi.  I need GHCi's cooperation.  From GHCi's
> perspective it's tricky too.

It seems to me that ideally, GHCi would do its thing in a child
thread, like the extra runtime threads, and let the program
execute in the main thread, as in a compiled program.  I mean,
ideal from the point of view of supporting the general case of
library functions that care what the main thread is doing.

I'm not saying that's possible - have no idea - but just that
where you're dealing with a possibly unconscious and probably
poorly documented expectation like that, it's better to not
break it in the first place, than to have to try to patch it
up at run time.  I have been wondering while reading this thread
if my Haiku API functions are subject to this restriction -
there is an application object that normally runs in main() -
but while that would be easy to verify empirically, it wouldn't
really tell me what I need to know.  A subsequent OS release
could easily introduce some thread sensitivity, and I guess if
my Haskell programs must run from a child thread under certain
circumstances, even if I could make them work I would have to
consider that success temporary and provisional.

	Donn



More information about the Haskell-Cafe mailing list