Home

closedtypes

Closedtypes are a concept in type theory and programming language design used to describe type expressions that contain no free type variables. A closed type is self-contained: all type variables appearing inside the expression are bound by a surrounding quantifier or by the typing context. In contrast, open types include free type variables and therefore depend on external type assignments.

Formally, a type expression is closed if it has no occurrences of type variables that are unbound.

The concept is related to the broader idea of closure in type formation. A closed type remains

In practice, many languages distinguish between concrete/closed types and generic/open types. For example, monomorphized code often

For
example,
in
many
languages,
concrete
types
such
as
Int,
Bool,
or
List
Int
are
closed,
as
they
do
not
rely
on
any
unspecified
type
parameters.
A
type
like
List
a
or
(a
->
b)
is
open
because
it
contains
free
type
variables
a
and
b.
In
polymorphic
systems,
universal
quantification
can
transform
an
open
type
into
a
closed
type
scheme,
but
there
is
a
distinction
between
a
closed
type
(no
free
variables
after
instantiation)
and
a
type
scheme
(which
may
introduce
quantified
variables).
valid
under
substitutions
of
its
bound
variables
and
does
not
require
additional
context
to
be
interpreted.
This
property
is
useful
during
type
checking,
code
generation,
and
optimization,
since
closed
types
can
be
reasoned
about
independently
of
external
type
assignments.
Open
types,
by
contrast,
usually
require
instantiation
or
generalization
before
they
can
be
fully
analyzed
or
emitted
into
code.
uses
closed
types,
while
generic
functions
may
operate
over
open
types
via
type
parameters.