Qqwy

Qqwy

TypeCheck Core Team

Beautiful Pipelines

Inspired by this topic I thought it might be interesting to talk about what pipelines we have encountered in the wild:

  • Whenever you come across a piece of code featuring a pipeline that you think is cool or elegant, feel free to share.
  • Also, feel free to share code snippets in which you feel that it might have been better not to use a pipeline but another abstraction.
  • And feel free to politely comment on and discuss the submissions written by other posters. Do you agree/disagree? What would you have done differently? :slight_smile:

Note: A with-chain can also be considered a kind of pipeline and be posted here, if you’d like.


All right, let’s start off:

This is a very simple example, part of the tensor library (for vectors, matrices and higher-dimension tensors) that I wrote a couple of years back.
What I like about this pipeline, is that is very clear to the reader what is going on. In most other languages, this would have to be written either in one line, or by using a temporary variable with probably a hard-to-choose name. The only other, non-pipeline approach I see, is to introduce an as_transposed wrapper that takes a function pointer, and does both the transposition and back under the hood. Maybe that’s nice for some other languages, but in Elixir, where we have this potential to produce pipelines (aliteration intended), it is definitely overkill.

Most Liked

OvermindDL1

OvermindDL1

Honestly most ‘beautiful’ uses of pipelines involves not changing the underlying container ‘type’ of the value being piped. Although I do a lot of transforming like that in mine, it is indeed harder to follow. Basically using pipes as a monad is the easiest to follow and read, that is really why I think that the monad concept should have been baked into pipelines to help enforce that.

Where Next?

Popular in Discussions Top

AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
restack_oslo
Hello, Please pardon me for any faux paux. I am 46 and this is my first time on a forum of any kind. I wanted to to get answers from tho...
New
MarioFlach
Hello, I want to share a project I’ve been working on for a while: https://github.com/almightycouch/gitgud Background Some time ago I ...
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 14350 124
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
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

We're in Beta

About us Mission Statement