Skip to content

Commit

Permalink
Refactor: prepare for exposing Implementation as Provider.Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbin committed Aug 2, 2024
1 parent fd412c1 commit 9a32ab0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/implementation0.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type _ t =
| T :
{ trait : ('t, 'module_type, _) Trait0.t
; impl : 'module_type
}
-> 't t

let implement (type a i) (trait : (a, i, _) Trait0.t) ~(impl : i) : a t =
T { trait; impl }
;;
8 changes: 8 additions & 0 deletions src/implementation0.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type _ t = private
| T :
{ trait : ('t, 'module_type, _) Trait0.t
; impl : 'module_type
}
-> 't t

val implement : ('t, 'module_type, _) Trait0.t -> impl:'module_type -> 't t
8 changes: 3 additions & 5 deletions src/provider.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let raise_s msg sexp = raise (E (Sexp.List [ Atom msg; sexp ]))
let phys_same t1 t2 = phys_equal (Stdlib.Obj.repr t1) (Stdlib.Obj.repr t2)

module Trait = struct
type ('t, 'module_type, 'tag) t = ..
type ('t, 'module_type, 'tag) t = ('t, 'module_type, 'tag) Trait0.t = ..

module Info = struct
type t = Stdlib.Obj.Extension_constructor.t
Expand Down Expand Up @@ -50,7 +50,7 @@ module Trait = struct
module Implementation = struct
type ('t, 'module_type, 'tag) trait = ('t, 'module_type, 'tag) t

type _ t =
type 'a t = 'a Implementation0.t = private
| T :
{ trait : ('t, 'module_type, _) trait
; impl : 'module_type
Expand All @@ -65,9 +65,7 @@ module Trait = struct
;;
end

let implement (type a i) (trait : (a, i, _) t) ~(impl : i) : a Implementation.t =
Implementation.T { trait; impl }
;;
let implement = Implementation0.implement
end

module Interface = struct
Expand Down
4 changes: 2 additions & 2 deletions src/provider.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module Trait : sig
['module_type] is expected to be a module type (Eio supports single
functions but this is discouraged through the use of this library). *)
type ('t, 'module_type, 'tag) t = ..
type ('t, 'module_type, 'tag) t = ('t, 'module_type, 'tag) Trait0.t = ..

(** {1 Dump & debug} *)

Expand Down Expand Up @@ -86,7 +86,7 @@ module Trait : sig

type ('t, 'module_type, 'tag) trait := ('t, 'module_type, 'tag) t

type _ t = private
type 'a t = 'a Implementation0.t = private
| T :
{ trait : ('t, 'module_type, _) trait
; impl : 'module_type
Expand Down
1 change: 1 addition & 0 deletions src/trait0.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type ('t, 'module_type, 'tag) t = ..
1 change: 1 addition & 0 deletions src/trait0.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type ('t, 'module_type, 'tag) t = ..

0 comments on commit 9a32ab0

Please sign in to comment.