type (='a:type, ='b:level, #'c:level) t
The type of stacks containing elements of type 'a.
exception Empty
Raised when Stack.pop or Stack.top is applied to an empty stack.
val create : unit -> ('a, 'b, 'c) t
Return a new stack, initially empty.
val push : 'a -> ('a, 'b, 'b) t -{'b ||}-> unit
push x s adds the element x at the top of stack s.
val pop : ('a, 'b, 'b) t -{'c | Empty: 'd |}-> 'e
with 'a < 'e
and 'c < 'b, 'd, level('e)
and 'b < 'd, level('e)
pop s removes and returns the topmost element in stack s,
or raises Empty if the stack is empty.
val top : ('a, 'b, 'c) t -{'d | Empty: 'd |}-> 'e
with 'a < 'e
and 'c < 'd, level('e)
and 'b < 'd, level('e)
top s returns the topmost element in stack s,
or raises Empty if the stack is empty.
val clear : ('a, 'b, 'b) t -{'b ||}-> unit
Discard all elements from a stack.
val copy : ('a, 'b, 'c) t -> ('d, 'c, 'e) t
with 'a < 'd
and 'b < 'c
Return a copy of the given stack.
val length : ('a, 'b, 'c) t -> 'c int
with 'b < 'c
Return the number of elements in a stack.
val iter : ('a -{'b | 'c | 'b}-> 'd) -> ('a, 'e, 'b) t -{'b | 'c |}-> unit
with content('c), 'e < 'b
iter f s applies f in turn to all elements of s,
from the element at the top of the stack to the element at the
bottom of the stack. The stack itself is unchanged.
This module implements stacks (LIFOs), with in-place modification.