cgarciae
Hi,
I want to propose an extension to the language that enables it to express branched computations using the pipe |> operator. Here is a basic example of how it could be used:
def add(a, b), do: a + b
def mul(a, b), do: a * b
...
assert [4, 7, 20] ==
2
|> [
add(2),
add(5),
mul(10)
]
As you see the essence would be to be able to pipe into a list with operations, and the piped value is distributed among the operations in the list, and a list is returned. The previous would be equivalent to:
assert [4, 7, 20] ==
[
2 |> add(2),
2 |> add(5),
2 |> mul(10)
]
I am bringing this idea from a python library I made for TensorFlow where I implement a small DSL to achieve this. You can view an example here: GitHub - cgarciae/tensorbuilder: TensorBuilder is a TensorFlow library enables you to easily create complex deep neural networks by leveraging the phi DSL to help define their structure. · GitHub
Trending in Discussions
Hey folks,
I wanted to share with you a project I’ve been working on for a while: It’s an Open Source (AGPLv3) newsletter tool. Think Ma...
New
Hi there! :wave:
@frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
Hi everyone,
I have 8 years of production experience with Erlang/OTP and I’m just starting to get to know Elixir. What would you learn f...
New
A note on form. Joe Armstrong, co-creator of the Erlang programming language, died in April 2019. What follows is a work of narrative non...
New
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Eiji
@cgarciae: How about this code:
In your case it will look like:
OvermindDL1
Or even like this so it is more traditionally pipe’y:
And used like:
Side Note: I’m noticing a lot of replies to old posts that have no replies, just trying to answer old posts or so?
Eiji
@OvermindDL1: Good macro, but it’s a little bigger code, anyway good job!
Today, I have more time so I decided to at least try to answer for as much unanswered questions as possible (no matter if old or not).
btw. It could be helpful if I could sort by 2 or more columns … For example firstly sort by replies count and then sort by category.
OvermindDL1
Yep, but it gives a more natural piping syntax. Could even change it up more too, like by another operator or something, or just parenthesis ‘sub-piping’ or so.
Cool.
The discourse API is pretty simple (simple JSON endpoints) so no capability sadly. We need a new Discourse, written in Elixir, that uses GraphQL instead of plain JSON.
OvermindDL1
Could do a wrapper around the pipe too:
Used like:
Or could just outright replace the pipe too with a macro…