From 611da1664273d519b840051b13786f0d4fa83f0f Mon Sep 17 00:00:00 2001 From: sabiwara Date: Wed, 15 Jan 2025 08:55:10 +0900 Subject: [PATCH 1/2] Mention the new type system in typespecs doc --- lib/elixir/pages/references/typespecs.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/elixir/pages/references/typespecs.md b/lib/elixir/pages/references/typespecs.md index 95eb40253f2..fd64b2bd6dc 100644 --- a/lib/elixir/pages/references/typespecs.md +++ b/lib/elixir/pages/references/typespecs.md @@ -1,7 +1,13 @@ # Typespecs reference -Elixir comes with a notation for declaring types and specifications. This document is a -reference into their uses and syntax. +> #### Typespecs are not set-theoretic types {: .warning} +> +> 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. +> +> Typespecs will be phased out as the set-theoretic type effort moves forward. 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: @@ -48,6 +54,13 @@ The syntax Elixir provides for type specifications is similar to [the one in Erl 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 +> #### Differences with set-theoretic types {: .warning} +> +> While they do share some similarities, the types below do not map one-to-one +> to the new types from the set theoretic type system. +> For example, there is no plan to support subsets of the `integer()` type such +> as positive, ranges or literals. + ### Basic types type :: From d847534652a6dc112a1c9018a137c022ee3ccf1b Mon Sep 17 00:00:00 2001 From: sabiwara Date: Wed, 15 Jan 2025 20:41:00 +0900 Subject: [PATCH 2/2] Apply review suggestion --- lib/elixir/pages/references/typespecs.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/elixir/pages/references/typespecs.md b/lib/elixir/pages/references/typespecs.md index fd64b2bd6dc..49d39f30e24 100644 --- a/lib/elixir/pages/references/typespecs.md +++ b/lib/elixir/pages/references/typespecs.md @@ -6,8 +6,7 @@ > [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. -> -> Typespecs will be phased out as the set-theoretic type effort moves forward. +> Typespecs may be phased out as the set-theoretic type effort moves forward. 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: