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!

  1. strings in erlang lists of integers correspond ascii code of characters (i.e. "qwe" = [$q,$w,$e] = [113,119,101]).
  2. the type language cannot express order of list's elements (and not aim so).
  3. the type got of "a nonempty list containing numbers 101, 113 , 119", close inference can get.

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -