OCaml Stack of tuples

2019-07-17 03:30发布

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条回答
女痞
2楼-- · 2019-07-17 04:09

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.

查看更多
登录 后发表回答