Source file nonempty_list.ml

1
2
3
4
5
6
7
8
type 'a t = ( :: ) of 'a * 'a list

let of_list = function
  | [] -> None
  | x :: xs -> Some (x :: xs)
;;

let to_list (x :: xs) = List.cons x xs