Set types in Disco [006X]

The type of a finite set with elements of type T is written Set(T). For example:

Disco> :type {1,2,3}
{1, 2, 3} : Set(ℕ)
Disco> :type {T, F}
{T, F} : Set(Bool)

All the elements in a set have to have the same type. For example, this is an error:

Disco> {1, T}
Error: typechecking failed.

However, we can mix and match different numeric types, and Disco will just give them the smallest type that works for all of them.

Disco> :type {1,2}
{1, 2} : Set(ℕ)
Disco> :type {3, 4, -5}
{3, 4, -5} : Set(ℤ)
Disco> :type {2, 1/2}
{2, 1 / 2} : Set(𝔽)
Disco> :type {2, -1, 3, 5/2}
{2, -1, 3, 5 / 2} : Set(ℚ)

If we ask for the type of the empty set, Disco responds with Set(a): the a here is a variable that can stand for any type. This is our first example of polymorphism.

Disco> :type {}
{} : Set(a)