let write h xs oc =
let module M = struct exception E of Error.t end in
let xs = Stream.map xs ~f:(fun al ->
match Alignment0.encode al h with
| Ok r -> r
| Error e -> raise (M.E e)
)
in
try write0 h xs oc ; Ok ()
with M.E e -> Error e