Personally I don’t see where it is better. I like when type annotations aren’t merged to declaration like it is in Erlang, Elixir, Elm and Haskell.
It seems like you’re trying to write Python (I see it in your profile) in Elixir.
@fuelen The fact that you don’t like it is a valid opinion, and I can totally accept it as it is) The problem I’m solving is kind of obvious: sometimes you need to mention a variable in a function definition 3 times: in function signature, in the guard and in @spec. What I propose, though being a macros, carries little semantic payload as it intuitively clear what is the long way of writing this.
Imho there is nothing wrong with trying approaches from language X in language Y, is it?
It’s in progress. Been working on it as part of my “holiday coding sabbatical” that I do every year
(Check the tests in the “collections” branch for usage)
Almost done with basic types, still need to do some recursive type testing, user defined (not sure if trivially possible) and remote types. Still need to only inject checking in dev and test, and also still need to allow suppression of non-guard tests (it does deep testing on lists and maps) on a module or function by function basis
You can issue multiple @specs and it works fine. (I think)
Also I think in Elixir, mentioning variable name in the typespec is slightly preferred since it gives hints to ex_doc, but I’m not certain about that
Yay, I checked it out briefly, and I like it. I didn’t want to override [def: 2] because somebody else could also do this (for a little and harmless trick) in his function and it all will break. Also, probably, it makes sence to be more close to existing @spec syntax, and to write x :: integer() instead of x :: integer