let read ?(start=Pos.(incr_line unknown)) r =
let pos = ref start in
let lines =
Pipe.map (Lines.read r) ~f:(fun line ->
pos := Pos.incr_line !pos;
line
)
in
read_header lines >>| function
| Error _ as e -> Or_error.tag_arg e "position" !pos Pos.sexp_of_t
| Ok hdr ->
let alignments = Pipe.map lines ~f:(fun line ->
Or_error.tag_arg
(parse_alignment line)
"position" !pos Pos.sexp_of_t
)
in
Ok (hdr, alignments)