Crowdhailer

Crowdhailer

Creator of Raxx

How are you using OK for control flow?

This week I was reading this article from @rrrene on the use of with vs |> for control flow. I enjoyed the article and many of the points it made. In my opinion with is not the best for error handling, although it is great for several other composition usecases.

It got me thinking about how I use a library I have written called OK.

The quick summary is that OK provides helpers for composition but explicitly for the cases when errors are being handled. First is OK.try which is similar to with but strictly for working with :ok/:error tuples. Second is ~>> which replaces |>. Again its use is strictly for handling result tuples.

See the README for more info.

This library is now regularly receiving more than 100 downloads per day and some of you must be among those.

I am interested in hearing about people have been using of this library.

  • Do you find it easy to add to existing code or does it force you to change your code?
  • Is that change beneficial?
  • Do you care that understanding monads influenced the design?

My answer

I find it has forced me to change my code, and I find that in most cases that is beneficial.
However as much as I like the pipeline ~>> approach I most real world situations I have found that too constraining and for 90%+ uses I reach for the other tools in the library.

Most Liked

Architect

Architect

Looks interesting. I’ll give it a try.

Crowdhailer

Crowdhailer

Creator of Raxx

Awesome, let me know how it goes

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement