Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure dec enc with gz #143

Merged
merged 26 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6c54ca0
revise a decoder and encoder, being pure
hannesm Feb 1, 2024
c67f945
remove stuff
hannesm Feb 2, 2024
9ccc73b
wip
hannesm Feb 3, 2024
ebabd3c
fix
hannesm Feb 3, 2024
ce9337b
proposed API
hannesm Feb 3, 2024
50f6659
add filter
hannesm Feb 3, 2024
1b4ae55
initial compiling tar_unix
hannesm Feb 3, 2024
984ffe0
remove offset nonsense
hannesm Feb 3, 2024
9c1c120
lwt-unix
hannesm Feb 4, 2024
29d884e
further work, get tests a bit more up to speed
hannesm Feb 4, 2024
281883b
more tests are working now
hannesm Feb 4, 2024
60d6faa
revive transform test
hannesm Feb 4, 2024
462063b
test tar_unix, use fold for list
hannesm Feb 4, 2024
2b49b1f
document write_header
hannesm Feb 4, 2024
2388f62
Purify fold and move it into Tar with a GADT, use it then for Tar_gz …
dinosaure Feb 7, 2024
8b308a9
Keep the bind as is and Tar_gz does not require the run function (/cc…
dinosaure Feb 7, 2024
14681fe
Implement Tar_gz.gzipped : _ Tar.t -> _ Tar.t
reynir Feb 7, 2024
d5ad1df
Fix the otar binary
dinosaure Feb 7, 2024
c7c81d2
Implement the high kind polymorphism to fix the lwt_unix layer
dinosaure Feb 7, 2024
906d6dc
Add a comment to explain the hkp trick
dinosaure Feb 21, 2024
b8b4ff6
Minor: qualify opens, fix tests
reynir May 7, 2024
0cfd771
Partially implement tar_eio, stub out remainder
reynir May 7, 2024
c24cd1b
Seek returns unit, improve documentation
robur-team May 9, 2024
576dcff
Remove [`Msg of string] from Tar_unix.decode_error
robur-team May 9, 2024
b1c10d0
Document Tar.fold
reynir May 9, 2024
890c1fe
Fixups
reynir May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
reynir marked this conversation as resolved.
Show resolved Hide resolved
| 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
dinosaure marked this conversation as resolved.
Show resolved Hide resolved
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
Loading