úÎkúf®F      !"#$%&'()*+,-./0123456789:;<=>?@ABCDE unportable experimentaljochem@functor.nl!The type that represents a time. /The type that represents a process identifier.  unportable experimentaljochem@functor.nl Finds the # (existential type) belonging to a . 'Converts a process with an action to a . A ! is an action that can be run. A  has  three parameters: , * The first is the process to which this  belongs. 1 * The second is a primitive action to be run. ( * The third is Maybe a continuation. Existential type for the   type. The Action! GADT. This is a GADT with three  parameters; an Action pkt st a is a action where 5 * pkt denotes the packet type of incoming packets / * st denotes the state that can be modified  and inspected ' * a denotes the result value of the Action 9GADT for the primitive actions. These are the primitives  Hasim supports. A PrimAction pkt st a is a primitive action where  * pkt# is the packet type the associated  supports.  * st is the state of the associated .  * a' is the return type of the PrimAction. 0 (this is why we need a GADT; the return type & varies for each primitive action). Existential type for a . A  is a Proc pkt  for some pkt. The type of result of the  An acceptor of a pkt is an , which is either  * Refuse6 if the packet is to be delivered at a later time, or  never, of course  *  Parallel act3 if a current computation should not be suspended, $ but the state should be changed.  *  Interrupt act1 if the current computation should be suspended. A  Proc st pkt8 is a process that potentially accepts packets of type  pkt while maintaining state st. -The list of acceptors with the continuations  after the WithAcceptor. &The current wakeup function, if any. !)The starting action. Loses its relevance " after startup of the simulation. "/The identifier of this process. Must be unique 0 or hell will ensue. Guaranteed to be unique by  the creator of the process. #1The name of the process. Determined by the user, 4 may be any string. Used for displaying information  to the user. $The state of the process. #  !"#$# !"#$   unportable experimentaljochem@functor.nl F"The initial state of the SimMonad G0Increase the current identifier of the SimMonad H.Append a process to the state of the SimMonad %Make an anonymous process. &3Make a process with a name. This name will be used  in logging and error messages 'Set the action of the process. (?Create a simulation from a SimMonad (a simulation definition).  If the simulation is invalid, I  will be called. JThe state of the SimMonad K%The identifier that will be used for  the next process LAll processes that are created )The simulation monad called ) . In this . monad you can define a simulation to be run. *%Data type representing a simulation. %&'()*+*)+%&'( unportable experimentaljochem@functor.nl ,The process of an 3 -!Is the Discrete Event Set empty? .9Get an event with lowest time that will take place next.  Returns a tuple  (evt, des) where evt is the next 3  and des is the new 2 where this event is removed. Calls I  if the 2 is empty. /<Schedule an event in a discrete event set. Note that an old C event of the same process is removed from the discrete event set. 0 Create a new 2 . For each , an 3 is scheduled  at time 0 and with  the associated  of the . 1An empty discrete event set. 2=Discrete Event Set. A discrete event set is a data structure  that supports the operations / and .. 3Event. An event consists of a  and a  4The ! at which the event takes place. 5The ! that should be run at this time ,-./012345 345,201-./ unportable experimentaljochem@functor.nl6Add the tuple (p1, p2) to the relation. 7Remove the tuple (p1, p2)# from the relation, if it existed. 8 Find all p1 such that (p1, p2) is in the relation. 9 An empty :. ::A watch map. This data structure represents a relation on  processes. 6789::9867 unportable experimentaljochem@functor.nl;Run the simulation. M/Given a DES, the initial simulation run state. NReturn the current DES. O Set the DES. PReturn the current Watchmap. QSet the Watchmap. RReturn the current time. SSet the current time. T1Return the next event to be run in the DES, and  update the DES. U5Run the simulation. Return only if the DES is empty. V$Warp to the time of the next event. WRun an event. X Schedule a  at a certain time in the DES. $ All other Runnables of the related  are removed. YSame as X#, but only execute if the Runnable  is a Just. Z Schedule a  at the current time. All other  Runnables of the related  are removed. [Same as Z#, but only execute if the Runnable  is a Just. \#Execute the PopAcceptor primitive. ]'Return the head of the acceptor stack. ^Add a watch to the Watchmap. _Execute a Send primitive `Execute the Unwatch primitive. aConcatenate two s. Because of lack of 5 type information, there is no flow of return values  between the two s. b:Same as rcat, but now the right hand side may be Nothing,  in which case nothing is done. c$Execute the WithAcceptor primitive. d#Execute the head of the Runnable. e5Is this event a wakeup event? i.e. must all watchers  be woken? fThe state of the simulation. g?The simulation run monad, composed of IO plus the state monad. ;; unportable experimentaljochem@functor.nl <6Get the current time. The result will be nonnegative. =$Wait for a nonnegative time period. >+Send a packet to a process, with a timeout % time interval. Returns True iff the  packet was accepted. ?.Send a packet. Return True iff the packet was / accepted immediately. Do not wait in case the  packet was not accepted. @@Send a packet. Wait as long as necessary to deliver the packet. AExecute an action with an  function B?Execute an action without interruptions from incoming packets. C<Wait forever. This can be useful in case you want to block,  waiting for incoming packets. D9Receive a packet. Block until the first packet comes in. E Receive a packet, non-blocking. <=>?@ABCDE <=C>?@ABDE  unportable experimentaljochem@functor.nl%&'()*;<=>?@ABCDE*)%&'(;h     !"#$%&&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP QRSTUVWXYDZ[\]^_`abcdefghijklmno hasim-0.1Control.Hasim.TypesControl.Hasim.ProcessControl.Hasim.SimulationControl.Hasim.DESControl.Hasim.WatchMapControl.Hasim.SimRunControl.Hasim.ActionbaseGHC.Err Control.HasimIdTimerunnable2process toRunnableRunnableRunAtomActionPrim PrimAction WaitForeverPutStateGetState ObserveTime PerformIO PopAcceptor WithAcceptorUnwatchSendWaitRetProcess AcceptResult InterruptParallelRefuseAcceptorProcacceptorwakeupaction identifiername currentState mkAnonProcess mkProcess setActioncreateSimulationSimMonad SimulationunSimeProcessisEmpty removeNextupdateinitDESemptyDESDESEventeTime eRunnableregister unregisterwatchersemptyWMWatchMap runSimulationgetTimewaitsendtrySend sendBlock withAcceptorwithoutInterruptions waitForeverreceivepollinitialSimStateincId appendProcesserrorSimState currentId processes initSimRunStgetDESputDES getWatchmap putWatchmapputTimepopEventrunwarprunEvent reschedulemaybeReschedule rescheduleNowmaybeRescheduleNowexecPopAcceptor getAcceptoraddWatchexecSend execUnwatchrcat rcatMaybeexecWithAcceptor stepRunnablewakeSimRunStSimRunM