kanishka

kanishka

Learning resources about dialyzer?

I am trying to build up my instincts for what errors dialyzer catches and what errors it doesn’t catch. Are there existing articles or videos that dive deep into Dialyzer and typespecs from a user perspective? I am hoping to avoid articles that go into the implementation of dialyzer.

Most Liked

BartOtten

BartOtten

If I recall correctly this video did help me a lot. It helps you think like Dialyzer which makes it easier to understand why it (does not) reports an error: Stavros Aronis - What does Dialyzer think about me? | Code BEAM STO 19 - YouTube

garazdawi

garazdawi

Erlang Core Team

While it in some parts is a bit heavy to read, the original paper on success typing contains a lot of information and if you understand what success typing is (and what it is not), then deciphering the error messages becomes easier.

BartOtten

BartOtten

Dialyzer is never wrong. When it knows an spec mismatch will happen in any case, it will report an error. If it might happen, it won’t as the conditions in which the function returns a non matching type might never occur. After all: you as a developer might call the function only in a way that makes it matching.

Example

@ spec foo(arg :: integer) :: :ok
def foo(arg) when is_integer(arg) do
   case arg do
     1 -> :ok
     _other -> :error
 end
end

You might think Dialyzer should/would warn that :error is not in the spec.

However, Dialyzer thinks different:

Maybe this function is only ever called with foo(1); then there is no issues at all as indeed it only will return :ok. I will not raise an issue.

There are flags to tune this behavior but their usage might cause other ‘issues’ so those are false by default.

kokolegorille

kokolegorille

In case You want to catch something like this, You could do

   case arg do
     1 -> do_ok()
     _other -> do_error()
 end

and give spec to the do_ok, do_error functions, as mentionned in this previous post

kanishka

kanishka

The video was helpful. I wish the speaker had continued for another thirty minutes and showed some examples of errors that Dialyzer wouldn’t catch.

Where Next?

Popular in Chat/Questions Top

Iex.new
Hello!, I just started this week to discover Elixir. I’m a PHP-Programmer and did some sutff in Go too. The more I read about Elixir t...
New
New
Yoga
Or at least, in the works? All I can find are bits and pieces but not a single project from start to finish. Including things like i18n,...
New
asfand
I am Asfandyar from Pakistan. This is my first time to the forum. I develop PHP websites using CodeIgniter, which is super easy to learn...
New
jslearner
Will learning Erlang really help in being a better Phoenix or Elixir developer or is it a waste of time?
New
New
pdgonzalez872
Do we have a list of academic/research papers: about Elixir/Erlang? that use Elixir/Erlang? about the Beam? If so, could you please po...
New
Twfo326
As a novice dev I’m trying to keep the curriculum as lean as possible. My requirements are modest: build simple CRUD apps with Phoenix...
New
koen_vb
Hi, I was looking for a pointer of how I could most easily start with phoenix regarding deploying it to something like linode or google c...
New
shansiddiqui94
Greetings Elixir Developers, My name is Daniel, and I am taking my first step to learn all about the Elixir language. Currently I have a...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
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
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement