[Haskell-beginners] Interrupting a thread

Floptical Logic flopticalogic at gmail.com
Sun Dec 27 00:11:13 EST 2009


I am new to concurrency in Haskell and I am having trouble
implementing the notion of interrupting a thread.

In a new thread, call it waitNotify, I am trying to do the following:
pop a number from a stack, wait some number of seconds based on the
number popped from the stack, perform some notification, and repeat
until there are no more numbers in the stack at which point we wait
for a new number.

These numbers will be supplied interactively by the user from main.
When the user supplies a new number, I want to interrupt whatever
waiting is happening in waitNotify, insert the number in the proper
position in the current stack, and resume waitNotify using the updated
stack.  Note, here "stack" is just a generalization; it will likely
just be a list.

What is the most idiomatic way to capture this sort of behavior in
Haskell?  My two challenges are the notion of interrupting a thread,
and sharing and updating this stack between threads (main and

Thank you

More information about the Beginners mailing list