4 ms·
> Elixir is overall a syntax that works well for me, at least as well as Rust’s. The Elixir team have made great strides in providing good compiler error messag
by _asummers 8y ago
> Elixir is overall a syntax that works well for me, at least as well as Rust’s. The Elixir team have made great strides in providing good compiler error messages, and are actively improving the distribution/ packaging story. Hex and mix are fantastic, and on par with what I’ve use in cargo.
I'm working on making the dialyzer error messages better, too, in Dialyxir[0] and Erlex[1] =).
[0] https://github.com/jeremyjh/dialyxir https://github.com/jeremyjh/dialyxir
[1] https://github.com/asummers/erlex https://github.com/asummers/erlex
- elcritch 8y agoWow, thanks! I’ve kept up with your project and greatful for the work. Out of curiosity, have you seen anything in Dialyzer for dealing with typing GenServer messages and handlers? I haven’t figured out a way to spec message handlers as dialyzer seems to only check that you have any `handle_cast` implemented and adding a behavior doesn’t compose. Given the key role GenServer plays in OTP, it’s a big lack IMHO. I’ve wondered if the new named guards in Elixir could help with it somehow.
- _asummers 8y agoNah because as soon as you deviate from the GenServer behaviour you'll get errors from not matching the @callback. The trick there is to provide a narrower API that calls into the GenServer functions with the proper @spec and treat the handle_cast and friends as private functions that you don't call directly. So like a pop/0 might call cast(:pop) and you'd have the associated handle_cast for :pop.
- elcritch 8y agoYah, that's the error I ran into. Creating function wrappers to send messages works well for client api's. However, it doesn't help verify that you've implemented the `handle_cast` properly or dealing with messages from other places. Normally it's not to big of an issue.
- _asummers 8y agoYeah ideally those APIs are well scoped enough to be able to unit test them, but I agree there's some piece missing there.