let with_file ?fmt file ~f =
  let start = Pos.make ~source:file ~line:1 () in
  In_channel.with_file file ~f:(fun cin ->
    match read ~start ?fmt cin with
    | Error _ as e -> e
    | Ok (header,strm) -> f header strm
  )