Does Elixir have sum types?

I am confused as discussed here (Better domain modeling in Elixir with sum types). Does Elixir have sum types like in languages like F#?


No, not natively. Most people simulate them with tagged tuples – {:ok, value} is a classic case – but the compiler does not enforce exhaustiveness in any way. If you need some guarantees you’ll have to use Dialyzer and put @spec-s on your functions.


I understand. Thank you.