Haskell logo CIS 552: Advanced Programming

Fall 2019

  • Home
  • Schedule
  • Homework
  • Resources
  • Style guide
  • Syllabus
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

> {-# LANGUAGE ScopedTypeVariables, TypeApplications, AllowAmbiguousTypes #-}
> module Queue where

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.)

> import Test.QuickCheck
  1. 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.
  1. 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.)
  1. Implement your interface.
  1. Make an arbitrary instance.
  1. Run your tests.
Design adapted from Minimalistic Design | Powered by Pandoc and Hakyll