mudasobwa
Creator of Cure
I’ve been heavily working with macros for more than 10 years already and I always used kinda ad-hoc code to expand/debug/test those when in trouble.
So yeah, it’s better to get a reputation of a slowpoke rather than to spend another 10 years fighting the ghosts.
Welcome ExPanda library that expands macros all the turtles down (short of defmodule and def/defp/defmacro/defmacrop structural forms.)
It’s time to take a look at what use GenServer does actually become in your code:
iex|🌢|1 ▶ "defmodule M, do: use GenServer"
|> ExPanda.expand_to_string()
|> elem(1)
|> IO.puts()
defmodule M do
require GenServer
opts = []
@behaviour GenServer
case :erlang.not(Module.has_attribute?(M, :doc)) do
false ->
nil
true ->
Module.__put_attribute__(
M,
:doc,
{0,
"Returns a specification to start this module under a supervisor.\n\nSee `Supervisor`.\n"},
nil,
[]
)
end
def child_spec(init_arg) do
default = %{id: M, start: {M, :start_link, [init_arg]}}
Supervisor.child_spec(default, unquote(Macro.escape(opts)))
end
defoverridable child_spec: 1
@before_compile GenServer
@doc false
def handle_call(msg, _from, state) do
proc =
case Process.info(:erlang.self(), :registered_name) do
{_, []} -> :erlang.self()
{_, name} -> name
end
case :erlang.phash2(1, 1) do
0 ->
:erlang.error(
RuntimeError.exception(
<<"attempted to call GenServer ", String.Chars.to_string(inspect(proc))::binary,
" but no handle_call/3 clause was provided">>
),
:none,
error_info: %{module: Exception}
)
1 ->
{:stop, {:bad_call, msg}, state}
end
end
@doc false
def handle_info(msg, state) do
proc =
case Process.info(:erlang.self(), :registered_name) do
{_, []} -> :erlang.self()
{_, name} -> name
end
:logger.error(
%{label: {GenServer, :no_handle_info}, report: %{module: M, message: msg, name: proc}},
%{
domain: [:otp, :elixir],
error_logger: %{tag: :error_msg},
report_cb: &:erlang./(GenServer.format_report(), 1)
}
)
{:noreply, state}
end
@doc false
def handle_cast(msg, state) do
proc =
case Process.info(:erlang.self(), :registered_name) do
{_, []} -> :erlang.self()
{_, name} -> name
end
case :erlang.phash2(1, 1) do
0 ->
:erlang.error(
RuntimeError.exception(
<<"attempted to cast GenServer ", String.Chars.to_string(inspect(proc))::binary,
" but no handle_cast/2 clause was provided">>
),
:none,
error_info: %{module: Exception}
)
1 ->
{:stop, {:bad_cast, msg}, state}
end
end
@doc false
def terminate(_reason, _state) do
:ok
end
@doc false
def code_change(_old, state, _extra) do
{:ok, state}
end
defoverridable code_change: 3, terminate: 2, handle_info: 2, handle_cast: 2, handle_call: 3
end
https://github.com/am-kantox/ex_panda
Enjoy!
Trending in Announcing
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi all!
I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas.
You...
New
Hello
Published a new library - ProcessHub!
ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
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
This showed up on my feed.. anyone heard of it? Just hype?
Ox Alpha is a reasoning model designed for coding, sustained ag...
New
It’s not that it’s vocabulary is too advanced. It’s something worse.
I get lost trying to follow even a paragraph written by Claude. It’...
New
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
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
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cmo
Nice. I’ve been patiently waiting years for someone to integrate this sort of thing into the LSP for me.
nulltree
10/10 name.
mudasobwa
The version
1.0is to roll out with a motto “chewing bamboo shoots to the roots.”mudasobwa
I have plans to ping ExpertLSP team members after I have it tested thoroughly with my own Ragex.
dmitrykleymenov
Wow, thanks for sharing. It could be pretty helpful