datatype 'a seq = Nil
| Cons of 'a * (unit -> 'a seq)
fun hd (Cons(x, _)) = x
| hd Nil = raise Empty
fun tl (Cons(_, xf)) = xf()
| tl Nil = raise Empty
fun null Nil = true
| null _ = false
fun cons (x, xq) = Cons(x, fn () => xq)