# \#module

**URL:** https://forum.elixirforum.com/tag/module/1284.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [How to conditionally compile a module with 3rd party macros](https://forum.elixirforum.com/t/how-to-conditionally-compile-a-module-with-3rd-party-macros/74444)

<div class="topic-metadata">

**Author:** [@fellipessanha](https://forum.elixirforum.com/u/fellipessanha)\
**Replies:** 0\
**Last updated:** [February 26, 2026, 6:29pm UTC](https://forum.elixirforum.com/t/how-to-conditionally-compile-a-module-with-3rd-party-macros/74444 "2026-02-26T18:29:21Z")

</div>

I’ve been working on a wrapper library for a brazillian Open Finance api, and I incurred into a fun error whilst trying to conditionally compile a module with 3rd party macros. I wrote a short text about this on medium, …

---

## [How to read the BEAM bytecode compiled into memory and that is not on the disk?](https://forum.elixirforum.com/t/how-to-read-the-beam-bytecode-compiled-into-memory-and-that-is-not-on-the-disk/43798)

<div class="topic-metadata">

**Author:** [@IvanR](https://forum.elixirforum.com/u/IvanR)\
**Replies:** 8\
**Last updated:** [August 13, 2025, 3:22am UTC](https://forum.elixirforum.com/t/how-to-read-the-beam-bytecode-compiled-into-memory-and-that-is-not-on-the-disk/43798 "2025-08-13T03:22:24Z")

</div>

Hi, I’m the author of the Domo library that validates struct’s data against its @type spec and would like to upgrade it to support in-memory modules. In the library, I read struct’s types by Code.Typespec.fetch\_types(m…

---

## [How to leave out modules at runtime?](https://forum.elixirforum.com/t/how-to-leave-out-modules-at-runtime/70221)

<div class="topic-metadata">

**Author:** [@Alex321](https://forum.elixirforum.com/u/Alex321)\
**Replies:** 4\
**Last updated:** [March 31, 2025, 1:47pm UTC](https://forum.elixirforum.com/t/how-to-leave-out-modules-at-runtime/70221 "2025-03-31T13:47:57Z")

</div>

I work on a library that has a helper module. In that module there are a few macros that are needed at compile time, but are completely useless at runtime. What’s more, the presence of that module is annoying because IEx…

---

## [Redefining modules in iex - does the original revert after leaving the session?](https://forum.elixirforum.com/t/redefining-modules-in-iex-does-the-original-revert-after-leaving-the-session/67877)

<div class="topic-metadata">

**Author:** [@MarkMekhaiel](https://forum.elixirforum.com/u/MarkMekhaiel)\
**Replies:** 5\
**Last updated:** [December 4, 2024, 2:47pm UTC](https://forum.elixirforum.com/t/redefining-modules-in-iex-does-the-original-revert-after-leaving-the-session/67877 "2024-12-04T14:47:07Z")

</div>

Hey I have an elixir / phoenix application that I often connect to remotely. I sometimes need to bugfix on there, and it helps me if I can insert some IO.inspects into modules to see what’s going on. If I redefine tha…

---

## [Dynamically reference a module spec](https://forum.elixirforum.com/t/dynamically-reference-a-module-spec/61675)

<div class="topic-metadata">

**Author:** [@erix](https://forum.elixirforum.com/u/erix)\
**Replies:** 2\
**Last updated:** [February 15, 2024, 6:36pm UTC](https://forum.elixirforum.com/t/dynamically-reference-a-module-spec/61675 "2024-02-15T18:36:14Z")

</div>

I have a module for each model in my program, and I can query them dynamically: model = String.to\_existing\_atom( "Elixir." \<\> data.params.model ) query = from m in model, where: m.domain == ^data.payload.domain, sel…

---

## [Defstruct inside \_\_using\_\_\`](https://forum.elixirforum.com/t/defstruct-inside-using/59904)

<div class="topic-metadata">

**Author:** [@wwaldner](https://forum.elixirforum.com/u/wwaldner)\
**Replies:** 2\
**Last updated:** [November 22, 2023, 4:24pm UTC](https://forum.elixirforum.com/t/defstruct-inside-using/59904 "2023-11-22T16:24:36Z")

</div>

Is it possible to define a struct inside a using defmodule Structor do defmacro \_\_using\_\_(\_) do quote do defmodule \_\_MODULE\_\_ do defstruct \[:field\] end def create(field) do %\_\_MO…

---

## [Why are module-based Supervisors recommended (outside of the tree root)?](https://forum.elixirforum.com/t/why-are-module-based-supervisors-recommended-outside-of-the-tree-root/59410)

<div class="topic-metadata">

**Author:** [@chocolatedonut](https://forum.elixirforum.com/u/chocolatedonut)\
**Replies:** 7\
**Last updated:** [November 1, 2023, 7:16pm UTC](https://forum.elixirforum.com/t/why-are-module-based-supervisors-recommended-outside-of-the-tree-root/59410 "2023-11-01T19:16:58Z")

</div>

Can you please provide an example of how and when is a module-based supervisor preferred (over starting a Supervisor via start\_link/2)? It isn’t clear to me what do “automatically” vs. “manually”, from the docs below, m…

---

## [Is there possible to find parent module in nested module?](https://forum.elixirforum.com/t/is-there-possible-to-find-parent-module-in-nested-module/58116)

<div class="topic-metadata">

**Author:** [@shahryarjb](https://forum.elixirforum.com/u/shahryarjb)\
**Replies:** 7\
**Last updated:** [September 6, 2023, 6:20pm UTC](https://forum.elixirforum.com/t/is-there-possible-to-find-parent-module-in-nested-module/58116 "2023-09-06T18:20:57Z")

</div>

Hi, I have this nested module: defmodule AA do defmodule BB do defmodule CC do ... end end end now is there a way get all the parents reversely? For example: \[AA.BB.CC, AA.BB, AA\] It should noted, …

---

## [How can add some data inside \_\_info\_\_(:compile)](https://forum.elixirforum.com/t/how-can-add-some-data-inside-info-compile/58117)

<div class="topic-metadata">

**Author:** [@shahryarjb](https://forum.elixirforum.com/u/shahryarjb)\
**Replies:** 0\
**Last updated:** [September 6, 2023, 7:26am UTC](https://forum.elixirforum.com/t/how-can-add-some-data-inside-info-compile/58117 "2023-09-06T07:26:04Z")

</div>

I create my nested module with macro, so I have question, how can add some data inside Test.\_\_info\_\_(:compile)? is it possible? I know I can create a function to keep essential data, but is is just for learning Thank yo…

---

## [Manipulate the AST before compilation](https://forum.elixirforum.com/t/manipulate-the-ast-before-compilation/54445)

<div class="topic-metadata">

**Author:** [@Astarno](https://forum.elixirforum.com/u/Astarno)\
**Replies:** 2\
**Last updated:** [March 9, 2023, 5:53pm UTC](https://forum.elixirforum.com/t/manipulate-the-ast-before-compilation/54445 "2023-03-09T17:53:27Z")

</div>

Hi there, Is there any way to change/edit the code/ast of a module before it compiles? I am trying to use the Interceptor library to add logging functionality to a module. In order to work, this library requires all fun…

---

## [Is is possible to control the order in which modules are compiled?](https://forum.elixirforum.com/t/is-is-possible-to-control-the-order-in-which-modules-are-compiled/46650)

<div class="topic-metadata">

**Author:** [@fireproofsocks](https://forum.elixirforum.com/u/fireproofsocks)\
**Replies:** 1\
**Last updated:** [March 17, 2022, 7:26pm UTC](https://forum.elixirforum.com/t/is-is-possible-to-control-the-order-in-which-modules-are-compiled/46650 "2022-03-17T19:26:31Z")

</div>

I ran into a problem when working on a new package designed to inspect Ecto schemas: inspecto | Hex I suppose this is “obvious” in retrospect, but when a module is being compiled and the @moduledoc block is being evalua…

---

## [Get typespecs for Code.compile\_string() module](https://forum.elixirforum.com/t/get-typespecs-for-code-compile-string-module/46022)

<div class="topic-metadata">

**Author:** [@feifan](https://forum.elixirforum.com/u/feifan)\
**Replies:** 3\
**Last updated:** [February 17, 2022, 3:33am UTC](https://forum.elixirforum.com/t/get-typespecs-for-code-compile-string-module/46022 "2022-02-17T03:33:41Z")

</div>

Hello! Is it possible to get the typespecs for a module that is compiled at runtime via Code.complie\_string()? For example, if I run compiled\_module, \_bytecode = Code.compile\_string( """ defmodule UserDefinedGreeter…

---

## [Create a module in memory, refresh/reload on change](https://forum.elixirforum.com/t/create-a-module-in-memory-refresh-reload-on-change/42098)

<div class="topic-metadata">

**Author:** [@dmitriid](https://forum.elixirforum.com/u/dmitriid)\
**Replies:** 5\
**Last updated:** [September 2, 2021, 6:09pm UTC](https://forum.elixirforum.com/t/create-a-module-in-memory-refresh-reload-on-change/42098 "2021-09-02T18:09:32Z")

</div>

It’s one of those “if you try it, you can figure it out” questions. I’m just hoping someone has already done this before and has some quick tips or a link to look at :slight\_smile: The meat of the question is: I have so…

---

## [Module.module\_info doesn't include all behaviours](https://forum.elixirforum.com/t/module-module-info-doesnt-include-all-behaviours/40105)

<div class="topic-metadata">

**Author:** [@sarat1669](https://forum.elixirforum.com/u/sarat1669)\
**Replies:** 6\
**Last updated:** [May 31, 2021, 10:13pm UTC](https://forum.elixirforum.com/t/module-module-info-doesnt-include-all-behaviours/40105 "2021-05-31T22:13:58Z")

</div>

I have a module which defines a behavior defmodule Light.Trigger do @callback initialize(%{}) :: {:ok, any()} defmacro \_\_using\_\_(\_) do quote do use GenServer @behaviour Light.Trigger ... e…

---

## [Using \_\_MODULE\_\_ in nested modules](https://forum.elixirforum.com/t/using-module-in-nested-modules/39711)

<div class="topic-metadata">

**Author:** [@stevensonmt](https://forum.elixirforum.com/u/stevensonmt)\
**Replies:** 7\
**Last updated:** [May 15, 2021, 5:23pm UTC](https://forum.elixirforum.com/t/using-module-in-nested-modules/39711 "2021-05-15T17:23:07Z")

</div>

If I have nested modules is it possible to use the syntax \_\_MODULE\_\_ in the submodule? I’m getting an error that says “cannot access struct RootModule …” when I have something like this: defmodule RootModule do defmo…

---

## [Did we get private modules?](https://forum.elixirforum.com/t/did-we-get-private-modules/39531)

<div class="topic-metadata">

**Author:** [@rm-rf-etc](https://forum.elixirforum.com/u/rm-rf-etc)\
**Replies:** 5\
**Last updated:** [May 11, 2021, 3:56am UTC](https://forum.elixirforum.com/t/did-we-get-private-modules/39531 "2021-05-11T03:56:27Z")

</div>

I see there was a long discussion on the proposal of private modules, but I can’t tell what decision was reached. I’m writing a library which has an internal-only \_\_using\_\_/1 macro, and I want to know how I can make it p…

---

## [Unknown CA error](https://forum.elixirforum.com/t/unknown-ca-error/38978)

<div class="topic-metadata">

**Author:** [@Papillon6814](https://forum.elixirforum.com/u/Papillon6814)\
**Replies:** 9\
**Last updated:** [April 18, 2021, 1:54am UTC](https://forum.elixirforum.com/t/unknown-ca-error/38978 "2021-04-18T01:54:09Z")

</div>

Hello. I’m using elixir-google-api for storing images in google cloud storage. I use goth for authentication of GCP. Goth works in my development environment, but it does not work in a docker container. \*\* (MatchErro…

---

## [How do you monitor channels?](https://forum.elixirforum.com/t/how-do-you-monitor-channels/37831)

<div class="topic-metadata">

**Author:** [@Papillon6814](https://forum.elixirforum.com/u/Papillon6814)\
**Replies:** 2\
**Last updated:** [February 27, 2021, 11:14am UTC](https://forum.elixirforum.com/t/how-do-you-monitor-channels/37831 "2021-02-27T11:14:04Z")

</div>

Hello. I’m looking for a way to visualize channels. I only know we can check who joined channel by watching logs. Do you know any other good ways?

---

## [Struct and complex logic](https://forum.elixirforum.com/t/struct-and-complex-logic/32449)

<div class="topic-metadata">

**Author:** [@smanza](https://forum.elixirforum.com/u/smanza)\
**Replies:** 7\
**Last updated:** [June 21, 2020, 7:13pm UTC](https://forum.elixirforum.com/t/struct-and-complex-logic/32449 "2020-06-21T19:13:23Z")

</div>

Hello. I practiced Elixir for few months now but every time I wonder about some code organisation and particularly with struct and business logic. I don’t know if struct must only define simple data transformation and …

---

## [Is there a way to get information of multiple specific modules?](https://forum.elixirforum.com/t/is-there-a-way-to-get-information-of-multiple-specific-modules/27806)

<div class="topic-metadata">

**Author:** [@tony612](https://forum.elixirforum.com/u/tony612)\
**Replies:** 4\
**Last updated:** [December 26, 2019, 6:19am UTC](https://forum.elixirforum.com/t/is-there-a-way-to-get-information-of-multiple-specific-modules/27806 "2019-12-26T06:19:56Z")

</div>

I’m developing some features for GitHub - elixir-protobuf/protobuf: A pure Elixir implementation of Google Protobuf. · GitHub, but I need a way to know what modules are protobuf modules and even want to store more inform…

---

## [Module is not available](https://forum.elixirforum.com/t/module-is-not-available/23393)

<div class="topic-metadata">

**Author:** [@Fl4m3Ph03n1x](https://forum.elixirforum.com/u/Fl4m3Ph03n1x)\
**Replies:** 5\
**Last updated:** [June 25, 2019, 2:41pm UTC](https://forum.elixirforum.com/t/module-is-not-available/23393 "2019-06-25T14:41:29Z")

</div>

Background I have an application :myapp and I am trying to add some web functionality to it from zero using Plug. However, even though I have all the files and modules, present, I still can’t launch it because iex can’t …

---

## [Difference between in load a large array string from a config file and load from a module](https://forum.elixirforum.com/t/difference-between-in-load-a-large-array-string-from-a-config-file-and-load-from-a-module/21486)

<div class="topic-metadata">

**Author:** [@GusGA](https://forum.elixirforum.com/u/GusGA)\
**Replies:** 2\
**Last updated:** [April 8, 2019, 3:39pm UTC](https://forum.elixirforum.com/t/difference-between-in-load-a-large-array-string-from-a-config-file-and-load-from-a-module/21486 "2019-04-08T15:39:00Z")

</div>

I forked an elixir lib that generates heroku random names. On the “master” repo, the nouns and the adjectives are loaded from a config file. I change it, I create a module from each one, one for the nouns and one for th…

---

## [Can we measure module and function usage?](https://forum.elixirforum.com/t/can-we-measure-module-and-function-usage/21370)

<div class="topic-metadata">

**Author:** [@Rich\_Morin](https://forum.elixirforum.com/u/Rich_Morin)\
**Replies:** 4\
**Last updated:** [April 3, 2019, 10:25pm UTC](https://forum.elixirforum.com/t/can-we-measure-module-and-function-usage/21370 "2019-04-03T22:25:40Z")

</div>

I think it would be interesting and possibly useful to gather statistics on module and function usage. For example, when I did a quick check on module use in my code base, I got these numbers: Enum.\* (268) Map.\* (63) S…

---

## [Elixir could suggest functions in other modules](https://forum.elixirforum.com/t/elixir-could-suggest-functions-in-other-modules/19091)

<div class="topic-metadata">

**Author:** [@Rich\_Morin](https://forum.elixirforum.com/u/Rich_Morin)\
**Replies:** 2\
**Last updated:** [January 4, 2019, 8:18am UTC](https://forum.elixirforum.com/t/elixir-could-suggest-functions-in-other-modules/19091 "2019-01-04T08:18:48Z")

</div>

When Elixir doesn’t recognize a variable name, it tries to make helpful suggestions. It could also make suggestions when a program tries to use a function that isn’t available. For example, when the user tries to run Li…
