Skip to content

Commit 4def31f

Browse files
committed
Mention the new type system in typespecs doc (#14188)
1 parent 88c75bc commit 4def31f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Diff for: lib/elixir/pages/references/typespecs.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Typespecs reference
22

3-
Elixir comes with a notation for declaring types and specifications. This document is a
4-
reference into their uses and syntax.
3+
> #### Typespecs are not set-theoretic types {: .warning}
4+
>
5+
> Elixir is in the process of implementing its
6+
> [own type system](./gradual-set-theoretic-types.md) based on set-theoretic types.
7+
> Typespecs, which are described in the following document, are a distinct notation
8+
> for declaring types and specifications based on Erlang.
9+
> Typespecs may be phased out as the set-theoretic type effort moves forward.
510
611
Elixir is a dynamically typed language, and as such, type specifications are never used by the compiler to optimize or modify code. Still, using type specifications is useful because:
712

@@ -48,6 +53,13 @@ The syntax Elixir provides for type specifications is similar to [the one in Erl
4853

4954
The notation to represent the union of types is the pipe `|`. For example, the typespec `type :: atom() | pid() | tuple()` creates a type `type` that can be either an `atom`, a `pid`, or a `tuple`. This is usually called a [sum type](https://en.wikipedia.org/wiki/Tagged_union) in other languages
5055

56+
> #### Differences with set-theoretic types {: .warning}
57+
>
58+
> While they do share some similarities, the types below do not map one-to-one
59+
> to the new types from the set theoretic type system.
60+
> For example, there is no plan to support subsets of the `integer()` type such
61+
> as positive, ranges or literals.
62+
5163
### Basic types
5264

5365
type ::

0 commit comments

Comments
 (0)