[Haskell] Discrete event simulation
paul at cogito.org.uk
Thu Jan 26 18:35:11 EST 2006
Hi, I'm going slowly nuts here. Maybe someone can help me out.
I want to do some fairly straightforward discrete event simulation.
Tasks do side effects, probably in the ST monad. Every so often the
current task calls "delay n" where n is a number of seconds. This puts
the task back on a list of schedulable processes that is ordered by
time, and then takes the head of the list and starts executing it.
Part of this will be some kind of synchronisation primitive. I don't
much care what it is, but somewhere I need a way to make a process wait
until something happens rather than just a constant time.
I think I want to use something like
type Task r s a = ContT r (ST s) a
But I can't see how to actually do it. I've read All About Monads.
I've googled for anything to do with continuations and coroutines. I'm
stuck. Can someone show me how to do it.
More information about the Haskell