'int 是什么?树'在 SML 错误消息中是什么意思? [英] What does 'int ?. tree' mean in an SML error message?

查看:36
本文介绍了'int 是什么?树'在 SML 错误消息中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一个班级编写了以下 SML 代码:

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)

在测试中:

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

并返回以下错误:

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))

?. 是什么意思?

推荐答案

这通常与跨模块的可见性受限有关.你的树"定义是什么样的?您可能需要告诉编译器您在一个模块中的树"类型与另一个模块中的相同.

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.

这篇关于'int 是什么?树'在 SML 错误消息中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆