declare % Represent as records of form % emptyStack | pushed(T ) % with the first element of the pushed record as % the top of the stack fun {NewStack} emptyStack end fun {Push Stck Elem} pushed(Elem Stck) end fun {Pop Stck ?OldTop} pushed(H Rest) = Stck in OldTop = H Rest end fun {IsEmpty Stck} case Stck of emptyStack then true else false end end