OCaml Stack of tuples

放肆的年华 提交于 2019-12-24 02:23:28

问题


I am trying to create a stack of tuples in OCaml using the following piece of code

let (k : (string*string) Stack.t) = Stack.create ;;

But when doing so i get an error while compiling telling

Error: This expression has type unit -> 'a Stack.t
   but an expression was expected of type (string * string) Stack.t

Am pretty new to OCaml. Can someone point out where I am going wrong?


回答1:


Stack.create is a function which takes the value () (of type unit) and give you back a stack.

So you should do:

let (k : (string*string) Stack.t) = Stack.create ();;

if you write Stack.create, you just speak about the function, not the result.



来源:https://stackoverflow.com/questions/12466841/ocaml-stack-of-tuples

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