Re: [elixir-core:10777] [Proposal] Allow String Literal in the TypeSpec

2022-02-13 Thread José Valim
Type specs are restricted to what Erlang allows. So unless this is added to Erlang, which I hardly see happening, it can’t be added to Elixir. It also feel like atoms could be a better fit here. Convert the strings to atoms at the edge of the system. On Sun, Feb 13, 2022 at 23:55 Yordis Prieto

[elixir-core:10777] [Proposal] Allow String Literal in the TypeSpec

2022-02-13 Thread Yordis Prieto
I would like to be able to do the following in my typespec: ``` @spec to_struct("account_created") :: %AccountCreated{} @spec to_struct("account_closed") :: %AccountClosed{} @spec to_struct(String.t()) :: no_return() @spec to_string(%AccountCreated{}) :: "account_created" @spec