On Tuesday, April 16, 2019 at 3:04:13 PM UTC-6, [email protected] wrote:
>
> It is often the case that you want to wrap the result of an operation in 
> an ":ok" or ":error" Tuple. We should add convenience wrapper functions 
> since this is so common and it cleans up otherwise ugly code.
>
> def ok(value), do: {:ok, value}
> def error(value), do: {:error, value}
>

This could be quite useful!  On the other side it would be useful to add 
functions like these as well:

def ok!({:ok, value}), do: value

def ok?({:ok, _value}), do: true
def ok?(_), do: false

And so forth for error as well.  They are not really useful on their own 
because matching is better, but for use in pipes that would be quite useful 
(right now I use the exceptional library, which does similar things and 
more).

-- 
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/30614530-7e33-4cb8-bffb-63c18248d340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to