问题
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