Skip to content

Commit f5700b8

Browse files
balatclaude
andcommitted
irmin-lwt: link top-level types to Schema in module type S
Without these equalities, [Irmin_lwt.S with module Schema = Schema] in a downstream consumer (Tezos' [Tezos_context_helpers.Context.DB]) only substituted [Schema] but left [hash], [contents], [step], etc. abstract. Cue type errors like "Store.Tree.hash returns Store.hash but Tezos expects Hash.t (= Schema.Hash.t)". Mirror the pattern of [Irmin.Generic_key.S]: declare [Schema] first and define the types it derives as type aliases: type step = Schema.Path.step type path = Schema.Path.t type metadata = Schema.Metadata.t type contents = Schema.Contents.t type branch = Schema.Branch.t type info = Schema.Info.t type hash = Schema.Hash.t Now [Irmin_lwt.S with module Schema = Schema] propagates the equalities to every Schema-derived type. The redundant [type X = S.X] constraints in [Make]'s output type are dropped accordingly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 260e64e commit f5700b8

2 files changed

Lines changed: 28 additions & 25 deletions

File tree

src/irmin-lwt/irmin_lwt.ml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,25 @@ let run_with_env env f =
1616
Lwt_eio.Promise.await_lwt (f ())
1717

1818
module type S = sig
19+
(** {1 Schema} *)
20+
21+
module Schema : Irmin.Schema.S
22+
23+
(** {1 Types} *)
24+
1925
type repo
2026
type t
21-
type step
22-
type path
23-
type metadata
24-
type contents
27+
type step = Schema.Path.step
28+
type path = Schema.Path.t
29+
type metadata = Schema.Metadata.t
30+
type contents = Schema.Contents.t
2531
type node
2632
type tree
2733
type commit
28-
type branch
34+
type branch = Schema.Branch.t
2935
type slice
30-
type info
31-
type hash
36+
type info = Schema.Info.t
37+
type hash = Schema.Hash.t
3238
type contents_key
3339
type node_key
3440
type commit_key
@@ -40,7 +46,6 @@ module type S = sig
4046

4147
(** {1 Type-level submodules} *)
4248

43-
module Schema : Irmin.Schema.S
4449
module Info : Irmin.Info.S with type t = info
4550
module Hash : Irmin.Hash.S with type t = hash
4651
module Path : Irmin.Path.S with type t = path and type step = step

src/irmin-lwt/irmin_lwt.mli

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,25 @@ val run_with_env : < clock : _ Eio.Time.clock ; .. > -> (unit -> 'a Lwt.t) -> 'a
3030
See {!Make} for the functor that produces a module conforming to [S] from an
3131
arbitrary [Irmin.Generic_key.S]. *)
3232
module type S = sig
33+
(** {1 Schema} *)
34+
35+
module Schema : Irmin.Schema.S
36+
37+
(** {1 Types} *)
38+
3339
type repo
3440
type t
35-
type step
36-
type path
37-
type metadata
38-
type contents
41+
type step = Schema.Path.step
42+
type path = Schema.Path.t
43+
type metadata = Schema.Metadata.t
44+
type contents = Schema.Contents.t
3945
type node
4046
type tree
4147
type commit
42-
type branch
48+
type branch = Schema.Branch.t
4349
type slice
44-
type info
45-
type hash
50+
type info = Schema.Info.t
51+
type hash = Schema.Hash.t
4652
type contents_key
4753
type node_key
4854
type commit_key
@@ -54,7 +60,6 @@ module type S = sig
5460

5561
(** {1 Type-level submodules} *)
5662

57-
module Schema : Irmin.Schema.S
5863
module Info : Irmin.Info.S with type t = info
5964
module Hash : Irmin.Hash.S with type t = hash
6065
module Path : Irmin.Path.S with type t = path and type step = step
@@ -704,27 +709,20 @@ end
704709

705710
module Make (S : Irmin.Generic_key.S) :
706711
S
707-
with type repo = S.repo
712+
with module Schema = S.Schema
713+
and type repo = S.repo
708714
and type t = S.t
709-
and type step = S.step
710-
and type path = S.path
711-
and type metadata = S.metadata
712-
and type contents = S.contents
713715
and type node = S.node
714716
and type tree = S.tree
715717
and type commit = S.commit
716-
and type branch = S.branch
717718
and type slice = S.slice
718-
and type info = S.info
719-
and type hash = S.hash
720719
and type contents_key = S.contents_key
721720
and type node_key = S.node_key
722721
and type commit_key = S.commit_key
723722
and type lca_error = S.lca_error
724723
and type ff_error = S.ff_error
725724
and type write_error = S.write_error
726725
and type watch = S.watch
727-
and module Schema = S.Schema
728726
and module Info = S.Info
729727
and module Hash = S.Hash
730728
and module Path = S.Path

0 commit comments

Comments
 (0)