user2821649
user2821649

Reputation: 57

OCaml: type definition syntax

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

Answers (1)

gasche
gasche

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

Related Questions