exception Empty of string ;;
type 'a series = [ `Nil | `Con of 'a * 'a series ] ;;
let se = `Con (1, `Con(2, `Con(3, `Con (4, `Con (5, `Nil))))) ;;
let hd = function
| `Nil -> raise (Empty "list is empty")
| `Con (h, _) -> h ;;
let show_hd s =
try
let fst = hd s in
print_int fst
with
| Empty e -> print_string e ;;
show_hd se ;;
show_hd `Nil ;;
match hd `Nil with | `Con(h, _) -> print_int h | exception Empty e -> print_string e ;;