Reputation: 5759
module type FOOable = sig
type 'a t
val foo : 'a -> 'a t
end
module type FOO_FUCNTOR =
functor (Elt : FOOable) ->
sig
type 'a t
val foo_alias : 'a -> 'a t
(* ... *)
end
How can I refer to the type 'a t
defined by FOOable
as it is not possible to use Elt.t
?
So in this example it would become type 'a t = 'a list
module MakeFoo : FOO_FUNCTOR =
functor (Elt : FOOable) ->
struct
type 'a t = ??? (* I want the type 'a t belonging to Elt *)
let foo_alias = Elt.foo
end
module FooableList = struct
type = 'a list
let foo x = [x]
end
module FooList = MakeFoo(FooableList)
let a = FooList.foo_alias 2
Upvotes: 1
Views: 83
Reputation: 6144
You can simply type 'a Elt.t
and you'll be sure to refer the right type.
module MakeFoo : FOO_FUNCTOR =
functor (Elt : FOOable) ->
struct
type 'a t = 'a Elt.t
let foo_alias = Elt.foo
end
Note that as in the definition of FOO_FUNCTOR
, the type equality is hidden, the link between 'a t
and 'a Elt.t
will not be visible outside the MakeFOO
definition (but that may be what you're looking for).
Upvotes: 4