4 ms·
Yeah, I mean that it will properly identify that the only time you can do that is when you have an empty list. The final spec will be (in elixir syntax):
by dnautics 6y ago
Yeah, I mean that it will properly identify that the only time you can do that is when you have an empty list. The final spec will be (in elixir syntax):
(nonempty_list, number -> number) | ([], any -> any)
It should also be able to correctly infer that the count/1 function must be
(nonempty_list -> pos_integer) | ([] -> 0)
- Joker_vD 6y agoI am using an old version of erlang, so typer infers the following types: -spec count([any()],_) -> any(). -spec count([any(),...]) -> any(). If I unexport count/2, it infers -spec count([any(),...]) -> non_neg_integer(). -spec count([any()],non_neg_integer()) -> non_neg_integer().
- dnautics 6y agoI did say "should be able to" without regard to any of the existing type inference engines =D I'll be sure to make this as explicit test in Mavis Inference, which is the one I'm working on. https://github.com/ityonemo/mavis_inference/issues/47 https://github.com/ityonemo/mavis_inference/issues/47