anchor.diff:  open OptimizedClosures
   open ExtCore
   
  -(*
   
   //
   type QueueData<'T> = {
  -    Front : Stream<'T>;
  +    Front : LazyList<'T>;
       Rear : 'T list;
  -    Pending : Stream<'T>;
  +    Pending : LazyList<'T>;
   }
   
   //
  
positive.code: //
  [<RequireQualifiedAccess; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
  module Queue =
      open Stream
  
      (* INVARIANTS                                        *)
      (*   1. length front >= length rear                  *)
      (*   2. length pending = length front - length rear  *)
  
negative.code:             // This should never happen -- it's only here to satisfy
              // the F# pattern-match exhaustivity checker.
              failwith "Invariant failed."
          | y :: ys ->
              if LazyList.isEmpty xs then
                  LazyList.cons y rys
              else
                  LazyList.consDelayed (LazyList.head xs) <| fun () ->
                      rotate (LazyList.tail xs, ys, LazyList.cons y rys)
  
      (* Psuedo-constructor that enforces invariant *)
      (*   always called with length pending = length front - length rear + 1 *)
      let private queue { Front = front; Rear = rear; Pending = pending; } =
          if LazyList.isEmpty pending then
              (* length rear = length front + 1 *)
              let front = rotate (front, rear, LazyList.empty)
              Queue {
                  Front = front;
                  Rear = [];
                  Pending = front; }
          else
              Queue {
                  Front = front;
                  Rear = rear;
                  Pending = LazyList.tail pending; }
  
      /// Returns an empty queue of the given type.
      let empty : Queue<'T> =
          Queue {
              Front = LazyList.empty;
              Rear = [];
              Pending = LazyList.empty; }
  
      /// Returns true if the given queue is empty; otherwise, false.
      let isEmpty (Queue { Front = front } : Queue<'T>) =
          (* by Invariant 1, front = empty implies rear = [] *)
          LazyList.isEmpty front
  
      /// The number of elements in the queue.
      let size (Queue { Front = front; Rear = rear; Pending = pending; } : Queue<'T>) =
          (* = LazyList.length front + length rear -- by Invariant 2 *)
          LazyList.length pending + 2 * List.length rear
  
      /// add to rear of queue
      let enqueue x (Queue { Front = front; Rear = rear; Pending = pending; } : Queue<'T>) =
          queue {
              Front = front;
              Rear = x :: rear;
              Pending = pending; }
  
      /// add to front of queue
      let enqueuef x (Queue { Front = front; Rear = rear; Pending = pending; } : Queue<'T>) =
          Queue {
              Front = LazyList.cons x front;
              Rear = rear;
              Pending = LazyList.cons x pending; }
  
      /// take from front of queue
      let dequeue (Queue { Front = front; Rear = rear; Pending = pending; } : Queue<'T>) =
          // Preconditions
          if LazyList.isEmpty front then
              invalidArg "front" "The queue is empty."
  
          LazyList.head front,
          queue {
              Front = LazyList.tail front;
              Rear = rear;
              Pending = pending; }
  
      //
      let toArray (queue : Queue<'T>) : 'T[] =
  