Question

Suppose I have the following setup

module type FOO = sig type f val do_foo : f end
module type BAR = sig type b val do_bar : b end


module type FOOANDBAR =
  sig 
    include FOO
    include BAR
  end

Now I want to (in a nice way, aka, without copying the interface and so that FOO and BAR are still subtypes) enforce the restriction that the type f and the type b are the same.

Is there a nice way to do this in OCaml, possibly using some different approach that the include keyword?

thanks!! -Joseph

Était-ce utile?

La solution

module type FOOANDBAR =
  sig 
    include FOO
    include (BAR with type b = f)
  end
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top