functor STACK(type Item)= struct exception Deq type Item = Item abstype Queue = Q of Item list with val empty = Q [] fun isEmpty (Q []) = true | isEmpty _ = false fun enq(Q s, e) = Q(e :: s) fun deq(Q(h :: t)) = (Q t, h) | deq _ = raise Deq end end;