Erlang's typer deduced weird types for strings -
i'm exploring typer, , gave function nothing but:
const_str() -> "qwe".
that guy's type deduced as:
-spec const_str() -> [101 | 113 | 119,...]
, i.e. "eqw" (huh?!), followed '...' business.
it looks constant strings confusing typer; understand shouldn't using them this, there atoms purpose; trying wrap head around typer (and erlang's type options), thought surprising , interesting. explain what's happening here? thanks!
- strings in erlang lists of integers correspond ascii code of characters (i.e.
"qwe" = [$q,$w,$e] = [113,119,101]
). - the type language cannot express order of list's elements (and not aim so).
- the type got of "a nonempty list containing numbers 101, 113 , 119", close inference can get.
Comments
Post a Comment