Вопрос

I defined an AVL tree as such, with 'a -> 'a -> int being the comparison function

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

I'm trying to use this AVL module to implement a priority queue in a separate module.

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

But when I try to compile I get this error:

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

What argument is it talking about and what's should the syntax be in the queue type?

Это было полезно?

Решение

Your AVL tree is parameterized by the type in the nodes ('a). So you should be able to say

type 'a t = Queue of ('a Avl.t * int)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top