I'm porting an Elixir library to Elm that uses type specs heavily but I'm having trouble finding documentation on some of the syntax used.
What is the following type expression expressing?
@type identifier :: (String.t | MyCustomTypeA.t | MyCustomTypeB.t)
Initially I modeled it as a tuple but now that I'm looking at it's usage it looks as though it may be a Discriminated Union. The problem with this assumption though is that I don't see any documentation for support of such things here (http://elixir-lang.github.io/getting-started/typespecs-and-behaviours.html).
You are correct in that it's a Discriminated Union. Neither the Elixir nor Erlang docs call it out directly but it can be inferred from the more in-depth docs (https://hexdocs.pm/elixir/typespecs.html)
The only real call-out to this is the line
In your example, the parenthesis are not required. You could also write it as
and it means that
identifiercan be either aString.t, aMyCustomTypeA.t, or aMyCustomTypeB.tElixir inherits this from Erlang and it's well explained in Learn you some Erlang for great good
(please remember that while Elixir builds on Erlang the syntax differs a bit)