What does 'int ?. tree' mean in an SML error message?

怎甘沉沦 提交于 2020-01-04 05:14:06

问题


I have the following SML code that I wrote for a class:

fun lookup (cmp: 'a * 'a -> order) (x: 'a, t: 'a tree) : 'a option =
    case t of
      Empty => NONE
    | Node(l,y,r) =>
      case cmp(x,y) of
        EQUAL => SOME y
      | LESS => lookup (cmp) (x,r)
      | GREATER => lookup (cmp) (x,l)

In testing this with:

val SOME 3 = lookup Int.compare (3, Node(Empty,3,Empty));

And getting the following error back:

stdIn:153.1-166.12 Error: operator and operand don't agree [tycon mismatch]
  operator domain: int * int ?.tree
  operand:         int * int tree
  in expression:
    (lookup Int.compare) (3,Node (Empty,3,Empty))

What does the ?. mean?


回答1:


This is usually to do with restricted visibility across modules. What does your 'tree' definition look like? You might need to tell the compiler that your 'tree' type in one module is the same as the one in another module.



来源:https://stackoverflow.com/questions/12830731/what-does-int-tree-mean-in-an-sml-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!