(* Example of polymorphic stacks in ML from pages 244-246 of Kenneth C. Louden, Programming Languages Principles and Practice 2nd Edition Copyright (C) Brooks-Cole/ITP, 2003 *) datatype 'a Stack = EmptyStack | Stack of 'a * ('a Stack); val empty = EmptyStack; (* empty has type 'a Stack *) val x = Stack (3, EmptyStack); (* x has type int Stack *) fun top (Stack p) = #1(p);