OCaml 函子 Set.Make/Map.Make weird annotation in VSCode

问题描述 投票:0回答:1

世界上为什么会有“1/”。在“Ord: Set”和“OrderedType ->”之间?

这在 VSCode 环境中显示为

Set.Make
Map.Make
,也可能显示为其他内置 Make 仿函数。

ocaml functor
1个回答
0
投票

来自 Yanny 的待定信息,这看起来你要么重新定义了模块,要么 VSCode 正在主动。考虑以下简单示例:

# module type S = sig
    type t
  end
  
  module A (T : S) = struct
    type t = T.t
  end;;
module type S = sig type t end
module A : functor (T : S) -> sig type t = T.t end
# module B = A (Int)
  
  let foo (x: B.t) = x + 1;;
module B : sig type t = Int.t end
val foo : B.t -> int = <fun>
# module B = A (Float)
  
  let bar (x : B.t) = x +. 1.;;
module B : sig type t = Float.t end
val bar : B.t -> float = <fun>
# foo;;
- : B/2.t -> int = <fun>

注意

B/2
签名中类型的
foo
名称?这是因为我已经隐藏了早期模块的名称
B
,但是
foo
仍然可以访问它。

© www.soinside.com 2019 - 2024. All rights reserved.