Skip to content

Commit 611da16

Browse files
committed
Mention the new type system in typespecs doc
1 parent ffbe286 commit 611da16

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/elixir/pages/references/typespecs.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
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+
>
10+
> Typespecs will be phased out as the set-theoretic type effort moves forward.
511
612
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:
713

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

4955
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
5056

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

5366
type ::

0 commit comments

Comments
 (0)