Note: this is the stubbed version of module Queue. You should
download the lhs version of this
module and replace all parts marked
undefined
.
Eventually, the complete
version will be made available.
In class exercise: Purely Functional Queues
We will use quickcheck to test this module. If you want to use additional library operations to complete this exercise, you may import them here. (For example, our solution uses at least one function from the Data.Maybe
library.)
- Define an interface for a purely functional Queue (FIFO) using a type class. It must (at least) have a way to add an element to the end of the queue (enqueue) and remove the element at the beginning of the queue (dequeue), if the queue is nonempty. The queue must be polymorphic over the type of elements that it stores.
- Define some properties that your queue should satisfy. (Note: if you want to add additional operations to your queue interface to help with stating these properties, you may.)
- Implement your interface.
- Make an arbitrary instance.
- Run your tests.