let uniq xs =
match peek xs with
| None -> empty ()
| Some first ->
let prev = ref first in
let rec aux i =
if i = 0 then Some first
else (
match next xs with
| None -> None
| Some x ->
if x = !prev then
aux i
else (
prev := x ;
Some x
)
)
in
from aux