Skip to content

Commit c60ba22

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

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/elixir/pages/references/typespecs.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
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+
Elixir is in the process of implementing its [own type system](./gradual-set-theoretic-types.md) based on set-theoretic types. Typespecs, which are described in the following document, are a distinct notation for declaring types and specifications based on Erlang.
4+
5+
Typespecs will be phased out as the set-theoretic type effort moves forward.
56

67
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:
78

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

4950
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
5051

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

5361
type ::

0 commit comments

Comments
 (0)