In cases where your results are based on a single function returning an 
ok/error tuple, the size of the tuple will be the same every time, allowing 
you to use a plain `Enum.filter`, like Chris already mentioned.

In cases where results in your enum are based on various different 
functions and you might end up having differently-sized tuples in your 
enumerable, then you should probably refactor this so it becomes normalized 
again.
Or, if you don't want to, there are a couple of libraries that already 
allow the functionality that you are looking for.
My own contribution in this regard is the library Solution 
<https://github.com/Qqwy/elixir-solution>, which has a Solution.Enum 
<https://hexdocs.pm/solution/Solution.Enum.html> module with functions like 
`oks`, `combine` (which returns a list of all OK-values, or the first 
encountered error), etc.
I know that besides Solution and MonEx which was mentioned earlier in this 
topic, at least the libraries Witchcraft, FunLand, OK, Exceptional, OkJose, 
HappyWith, ElixirMonad and Towel try to do similar things to make working 
with ok/error tuples (inside pipes and/or enumerables) easier.

On one hand this does make it seem that maybe there is something there that 
is so general and ubiquitous that the standard library should adopt it.
On the other (and this is the direction I currently lean towards), it's 
perfectly fine and nice to have so many different, user-maintained, 
approaches where for each project the best fit can be chosen.

So no, I don't think we should add this.


~Marten / Qqwy

-- 
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/3f284a8c-39b0-49ab-a598-2856e8116b02%40googlegroups.com.

Reply via email to