signature StackSig =
    sig
        type 'a stack
        exception StackEmpty

        val emptyStack : 'a stack
        val push : 'a stack * 'a -> 'a stack
        val pop : 'a stack -> 'a * 'a stack
    end

structure Stack : StackSig =
    struct
        type 'a stack = 'a list
        exception StackEmpty
        val emptyStack = []
        fun push (stk, itm) = itm::stk
        fun pop [] = raise StackEmpty
          | pop (itm::stk) = (itm,stk)
end