Crowdhailer

Crowdhailer

Creator of Raxx

OK: Elegant error handling for elixir pipelines. Version 1.0 released

I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention.

Assuming you have a double function with the spec double(int()) :: {:ok, int()} and safe dividing function. safe_div(int(), int()) :: {:ok, int()} | {:error, term()}.

Ok now can be used to create a pipeline that looks very much like the native pipe operator.

      iex> {:ok, 6} ~>> safe_div(3) ~>> double
      {:ok, 4.0}

      iex> {:ok, 6} ~>> safe_div(0) ~>> double
      {:error, :zero_division}

I have opened a pull request for this new version and pushed a release candidate. Hopefully it’s now interesting to people.

Most Liked

Crowdhailer

Crowdhailer

Creator of Raxx

Just pushed a 1.0 release to hex.

Crowdhailer

Crowdhailer

Creator of Raxx

Version 0.2.0 released.

I will make a 1.0 release soon as there is almost no API to decide on. The one change that I think perhaps should be made is renaming the OK module to Ok so is follows mix patterns for capitalization?

OvermindDL1

OvermindDL1

I’d recommend Ok as well as it is common vernacular now. However, OK is correct as it is short for (what is considered by etymologists(sp?)) Oll Korrekt, a vernacular of “All Correct” popularized in 1840’s New York (told to me by google ^.^). :slight_smile:

So, although I tend to use Ok myself, technically OK is correct. :slight_smile:

Where Next?

Popular in Announcing Top

tmbb
PhoenixWS - Websockets over Phoenix Channels Source code on Github here: GitHub - tmbb/phoenix_ws: Websockets implemented over Phoenix Ch...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43657 311
New
Crowdhailer
The latest release of Ace (0.10.0) includes serving content over HTTP/2. I have started writing a webserver to teach my self more about...
New
kip
ex_cldr provides localisation and internationalisation support based upon the data from the Unicode CLDR project. Unicode released CLDR ...
407 13056 120
New
kip
Image is an image processing library for Elixir. It is based upon the fabulous vix library that provides a libvips wrapper for Elixir. I...
622 19010 194
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
144 10483 141
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
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
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42158 114
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
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
New

We're in Beta

About us Mission Statement