Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用以下代码在 OCaml 中创建一组元组
let (k : (string*string) Stack.t) = Stack.create ;;
但是这样做时我在编译告诉时出错
Error: This expression has type unit -> 'a Stack.t but an expression was expected of type (string * string) Stack.t
我对 OCaml 很陌生。有人可以指出我哪里出错了吗?
Stack.create是一个函数,它接受值()(类型unit)并给你一个堆栈。
Stack.create
()
unit
所以你应该这样做:
let (k : (string*string) Stack.t) = Stack.create ();;
如果你写Stack.create,你只是在谈论功能,而不是结果。