【问题标题】:ocaml type constructor argumentsocaml 类型构造函数参数
【发布时间】:2012-09-22 20:22:42
【问题描述】:

我这样定义了一个 AVL 树,其中 'a -> 'a -> int 是比较函数

type 'a t = Empty of ('a -> 'a -> int)
  | Node of 'a * 'a t * 'a t * ('a -> 'a -> int)

我正在尝试使用此 AVL 模块在单独的模块中实现优先级队列。

type 'a t = Queue of (Avl.t * int)

但是当我尝试编译时,我得到了这个错误:

 Error: The type constructor Avl.t expects 1 argument(s),
   but is here applied to 0 argument(s)

它在谈论什么参数,队列类型中的语法应该是什么?

【问题讨论】:

    标签: types constructor ocaml type-constructor


    【解决方案1】:

    您的 AVL 树由节点中的类型参数化 ('a)。所以你应该可以说

    type 'a t = Queue of ('a Avl.t * int)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-01
      • 2010-12-31
      • 2010-12-05
      • 2016-01-07
      • 1970-01-01
      • 2020-10-17
      • 2017-09-14
      • 1970-01-01
      相关资源
      最近更新 更多