Skip to content

Commit

Permalink
Keep the bind as is and Tar_gz does not require the run function (/cc @…
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed Feb 7, 2024
1 parent 2388f62 commit 8b308a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
11 changes: 2 additions & 9 deletions lib/tar_gz.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,13 @@ let seek_through_gz : decoder -> int -> (int, [> error ]) Tar.t = fun state len
let* _buf = really_read_through_gz state len in
Tar.return (Ok 0 (* XXX(dinosaure): actually, [fold] ignores the result. *))

type 'err run = { run : 'a 'err. ('a, 'err) Tar.t -> ('a, 'err) result } [@@unboxed]

let fold_with_gz
: run:[> error ] run -> _ -> _ -> _
= fun ~run:{ run } f init ->
let fold_with_gz f init =
let rec go : type a. decoder -> (a, [> error ] as 'err) Tar.t -> (a, 'err) Tar.t = fun decoder -> function
| Tar.Really_read len -> really_read_through_gz decoder len
| Tar.Read _len -> assert false (* XXX(dinosaure): actually does not emit [Tar.Read]. *)
| Tar.Seek len -> seek_through_gz decoder len
| Tar.Return v -> Tar.return v
| Tar.Bind (x, f) ->
match run x with
| Ok value -> go decoder (f value)
| Error _ as err -> Tar.return err in
| Tar.Bind _ as bind -> bind in
let decoder =
let oc_buffer = De.bigstring_create 0x1000 in
{ gz= Gz.Inf.decoder `Manual ~o:oc_buffer
Expand Down
4 changes: 1 addition & 3 deletions lib/tar_gz.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

type error = [ `Fatal of Tar.error | `Eof | `Gz of string ]

type 'err run = { run : 'a 'err. ('a, 'err) Tar.t -> ('a, 'err) result } [@@unboxed]

val fold_with_gz : run:[> error ] run -> ('a, [> error]) Tar.fold
val fold_with_gz : ('a, [> error]) Tar.fold

(*
module type READER = sig
Expand Down

0 comments on commit 8b308a9

Please sign in to comment.