Reputation: 57
I read a program with the following definition:
type 'a queue = ('a list * 'a list) ref
I do not understand the syntax here. Is it a union or what?
Upvotes: 0
Views: 643
Reputation: 31479
This is a synonym/alias. The type ('a list * 'a list) ref
already makes sense in OCaml (it is a reference to a pair of lists of type 'a
), we are giving it a new, shorter name, 'a queue
. More precisely, queue
is the name of a parametrized type, and the parameter is named 'a
here.
Upvotes: 2