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

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
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

We're in Beta

About us Mission Statement