Trying to avoid more layers since the string thing is being imposed by a behavior.
Where would be the place to discuss bringing this to Erlang? On Sunday, February 13, 2022 at 6:15:45 PM UTC-5 José Valim wrote: > 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 <[email protected]> wrote: > >> 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 to_string(%AccountClosed{}) :: "account_closed" >> @spec to_string(struct()) :: no_return() >> ``` >> >> This will help the documentation much better, while also keeping the >> typespec closer to what the intention was. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/147aa05a-be3d-4f32-aab8-13a1938341b0n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/elixir-lang-core/147aa05a-be3d-4f32-aab8-13a1938341b0n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/34c89285-e70d-4aec-ab08-d736ebaf7bf8n%40googlegroups.com.
