Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e9fa6d

Browse files
committed
irmin-lwt: declare Closeable trait and use it in S.Repo
Mirror Irmin 3.11's [Repo] signature, which exposes its [val close] through [include Closeable with type _ t := t] rather than as a free [val close]. The visible signature is unchanged for clients reading fields directly, but [module M : Irmin_lwt.Closeable = ...]-style constraints now type-check against [Repo].
1 parent b7e3255 commit 9e9fa6d

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/irmin-lwt/irmin_lwt.ml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ let run_with_env env f =
1515
Lwt_eio.with_event_loop ~clock:env#clock @@ fun _ ->
1616
Lwt_eio.Promise.await_lwt (f ())
1717

18+
module type Closeable = sig
19+
type 'a t
20+
21+
val close : 'a t -> unit Lwt.t
22+
end
23+
1824
module type S = sig
1925
(** {1 Schema} *)
2026

@@ -99,7 +105,9 @@ module type S = sig
99105

100106
val elt_t : elt Irmin.Type.t
101107
val v : Irmin.Backend.Conf.t -> t Lwt.t
102-
val close : t -> unit Lwt.t
108+
109+
include Closeable with type _ t := t
110+
103111
val heads : t -> commit list Lwt.t
104112
val branches : t -> branch list Lwt.t
105113
val config : t -> Irmin.Backend.Conf.t

src/irmin-lwt/irmin_lwt.mli

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ val run_with_env : < clock : _ Eio.Time.clock ; .. > -> (unit -> 'a Lwt.t) -> 'a
1919
instead of calling [Eio_main.run] internally. Useful when the client is
2020
already inside an Eio event loop. *)
2121

22+
(** Lwt-flavoured counterpart of the internal [Irmin.Closeable] trait: a single
23+
[close] operation that releases the resources held by a handle. Used as
24+
[include Closeable with type _ t := t] in [S.Repo] to mirror the Irmin 3
25+
[Repo] signature. *)
26+
module type Closeable = sig
27+
type 'a t
28+
29+
val close : 'a t -> unit Lwt.t
30+
end
31+
2232
(** The Lwt-flavoured counterpart of [Irmin.Generic_key.S].
2333
2434
Every I/O-triggering operation of [Irmin.Generic_key.S] is replaced by a
@@ -113,7 +123,10 @@ module type S = sig
113123

114124
val elt_t : elt Irmin.Type.t
115125
val v : Irmin.Backend.Conf.t -> t Lwt.t
116-
val close : t -> unit Lwt.t
126+
127+
include Closeable with type _ t := t
128+
(** @inline *)
129+
117130
val heads : t -> commit list Lwt.t
118131
val branches : t -> branch list Lwt.t
119132
val config : t -> Irmin.Backend.Conf.t

0 commit comments

Comments
 (0)