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

Isn't Dialyzer's success typing similar to TypeScript in that it's gradual typing? Or am I muddling up my concepts?


It's similar and they are both considered gradual typing, yes. Dialyzer is 'better' in some ways though. For example, consider this TypeScript:

    function f(a) { console.log(a.x); }
    f({});
With the strictest checks turned on ( try it at https://www.typescriptlang.org/play/#src=function%20f(a)%20%... ), TypeScript will give you this message: `Parameter 'a' implicitly has an 'any' type.`

Now consider the equivalent Elixir:

    def test2(), do: f(%{})
    def f(a), do: IO.inspect(a.x)
Dialyzer will give you this message: `Function test2/0 has no local return ... The call 'YourModule':f(#{}) will never return since it differs in the 1st argument from the success typing arguments: (atom() | #{'x':=_, _=>_})`

This is why I said the Dialyzer message takes some getting used to :-) But, it just means that `f` needs to be called with either an atom (because you could pass in a module to the function, and modules are modelled as atoms), or with a map object with the `x` key and possibly some other keys.




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

Search: