josevalim

josevalim

Creator of Elixir

Type system updates: moving from research into development

I hereby officially announce the Elixir type system effort is transitioning from research into development. Read the full-announcement here: Type system updates: moving from research into development - The Elixir programming language

This new exciting development stage is sponsored by Fresha (they are hiring!), Starfish* (they are hiring!), and Dashbit.

Thank you!

638 12690 164

Most Liked

josevalim

josevalim

Creator of Elixir

There are a few details I don’t appreciate about how we implemented typespecs (for example, I find them too verbose) but the deal breaker here is that typespecs are not capable of expressing the proposed type system, so we will need something new.

27
Post #8
lifeofdan

lifeofdan

I had to create an account here just to say how much I love this. This is incredibly exciting!

josevalim

josevalim

Creator of Elixir

The type system allows us to support any literal as type but it is still undecided if we want to do that. Opposite to the Dialyzer, an actual type system will be strict about the expected arguments. Imagine this code:

$ :foo or :bar -> string
def foo_or_bar(:foo), do: ...
def foo_or_bar(:bar), do: ...

Now imagine you call it like this:

foo_or_bar(String.to_existing_atom(string))

Because you are passing any atom to the function, the type system will warn about a type error. While Dialyzer would never warn. So you would need to write this instead:

case String.to_existing_atom(string) do
  :foo -> foo_or_bar(:foo)
  :bar -> foo_or_bar(:bar)
  _ -> raise "expected foo or bar"
end

Therefore, more specific types will require you to prove that you are passing those specific types and that may actually make the type system more annoying than helpful.

Since there are trade-offs here, it is a decision we will make later once we have a better feeling for the type system.

Correct.

Where Next?

Popular in News Top

Elixir
Release: Release v1.11.2 · elixir-lang/elixir · GitHub 1. Bug fixes Elixir [Code] Do not crash when getting docs for missing erts appdi...
New
Elixir
Release: Release v1.10.3 · elixir-lang/elixir · GitHub 1. Bug fixes Elixir [Code] Return [{mod, bin}] from Code.compile_file/2, Code.re...
New
josevalim
Hello folks, Elixir v1.4.0-rc.0 has been released. This is a release candidate for the upcoming Elixir v1.4.0. The most notable changes...
New
Elixir
Release: Release v1.9.0 · elixir-lang/elixir · GitHub Releases The main feature in Elixir v1.9 is the addition of releases. A release is...
New
Elixir
1. Bug fixes Elixir [Duration] Fix parsing of fractional durations with non-positive seconds [Kernel] Do not attempt to group module war...
New
Elixir
This release includes initial support for Erlang/OTP 28, for those who want to try it out. In such cases, you may use Elixir v1.18.4 prec...
New
Elixir
1. Enhancements Elixir [Code] Emit :defmodule tracing event on module definition Mix [Mix] Add Mix.install_project_dir/0 [Mix] Add env...
New
New
Elixir
Today we celebrate 15 years since Elixir’s first commit! To mark the occasion, we are glad to announce the first release candidate for El...
New
Elixir
1. Enhancements Elixir [Duration] Add Duration.to_iso8601/1 and Duration.from_iso8601/1 [Keyword] Add Keyword.intersect/2-3 to mirror th...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

We're in Beta

About us Mission Statement