How to merge OCaml module types (signatures) defining the same type?

前端 未结 1 992
既然无缘
既然无缘 2021-01-04 20:27

In OCaml, I have two module types defining a type t:

module type Asig = sig
    type t
    val a : t
end

module type Bsig = sig
    type t
             


        
相关标签:
1条回答
  • 2021-01-04 20:44

    Here is the way to do it :

    module type Asig = sig
        type t
        val a : t
    end
    
    module type Bsig = sig
        type t
        val b : t
    end
    
    module type ABsig = sig
        include Asig
        include Bsig with type t := t
    end
    

    It's called "destructive substitution".

    0 讨论(0)
提交回复
热议问题