Get the latest tech news

Typing lists and tuples in Elixir


This article explores the design decisions of typing lists and tuples in Elixir within a sound gradual type system

While many programming languages provide functions to compose option values, one may also get rid of the additional wrapping and directly pattern match on the list instead. Both examples above are limited by the fact the type system cannot distinguish between empty and non-empty lists and therefore their handling must happen at runtime. If we completely remove elem/2 from the language and you can only access tuples via pattern matching (or by adding a literal notation such as tuple.0), then all possible bugs can be caught by the type checker.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of lists

lists

Photo of elixir

elixir

Photo of tuples

tuples

Related news:

News photo

Defenders think in lists, attackers think in graphs (2015)

News photo

How Diaries Evolved from Lists to Personal Histories

News photo

Unification in Elixir