Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It depends on what you are struggling with. If you want formal type documentation and some decent type checking, Dialyzer is pretty good. That’s really the only solution for Elixir.

If you want full static type checking, there is https://gleam.run/ which is a new language, and there’s also something that seems like a full static type checker for Erlang which is going to be released by Facebook soon (they use it internally). See this: https://elixirforum.com/t/facebook-is-writing-a-new-statical....

I, for one, am hoping that the Facebook solution allows us to implement something in Elixir to interface with it so that we can take advantage of it in Elixir, but that is yet to be seen.



I've been using Dialyzer and it works well enough most of the time. Maybe the Elm compiler spoiled me, but when Dialyzer tells me "this pattern will never match" and not offer me tools to fix it, it's very frustrating. I'm not sure if it's possible, but it would be nice to have an action to autocomplete missing patterns like in Elm / Rust.

That said, I'll take a look at Gleam. Thank you


Dialyzer messages can be pretty obtuse. Usually I take it as a cue to just re-read the function and it's often somewhat clear where the problem lies due to immutability (not always though).

Another trick I'll do, is to use (abuse) pattern matching:

    def foo(%SomeStruct{} = arg, value) when is_integer(value) ...
That also helps Dialyzer narrow down possibilities too and will blow up on runtime.

If you use VSCode, the ElixirLS module will auto-suggest @spec's for your functions.


Yeah the big problems with Dialyzer are that it can be slow at times and that the error messages are not great. However, a lot of the error messages are the same esoteric messages, and you can get used to debugging them when you know what they are trying to call out.


Hello! I'm the creator of Gleam.

From talking to the WhatsApp Erlang team a little it seems unlikely unlikely that the Erlang type checker will be usable with Elixir I'm afraid.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: