iacobson
1 min readMar 3, 2018

--

Yes, I agree with you. I think Elixir offers enough tools to do things a bit differently and has its own Elixir way, which I love.

As said in some responses above, this is more of an experiment of applying some functional concepts to Elixir.

On the other hand, your example above works very well for cases where we do not care that much about the error itself. If we need to parse and report the error, it can get a bit more complicated than this, but still achievable with multi head functions.

Example, in the last example of the article, decode_response/1 needs to know how to handle {:ok, %HTTPoison.Response{body: body, status_code: 401}} as well as {:error, …} and treat them differently. It just gets a bit more verbose.

--

--

Responses (1)