diff --git a/src/implementation0.ml b/src/implementation0.ml new file mode 100644 index 0000000..e467adc --- /dev/null +++ b/src/implementation0.ml @@ -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 } +;; diff --git a/src/implementation0.mli b/src/implementation0.mli new file mode 100644 index 0000000..8f65335 --- /dev/null +++ b/src/implementation0.mli @@ -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 diff --git a/src/provider.ml b/src/provider.ml index 8c24a7d..c0ea41b 100644 --- a/src/provider.ml +++ b/src/provider.ml @@ -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 @@ -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 @@ -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 diff --git a/src/provider.mli b/src/provider.mli index ab10ad0..cbae44e 100644 --- a/src/provider.mli +++ b/src/provider.mli @@ -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} *) @@ -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 diff --git a/src/trait0.ml b/src/trait0.ml new file mode 100644 index 0000000..e1fb797 --- /dev/null +++ b/src/trait0.ml @@ -0,0 +1 @@ +type ('t, 'module_type, 'tag) t = .. diff --git a/src/trait0.mli b/src/trait0.mli new file mode 100644 index 0000000..e1fb797 --- /dev/null +++ b/src/trait0.mli @@ -0,0 +1 @@ +type ('t, 'module_type, 'tag) t = ..