Nice article. I find myself tending toward a combination of simple ok/error tuples and bang methods. Kinda like so:
@spec foo() :: {:ok, any} | {:error, String.t} @spec foo!() :: any | no_return
It was the with keyword that appeared in Elixir 1.3 that convinced me tagged tuples were the way, it’s such an easy and composable way to get the Either pattern (as long as your functions play along).
with
Nice article. I find myself tending toward a combination of simple ok/error tuples and bang methods. Kinda like so:
It was the
withkeyword that appeared in Elixir 1.3 that convinced me tagged tuples were the way, it’s such an easy and composable way to get the Either pattern (as long as your functions play along).