functor PQUEUE(type Item val > : Item * Item -> bool ):QueueSig = struct type Item = Item exception Deq fun insert e [] = [e]:Item list | insert e (h :: t) = if e > h then e :: h :: t else h :: insert e t abstype Queue = Q of Item list with val empty = Q [] fun isEmpty (Q []) = true | isEmpty _ = false fun enq(Q q, e) = Q(insert e q) fun deq(Q(h :: t)) = (Q t, h) | deq _ = raise Deq end end;