
Test.IOSpec.VirtualMachine 




Description 
The virtual machine on which the specifications execute.


Synopsis 




The Virtual Machine



The VM monad is essentially a state monad, modifying the
store. Besides returning pure values, various primitive effects
may occur, such as printing characters or failing with an error
message.







Instances  





Instances  




Primitive operations on the VM



The alloc function allocate a fresh location on the heap.



The emptyLoc function removes the data stored at a given
location. This corresponds, for instance, to emptying an MVar.



The freshThreadId function returns a previously unallocated ThreadId.



The finishThread function kills the thread with the specified
ThreadId.



The lookupHeap function returns the data stored at a given
heap location, if there is any.



The mainTid constant is the ThreadId of the main process.





The readChar and printChar functions are the primitive
counterparts of getChar and putChar in the VM monad.



The updateHeap function overwrites a given location with
new data.



The updateSoup function updates the process associated with a
given ThreadId.


The observable effects on the VM



The Effect type contains all the primitive effects that are
observable on the virtual machine.
 Constructors   Instances  


Sample schedulers


There are two example scheduling algorithms roundRobin and
singleThreaded. Note that Scheduler is also an instance of
Arbitrary. Using QuickCheck to generate random schedulers is a
great way to maximise the number of interleavings that your tests
cover.



The roundRobin scheduler provides a simple roundrobin scheduler.



The singleThreaded scheduler will never schedule forked
threads, always scheduling the main thread. Only use this
scheduler if your code is not concurrent.


Executing code on the VM



The Executable type class captures all the different types of
operations that can be executed in the VM monad.
  Methods    Instances  






The runIOSpec function is the heart of this library. Given
the scheduling algorithm you want to use, it will run a value of
type IOSpec f a, returning the sequence of observable effects
together with the final store.



The evalIOSpec function returns the effects a computation
yields, but discards the final state of the virtual machine.



The execIOSpec returns the final Store after executing a
computation.
Beware: this function assumes that your computation will
succeed, without any other visible Effect. If your computation
reads a character from the teletype, for instance, it will return
an error.


Produced by Haddock version 2.4.2 