문제

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

도움이 되었습니까?

해결책

module type FOOANDBAR =
  sig 
    include FOO
    include (BAR with type b = f)
  end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top