Using Types and Typespecs in Elixir

Elixir is a dynamically types language, so it does not perform type checks at compile time. However, it does provide a notation for declaring types and function specifications that can be used when generating documentation or with static analysis tools like Dialyxir.

Elixir/erlang have a number of basic types, and Elixir takes this further by providing some built-in types of its own. You can also document and define your own compound types. Typespecs allow us to type the input and outputs of a function, and run static analysis on our code to make sure that we conform to that contract. In this video, we’ll show how to use the existing types, define compound types, write typespecs, and use Dialyxir to enforce the contracts.

Sign up for our newsletter

Get notified of any new episodes as we release them.

© 2020 QuantLayer, LLC. All rights reserved.