Latest #macro Threads Top

DaAnalyst
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
Oliver
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
przemyxe0p
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
Petr
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
honungsburk
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
AppleKid7
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
demerphq
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
apoorv-2204
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
MadsBoydMadsen
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
lud
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 Top

This Month's Trending Top

DaAnalyst
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 Top

Petr
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
Oliver
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
przemyxe0p
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
honungsburk
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 Top

sodapopcan
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
fceruti
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
addrummond
Can Elixir code detect whether it is executing at compile time? I would like to write something like the following macro: defmacro foo()...
New
shahryarjb
Hello friends, I want to create a module inside another module with an atom name: For example: defmacro sub_field(name, _type, opts \...
New
fireproofsocks
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
shahryarjb
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
DidactMacros
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
Ridtt
Hex: bin_struct | Hex Git: GitHub - 4ait/bin_struct Docs: bin_struct v0.2.34 — Documentation BinStruct is a library which main functio...
New
MadsBoydMadsen
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
Gigitsu
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
shahryarjb
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
Sebb
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
Moussenger
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
lud
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
janp
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 Top

thojanssens1
defmodule Bar do @after_compile __MODULE__ defmacro __before_compile__(_env) do IO.inspect("#{__MODULE__}.__before_compile__") ...
New
bartblast
Suppose we’ve got the following module: defmodule TestModule do defmacro test_macro(param1, param2, param3) do quote do para...
New
Fl4m3Ph03n1x
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
vrod
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
hst337
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
shahryarjb
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
ream88
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
vrod
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
PatrickSachs
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
thojanssens1
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
saleyn
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
zoten
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
zimt28
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
shahryarjb
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
thojanssens1
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
  • Follow
  • Join
  • Shape
the conversation

Latest on Elixir Forum

Elixir Forum

Similar Portals

    None added yet

We're in Beta

About us Mission Statement