Latest #macro Threads 
For those of us still caring about the code readability (in the age of LLMs), this tiny library can replace nested ifs in situations when...
New
I have a macro that expands into a module definition. The use case is that we take a testcase defined in one elixir module (parent) and m...
New
Hi,
I am wondering thy elixir added parens at the end not just simply changed \* to + and + to \*
Interactive Elixir (1.19.1) - press C...
New
There is an example in Ash Framework of adding a resource Album into Music domain
mix ash.gen.resource Tunez.Music.Album --extend postgr...
New
As the title says: is it possible to verify that a parameter to a macro is a typespec? As I understand it, a macro receives the ASTs as p...
New
Hello, so I was wondering if something like newtypes is possible in Elixir and found something that does it but I THINK (correct me if I’...
New
Recently I was in a conversation with José Valim where I happened to mention that I find myself writing code like this:
X = if COND, do:...
New
I am trying to write custom logger , as I am tired of writing Logger.xyz() and then interpolate and inspect some variable.
Trying to ach...
New
I’m working on a macro to support automatic timing for functions.
If I have this - say:
def double(x) do
x + x
end
I would like to b...
New
In order to only have one branch of code in a macro that defines functions with support for guards, I would like to always have a guard. ...
New
This Week's Trending
This Month's Trending
For those of us still caring about the code readability (in the age of LLMs), this tiny library can replace nested ifs in situations when...
New
This Year's Trending
There is an example in Ash Framework of adding a resource Album into Music domain
mix ash.gen.resource Tunez.Music.Album --extend postgr...
New
I have a macro that expands into a module definition. The use case is that we take a testcase defined in one elixir module (parent) and m...
New
Hi,
I am wondering thy elixir added parens at the end not just simply changed \* to + and + to \*
Interactive Elixir (1.19.1) - press C...
New
As the title says: is it possible to verify that a parameter to a macro is a typespec? As I understand it, a macro receives the ASTs as p...
New
Last Three Year's Trending
I’m having a bit of trouble wrapping my brain around how I would pass a dynamic fragment to ~p inside a macro:
defmacro __using__(opts) ...
New
I need to access the application name under which a module was defined, in other words, I need the name defined in the module’s parent mi...
New
Can Elixir code detect whether it is executing at compile time? I would like to write something like the following macro:
defmacro foo()...
New
Hello friends,
I want to create a module inside another module with an atom name:
For example:
defmacro sub_field(name, _type, opts \...
New
Is there any way to override functions generated by a use macro when those functions have NOT been tagged as defoverridable?
I’m tapped ...
New
Hi everyone, I want to create a macro, and this macro should check is there a specific function inside the module is using this macro or ...
New
I have a question regarding a code snippet from part 6 of a really great Macros guide by @sasajuric.
This question specifically ranges f...
New
Hex: bin_struct | Hex
Git: GitHub - 4ait/bin_struct
Docs: bin_struct v0.2.34 — Documentation
BinStruct is a library which main functio...
New
I’m working on a macro to support automatic timing for functions.
If I have this - say:
def double(x) do
x + x
end
I would like to b...
New
Summary
I’m trying to create a macro that takes in input a module name and automatically creates a defdelegate for each function defined ...
New
Hello friends, I do not think this problem of mine exists in production build ( I did not test it), but in developer mode iex -S mix.
im...
New
I have this weird behaviour with quoting n in iex. (1.14.3-otp25 on mac)
iex(1)> ast = quote(do: n)
{:n, [if_undefined: :apply, conte...
New
Hi!
I’m trying to avoid redundant testing (that means, tests that are made in the same way all the time but with slightly different para...
New
In order to only have one branch of code in a macro that defines functions with support for guards, I would like to always have a guard. ...
New
I am currently stuck in implementing a macro :thinking: Here’s the code I currently have (without unnecessary code):
defmacro request(op...
New
Trending Over Three Years
defmodule Bar do
@after_compile __MODULE__
defmacro __before_compile__(_env) do
IO.inspect("#{__MODULE__}.__before_compile__")
...
New
Suppose we’ve got the following module:
defmodule TestModule do
defmacro test_macro(param1, param2, param3) do
quote do
para...
New
Background
So, I am playing around with a concept named “NewType” and I am taking inspiration from languages like F# and Scala.
My objec...
New
This is my first time I am looking at macros. I think I understand they are something like “pre generation” of code. Maybe something li...
New
Summary
Is there any way to write a function which can be invoked in compile time and which can return an AST and Macro.Env of given func...
New
Hello, I want to load a alias under my __using__, but with opts help like this:
defmacro __using__(opts) do
quote(bind_quoted: [opts: ...
New
Hey,
I’m currently trying to DRY up some tests which have a lot of boilerplate code in the form of:
test "user is updated", %{user_id: ...
New
Is there a way to put more functions into __using__ block? It gets very long and hard to read. I cannot figure out how to split up the ...
New
Hello there,
I have the following scenario:
I have a library my_lib that is used in my_app. my_lib has a configuration file option that...
New
For a library, we get the list of all Ecto Schema modules of the user’s app, and want to generate functions (through macros) into a modul...
New
How can I create a macro that defines a type using atom that represents the type name? In the macro __type__ below, for the visibility a...
New
Hi everyone!
I’m searching for a hint for a problem I cannot understand if it is in my code or a third party misbehaviour.
I’m currentl...
New
I’d like to use the ~E sigil inside of a macro. For some reason the assigns variable is not accessible:
defmacro __using__(_opts) do
q...
New
Hi friends, I have a nested list that is unstructured, and I really know how much it has nested list or map in itself.
I just need to se...
New
I have an operator in a variable, for example:
guard = &Kernel.>=/2
How can I use that variable as argument to a macro, e.g. for...
New
Latest on Elixir Forum
Get money off!
The Pragmatic Bookshelf
35% off any eBook
Manning Publications
45% off any item
ElixirCasts
10% off for life
The Pragmatic Studio
20% off any course
AppSignal
10% off for 12 months
Honeybadger
10% off for 12 months
Simply use coupon code "devtalk.com" or "elixirforum" at checkout!
Filter by Type:
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #exunit
- #elixirconf
- #discussion
- #javascript
- #podcasts
- #code-sync
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #api
- #processes
- #forms
- #metaprogramming
- #security
- #performance
- #hex







