Why there is a plus sign before this type?

后端 未结 2 2099
伪装坚强ぢ
伪装坚强ぢ 2020-12-30 04:15

I was browsing ocaml\'s standard library, and came across this code in the map.ml file.

module type S =
  sig
    type key
    type +\'a t
    val empty: \'a         


        
2条回答
  •  生来不讨喜
    2020-12-30 05:03

    This marks the type as covariant with respect to the module type. Assume you have two maps whose keys are the same type. This + says if the values of one map A are of a subtype of the values of the other map B, then the overall type of map A is a subtype of map B's type. I found a pretty good description of this in the Jane Street blog.

提交回复
热议问题